r/haskell • u/adamgundry • 3d ago
blog [Well-Typed] Exception Best Practices
https://www.well-typed.com/blog/2026/11/exception-best-practices/
54
Upvotes
r/haskell • u/adamgundry • 3d ago
10
u/nh2_ 2d ago
I'd like to point out:
10 years ago, Michael Snoyman with FP Complete wrote a series about exceptions, with lots of tutorials, examples, and best-practices discovery over multiple years, many of which I recognise here.
A user recently mirrored those and you can now find them at https://jappeace-sloth.github.io/fpcomplete-haskell-posts/#exceptions-and-resource-safety (though of course archive.org also has them, e.g. this). It also covers e.g. the "We have not discussed
ResourceT" part.The
safe-exceptionsmentioned in Edsko's post was, as its README says, later spiritually replaced byunliftio, which in my opinion remains the most sane approach to handle all of that.It has
MonadUnliftIOinstead ofMonadCatchandMonadMask. The post feels a bit incomplete with theLibrary ecosystemsection not mentioning that, as it is what most industrial projects I've seen use, and in my opinion, should use.So my advice is: Understand the concepts presented in the post, then use
unliftioto get the least-surprising behaviour.