Skip to content

Commit

Permalink
Merge pull request #56 from haskell-works/newhoggy/new-runErrorMap-fu…
Browse files Browse the repository at this point in the history
…nction

New `runErrorMap` function
newhoggy authored Nov 6, 2024
2 parents de6d2b2 + 9ed1034 commit 58ccb3d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/HaskellWorks/Polysemy/Error.hs
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ module HaskellWorks.Polysemy.Error
( module HaskellWorks.Error,
trap,
trap_,
runErrorMap,
embedRunExceptT,
embedThrowExceptT,
) where
@@ -30,6 +31,14 @@ trap_ :: forall e a r. ()
trap_ h =
trap (const h)

-- | Run an 'Error' effect and map the error value to a different type.
runErrorMap :: ()
=> (e -> d)
-> Sem (Error e : r) a
-> Sem r (Either d a)
runErrorMap f =
fmap (first f) . runError

embedRunExceptT :: forall e a r m. ()
=> Member (Embed m) r
=> ExceptT e m a

0 comments on commit 58ccb3d

Please sign in to comment.