-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add some interesting combinators that build on alternation over sequences #82
Conversation
Whoa, fun! Thanks for the PR.
|
@@ -159,6 +159,7 @@ | |||
D4FC47B21A37E47C00D23A6F /* Products */, | |||
); | |||
sourceTree = "<group>"; | |||
usesTabs = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t know why Xcode never enables this for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, what I meant was that as far as I knew this was already enabled.
Basically all of these are awesome and you are awesome and I am very grateful 🙇 Just the one question, really; this is golden ⭐ |
`inject` unfortunately is a little confusing because of the connection with reduce/inject in Smalltalk/Ruby. Also `pure` is better.
Thanks for the lovely comments @robrix, glad you liked it! Took me quite a lot of wading through complex index-munging logic beforeI realised that I could use Ready when you are. |
Oh btw, something else I considered was adding |
|
Add some interesting combinators that build on alternation over sequences
🎉 I’ve added you as a collaborator @sharplet. Same as on |
Also: ⭐ for your branch name. |
😁 |
Let me preface this by saying that may agenda here was ultimately to build the
anyOf()
combinator for my own purposes — I don't know if this is the kind ofthing you want to be included in Madness core! But along the way I discovered
some interesting and fun things, and if any of them fit then feel free to
cherry-pick just those. I've got what I was looking for. 😇
A brief summary:
inject()
: A name that I came up with for monadicreturn
over parsers.(I'm not super attached to the name.)
oneOf()
: Kinda looks likemconcat
over parsers (!), but limited to literals.(I'm guessing that
mconcat
wouldn't really be possible because of thetrouble with function types in generic constraints, and the general lack of
higher-kinded types.)
anyOf()
: That's what I came here for. I'm planning to use this one to parseabbreviated short option strings, e.g.,
-la => [-l, -a] // "any of" l or a
.It's interesting, but up to you whether it's suitable for inclusion in Madness.
allOf()
: Logical addition to go alongsideanyOf()
. Basically a greedierversion that pulls out all the matches from the set of literals.
Thanks for the great library, this was a lot of fun! Looking forward to your
feedback. 😊