Last active
June 4, 2017 09:04
-
-
Save s9gf4ult/2d4d4e76f3842cbdf52bed2f3943aada to your computer and use it in GitHub Desktop.
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
seriousBusiness :: Trans IO Int | |
seriousBusiness = do | |
res1 <- doSomeAction | |
cleanupOnErrors res1 $ do | |
res2 <- doOtherAction | |
cleanupOnErrors res2 $ do | |
res3 <- doEvenMoreAction | |
cleanupOnErrors res3 $ do | |
return 42 | |
cleanupOnErrors :: (MonadCatch m) => Res -> m a -> m a | |
cleanupOnErrors res ma = catchAll ma $ \e -> do | |
cleanupRes res | |
throwM e | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment