Computer Science > Programming Languages
[Submitted on 31 Oct 2018 (this version), latest version 30 Jan 2019 (v3)]
Title:Exceptionally Monadic Error Handling
View PDFAbstract:We notice that the type of src_haskell{catch :: c a -> (e -> c a) -> c a} operator is a special case of monadic src_haskell{bind} 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 $\lambda A.E \lor 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_haskell{catch} operator of the "flipped" "conjoined" error monad $\lambda E.E \lor 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.
Submission history
From: Jan Malakhovski [view email][v1] Wed, 31 Oct 2018 17:42:58 UTC (206 KB)
[v2] Mon, 5 Nov 2018 07:14:43 UTC (207 KB)
[v3] Wed, 30 Jan 2019 20:39:54 UTC (208 KB)
Current browse context:
cs.PL
References & Citations
Bibliographic and Citation Tools
Bibliographic Explorer (What is the Explorer?)
Litmaps (What is Litmaps?)
scite Smart Citations (What are Smart Citations?)
Code, Data and Media Associated with this Article
CatalyzeX Code Finder for Papers (What is CatalyzeX?)
DagsHub (What is DagsHub?)
Gotit.pub (What is GotitPub?)
Papers with Code (What is Papers with Code?)
ScienceCast (What is ScienceCast?)
Demos
Recommenders and Search Tools
Influence Flower (What are Influence Flowers?)
Connected Papers (What is Connected Papers?)
CORE Recommender (What is CORE?)
arXivLabs: experimental projects with community collaborators
arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.
Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.
Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.