Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pair combinator #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added pair combinator #4

wants to merge 1 commit into from

Conversation

sayon
Copy link

@sayon sayon commented Aug 24, 2016

Instead of using >>= as a generic but a bit cumbersome way to work with tuples of arbitrary length, you can use <~~> to pair up combinators.

@tekknolagi
Copy link

@pyrocat101 thoughts?

@Schmavery
Copy link

Missing the corresponding mli change:

val ( <~~> ) : ('token, 'a) parser -> ('token, 'b) parser -> ('token, ('a * 'b)) parser

@@ -82,6 +82,7 @@ let (=>) x f = x >>= fun r -> return (f r)
let (>>) x y = x >>= fun _ -> y
let (<<) x y = x >>= fun r -> y >>= fun _ -> return r
let (<~>) x xs = x >>= fun r -> xs >>= fun rs -> return (r :: rs)
let (<~~>) x y = x >>= fun r -> y >>= fun rs -> return (r,rs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be

let (<~~>) x y = x >>= fun r1 -> y >>= fun r2 -> return (r1, r2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants