You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tryError is used to state an additional law about the interaction of catchError with (>>=).
For reference, the 5 laws other than that one can be found in the paper Just do it: Simple Monadic Equational Reasoning, Section 5 (modulo a change from catch :: m a -> m a -> m a to catchError :: m a -> (e -> m a) -> m a).
I also cut the original comment on this class. I find the first sentence quite hard to read, and the rest is not quite relevant.
It is common to use Either String
IMO Either is a very niche instance of MonadError.
You can also define your own error type and/or use a monad type constructor
other than @'Either' 'String'@ or @'Either' 'IOError'@.
> In these cases you will have to explicitly define instances of the 'MonadError'
> class.
You don't need to define additional instances if you just want to vary your exception type from String or IOError (I would assume this is a remnant of the old MonadError).
(If you are using the deprecated "Control.Monad.Error" or "Control.Monad.Trans.Error", you may also have to define an 'Error' instance.)
The old MonadError has been deprecated for so long, I would assume people who have to maintain such old code should be able to follow the changelog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tryErroris used to state an additional law about the interaction ofcatchErrorwith(>>=).For reference, the 5 laws other than that one can be found in the paper Just
doit: Simple Monadic Equational Reasoning, Section 5 (modulo a change fromcatch :: m a -> m a -> m atocatchError :: m a -> (e -> m a) -> m a).