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

Hoist between ExceptT error types #10

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Control/Monad/Error/Hoist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import Control.Monad.Error.Class (MonadError (..))

import Data.Either (Either, either)

import Control.Monad.Except (Except, ExceptT, runExcept,
import Control.Monad.Except (Except, ExceptT(..), runExcept,
runExceptT)

-- | Given a conversion from the error in @t a@ to @e'@, we can hoist the
Expand Down Expand Up @@ -194,3 +194,6 @@ instance Applicative m => PluckError e (Either e) m where
instance Monad m => PluckError e (ExceptT e m) m where
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
instance Monad m => PluckError e (ExceptT e m) m where
instance (m ~ n, Monad m) => PluckError e (ExceptT e m) n where

I think this is what we want

pluckError = runExceptT
foldError f g = either f g <=< runExceptT

instance Monad m => PluckError e (ExceptT e m) (ExceptT e' m) where
pluckError = ExceptT . fmap Right . runExceptT
Loading