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 8602027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:58:52+00:00 2026-06-12T01:58:52+00:00

On page 76 we define a function item as parser — a function that

  • 0

On page 76 we define a function item as parser — a function that takes a String and returns [(Char, String)] or [] if failed.

On page 78 we define a function sat that takes a predicate p and “wraps” a parser construction around that

p :: (Char -> Bool) -> Parser Char
sat p = do x <- item
           if p x then return x else failure

What I don’t understand is the magic of <-? If the result of item is not empty then this operator should unwrap the list and fetch the first item from the tuple, otherwise it should produce something that won’t choke the predicate. What am I missing?

  • 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-12T01:58:53+00:00Added an answer on June 12, 2026 at 1:58 am
    do x <- item
       if p x then return x else failure
    

    This is syntactic sugar for

    item >>= (\x -> if p x then return x else failure)
    

    >>= is the monadic bind operator.

    What you’re missing is: what is the definition of >>= for the Parser type? (Where in the book is the Monad instance for Parser defined? It will start instance Monad Parser where.)

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

Sidebar

Related Questions

So, as described on this msdn page , when you define a Connection String
I am attempting to define a function in Maple that defines the Taylor Series
Is that possible to define a function without referencing to self this way? def
I have defined a function in which i want to open a page on
In a Rails 3.2 app I define the page title using <% title Title
Any table I define with sidewaystable appears at the last page of created pdf
I have created a JSF 2 page which uses Facelets to define the structure
I am creating one asp page. In that page i defined one property like
On my JSP page, I defined some javascript with a variable that get value
In the following code I am attempting to:- Define google analytics on the page

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.