Skip to content

Instantly share code, notes, and snippets.

@s9gf4ult
Last active June 4, 2017 09:04
Show Gist options
  • Save s9gf4ult/2d4d4e76f3842cbdf52bed2f3943aada to your computer and use it in GitHub Desktop.
Save s9gf4ult/2d4d4e76f3842cbdf52bed2f3943aada to your computer and use it in GitHub Desktop.
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