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

  • SEARCH
  • Home
  • 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 5849785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:02:59+00:00 2026-05-22T13:02:59+00:00

I am reading Programming In Haskell, in the 8th chapter, the author gives an

  • 0

I am reading Programming In Haskell, in the 8th chapter, the author gives an example of writing parsers.
The full source is here: http://www.cs.nott.ac.uk/~gmh/Parsing.lhs
I can’t understand the following part: many permits zero or more applications of p,
whereas many1 requires at least one successful application:

many        ::    Parser a → Parser [a ]
many p      =     many1 p +++ return [ ]
many1       ::    Parser a → Parser [a ]
many1 p     = do v ← p
                 vs ← many p
                 return (v : vs)

How the recursive call happens at

vs <- many p

vs is the result value of many p, but many p called many1 p, all many1 has in its definition is a do notation, and again has result value v, and vs, when does the recursive call return?
Why does the following snippet can return [("123","abc")] ?

> parse (many digit) "123abc"
[("123", "abc")]
  • 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-05-22T13:02:59+00:00Added an answer on May 22, 2026 at 1:02 pm

    For the last question:

    > parse (many digit) "123abc"
    [("123", "abc")]
    

    Means that parsing has been successful as at least one result has been returned in the answer list. Hutton parsers always return a list – the empty list means parsing failure.

    The result (“123”, “abc”) means that parsing has found three digits “123” and stopped at ‘a’ which is not a digit – so the “rest of the input” is “abc”.

    Note that many means “as many as possibly” not “one or more”. If it were “one or more” you’d get this result instead:

    [("1", "23abc"), ("12", "3abc"), ("123", "abc")]
    

    This behaviour wouldn’t be very good for deterministic parsing, though it might sometimes be needed for natural language parsing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading Programming Scala . At the beginning of chapter 4, the author comments
I have just been getting into low level programming (reading/writing to memory that sort
I'm reading Simon Thompson's Haskell: The Craft of Functional Programming , and I'm wondering
I've been reading various programming styles like XP (writing the test first), and came
I've been reading Programming WPF, here is one of the examples about Control Template:
I'm reading through Programming Entity Framework, 2nd Edition , and in first chapter there
I had a question... I'm reading Cocoa Programming for Mac OSX and in Chapter
No surprise here, possible dupes: Good Books for Learning Web Programming Required Reading for
I'm reading Programming Erlang by Joe Armstrong(Pragmatic Bookshelf) . In name_server.erl source code on
I'm reading Programming Perl , and I found this code snippet: sub new {

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.