-
Notifications
You must be signed in to change notification settings - Fork 8
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
First expression in mdo
is eagerly evaluated
#5
Comments
Yeah, I've actually run into this but haven't fixed it (obviously). A kind of stupid workaround for now is to just insert a do-nothing return expression at the beginning. Thanks for the report though, will work on a fix. |
I'll just drop some thoughts in here ... Actually, on further thought, there is a real question about how to treat this. The above example translates thus: (>>= (throw (RuntimeException. "AHA!"))
(fn [failure] (>>= (right :something)
(fn [_] :success)))) And if you think of Of course it's possible to have It's still a PITA of course. |
Agree with your concerns. Thinking about it as My background isn't in haskell, but my mental model for Again, I'm not sure if there's a good solution for this -- though at minimal maybe this could be added to the README. |
I'm seeing that the first expression inside an
mdo
is always evaluated, which may execute side-effects before the monad is run.For example:
This throws the runtime exception before I try to execute it with
monads.core/run-monad
The text was updated successfully, but these errors were encountered: