[Haskell-cafe] how to catch/bracket in yesod-1.6?

Simon Hafner hafnersimon at gmail.com
Wed Apr 25 12:21:33 UTC 2018


>From the doc [1] there's a few instances you can use. `MonadResource`
sounds like the most obvious choice, with its `allocate` [2], but
that'll require you to refactor your application a bit. It's what I'd
recommend though. If that's unfeasable, there's always the new
`bracket_` on `MonadUnliftIO` [3]

[1] https://www.stackage.org/haddock/lts-11.6/yesod-core-1.6.3/Yesod-Core-Handler.html#t:HandlerFor
[2] https://www.stackage.org/haddock/lts-11.6/resourcet-1.2.1/Control-Monad-Trans-Resource.html#v:allocate
[3] https://www.stackage.org/haddock/lts-11.6/unliftio-0.2.6.0/UnliftIO-Exception.html#v:bracket_

2018-04-25 13:26 GMT+02:00 waldmann <johannes.waldmann at htwk-leipzig.de>:
> Dear Cafe,
>
> I wonder what's the recommended way to catch an exception,
> clean up resources, etc., in a yesod Handler.
> I was using Control.Monad.Catch.bracket_ in legacy code but now I get
> "No instance for (Control.Monad.Catch.MonadMask (HandlerFor App))"
>
> - J
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.


More information about the Haskell-Cafe mailing list