Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Control.Monad.Except (ExceptT(..), throwError)
- data Error = MyError | ThirdPartyError String
- -- some third-party function, that doesn't return our type
- doSomethingWithX :: Integer -> Either String ()
- doSomethingWithX = undefined
- computeX :: (Monad m) => ExceptT Error m Integer
- computeX = undefined
- doStuff :: (Monad m) => ExceptT Error m ()
- doStuff = do
- x <- computeX
- lift3rdParty $ doSomethingWithX x
- lift3rdParty :: (Monad m) => Either String t -> ExceptT Error m t
- lift3rdParty = either (throwError . ThirdPartyError) return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement