I am trying to learn Haskell by writing small programs ... so now I am writing lexer / parser for simple expressions. (Yes, I could use Alex / Happy ... but first I want to learn the main language).
My parser is essentially a set of recursive functions that build a tree. In the case of syntax errors, I would usually throw an exception (i.e., If I wrote in C #), but in Haskell this did not seem to be encouraging.
So what is the alternative? I do not want to check the error states in each individual fragment of the analyzer. I want to either get the correct tree of nodes, or an error state with details.
exception-handling recursion haskell
stusmith
source share