logo
首页技术栈工具库讨论
partial-handler

partial-handler

If you have ever had to compose an exception handler for exceptions of multiple types, you know how frustraiting it can get. This library approaches this issue by providing a composable exception handler type, which has a Monoid instance. Composability means that you can define custom partial handlers and reuse them by composing other handlers from them. Here is an example of a composable partial handler, which only defines what to do in case of a ThreadKilled exception (the code uses the LambdaCase extension): Here's how you can construct a handler of type SomeException -> IO () using this library: and here is how you would do it traditionally (with the MultiWayIf extension): Putting all the syntactic trickery to make it shorter aside, this handler is a monolith block of code. Unlike with PartialHandler you can neither decompose it into simpler ones, nor compose it with other handlers to form a more complex one.
由 
bruceshi2021-01-13 收录
--
推荐
不推荐
更多信息
HACKAGE
carbal install partial-handler
查看
标签
根据用户添加的标签生成
暂无标签