-
Notifications
You must be signed in to change notification settings - Fork 114
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
Can we have an eitherReader convenience function? #48
Comments
Yes, that would be a useful addition. Can you submit a patch? |
I just realized that my implementation doesn't work. Weirdly enough, it does work on a successful parse; if the parse fails, however, and returns This implementation, using eitherReader str2either = reader (either fail return . str2either) It's very unclear to me what's going on here, I believe the two should really do the same. (This is like in #47, but this time, it's on the |
I'll look into it, thanks for the report. |
I think it comes from the (Just r, ErrorMsg _) -> return r here (at least the error message I expect is contained in that. |
Thanks! |
For parsing simple arguments, I often define functions of type
parseFoo :: String -> Either String a
, which are used in multiple places, and then I want to use them withreader
.Could we have a convenience function like this?
This would not be necessary if the
fail
instance ofEither String
was not an exception, but it is andfail
isn't a realy thing inMonad
either (no pun intended).Thanks :)
The text was updated successfully, but these errors were encountered: