Offer an 'optional' combinator #53

ocharles opened this Issue Nov 29, 2012 · 2 comments


None yet

3 participants


It would be much more elegant if we could have an optional combinator. This would both clean up the API (no need to offer stringRead and optionalStringRead), while also providing nicer code for authors. For example, at the moment I have:

  where labelCode = check "Label codes must be positive and at most 5 digits"
                      (maybe True (\i -> i > 0 && i < 100000)) $
                        optionalStringRead "Invalid integer" Nothing

Which is a tad on the messy side (I have to handle Maybe inside that check).


This is also what I originally wanted to do, but I couldn't come up with a good implementation and semantics that make sense. The problem is that it's extremely tricky for composed forms...


Here's my excessively copy-paste use case:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment