Skip to content
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

Why MonadError instance for ChronicleT uses underlying monad #67

Open
phadej opened this issue Oct 25, 2016 · 1 comment
Open

Why MonadError instance for ChronicleT uses underlying monad #67

phadej opened this issue Oct 25, 2016 · 1 comment
Assignees

Comments

@phadej
Copy link
Collaborator

phadej commented Oct 25, 2016

Can it be made lawful directly. Why if not? Add to documentation

@phadej phadej self-assigned this Oct 25, 2016
@mutantmell
Copy link

mutantmell commented Oct 25, 2016

I believe that this is a valid instance:

instance (Semigroup c, Monad m) => MonadError c (ChronicleT c m) where
    throwError = confess
    catchError (ChronicleT m) handler = ChronicleT $ do
      a <- m
      case a of
        This  x   -> runChronicleT $ handler x
        That    y -> return $ That y
        These _ y -> return $ That y

It discards errors from a 'These' constructor, which is consistent with the idea that 'These' represents non-fatal error states.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants