Exceptionally Monadic Error Handling

10/31/2018 ∙ by Jan Malakhovski, et al. ∙ 0

We notice that the type of src_haskellcatch :: c a -> (e -> c a) -> c a operator is a special case of monadic src_haskellbind operator src_haskell(>>=) :: m a -> (a -> m b) -> m b and the semantic (surprisingly) matches. For instance, the reader is probably aware that the monadic essence of the src_haskell(>>=) operator of the error monad λ A.E A is to behave like identity monad for "normal" values and to stop on "errors". The unappreciated fact is that handling of said "errors" with a src_haskellcatch operator of the "flipped" "conjoined" error monad λ E.E A is, too, a monadic computation that treats still unhandled "errors" as "normal" values and stops when an "error" is finally handled. This fact has several immediate practical consequences for monadic parser combinators and similar structures. More importantly, however, it can be generalized to provide a uniform error handling framework for /all/ monadic error handling mechanisms we are aware of. It also provides some surprising perspectives on error handling in general.

READ FULL TEXT
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.