-
Notifications
You must be signed in to change notification settings - Fork 62
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
Is there a reason for no MonadFail instance? #306
Comments
No reason that comes to mind, although do you have a specific example use case in mind? I've certainly used an ExceptT transformer to a similar effect. |
It just seems kinda neater in some scenarios. Especially if the sampling is abstracted and we can't "fix" it at the source. enumerator $ do
a <- uniformD [Just 1, Just 2, Nothing]
condition (isJust a)
pure a enumerator $ do
Just a <- uniformD [Just 1, Just 2, Nothing]
pure a |
[lengthy comment following] Your two examples even have different types, the first being To achieve that effect, one would like to write: enumerator $ do
aMaybe <- uniformD [Just 1, Just 2, Nothing]
case aMaybe of
Just a -> pure a
Nothing -> do
score 0
error "Impossible" But unfortunately, there is no law in I read your proposal as adding such a possibility to the interface via |
Yes, the types being different was a transcription error. And yes, I had noticed that So your conclusion is correct, I'd actually like to have a |
Sometimes it would be neat to be able to use a fallible pattern match in
do
-notation, similar to what we get with lists. This is enabled by having aMonadFail
instance.I was wondering if there was some reason why there is no
MonadFail
instance available that I can not see?The text was updated successfully, but these errors were encountered: