Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7988411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:26:34+00:00 2026-06-04T12:26:34+00:00

I’ve got a Parsec parser that I’m writing in mostly applicative style. In one

  • 0

I’ve got a Parsec parser that I’m writing in mostly applicative style. In one case (the only time I’m using sepBy) I’m having trouble with my eol parser. First, a few definitions:

eol =   try (string "\n\r")
    <|> try (string "\r\n")
    <|> string "\n"
    <|> string "\r"
    <?> "eol"

betaLine = string "BETA " *> (StrandPair <$> p_int <*> p_int <*> p_int <*> (p_int *> p_direction) <*> p_exposure) <* eol

Note: betaLine works perfectly (for brevity, I’ve left out the definitions of p_int and such:

*HmmPlus> parse betaLine "beta" "BETA 6 11 5 24 -1 oiiio\n"
Right (StrandPair {firstStart = 6, secondStart = 11, pairLength = 5, parallel =   Antiparallel, exposure = [Exposed,Buried,Buried,Buried,Exposed]})

The problem occurs with this other parser, hmmMatchEmissions:

 hmmMatchEmissions     = spaces *> (V.fromList <$> sepBy p_logProb spaces) <* eol <?> "matchEmissions"

*HmmPlus> parse hmmMatchEmissions "me" "      2.61196  4.43481  2.86148  2.75135  3.26990  2.87580  3.69681\n"
Left "me" (line 2, column 1):
unexpected end of input

Now, if I remove the <* eol from the parser definition, and remove the \n from the line, it does work:

*HmmPlus> parse hmmMatchEmissions "me" "      2.61196  4.43481  2.86148  2.75135  3.26990  2.87580  3.69681"
Right (fromList [NonZero 2.61196,NonZero 4.43481,NonZero 2.86148,NonZero 2.75135,NonZero 3.2699,NonZero 2.8758,NonZero 3.69681])

So, why is eol working in the case of betaLine but not hmmMatchEmissions?

I will note that this is the only place I’m using sepBy; could that be a clue?

Update: I’ve done the following, and it now fails differently :/

reqSpaces = many1 (oneOf " \t")

optSpaces = many (oneOf " \t")

hmmMatchEmissions = optSpaces *> (V.fromList <$> sepBy1 p_logProb reqSpaces) <* eol <?> "matchEmissions"

And here’s the failure:

*HmmPlus> parse hmmMatchEmissions "me" "  0.123  0.124\n"
Left "me" (line 1, column 10):
unexpected "0"
expecting eol

I’ll note that the unexpected 0 in column 10 is the first character of the 0.124 token.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:26:36+00:00Added an answer on June 4, 2026 at 12:26 pm

    The problem seems to be that your p_logProb parser consumes whitespace. So, this is what happens during the parse:

      0.123  0.124\n
    []               optSpaces
      [-----]        p_logProb
             {       trying reqSpaces
             {       trying eol
                     failure: expecting eol
    

    The p_logProb parser should only consume the thing that it parses, namely the actual number. This will lead to the intended parse:

      0.123  0.124\n
    []               optSpaces
      [---]          p_logProb
           []        reqSpaces
             [---]   p_logProb
                  {  trying reqSpaces
                  #  eol
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.