Hostname: page-component-5d59c44645-mhl4m Total loading time: 0 Render date: 2024-03-04T21:23:28.107Z Has data issue: false hasContentIssue false

Monadic parsing in Haskell

Published online by Cambridge University Press:  01 July 1998

University of Nottingham, Nottingham, UK
University of Utrecht, Utrecht, The Netherlands
Rights & Permissions [Opens in a new window]


Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

This paper is a tutorial on defining recursive descent parsers in Haskell. In the spirit of one-stop shopping, the paper combines material from three areas into a single source. The three areas are functional parsers (Burge, 1975; Wadler, 1985; Hutton, 1992; Fokker, 1995), the use of monads to structure functional programs (Wadler, 1990, 1992a, 1992b), and the use of special syntax for monadic programs in Haskell (Jones, 1995; Peterson et al., 1996). More specifically, the paper shows how to define monadic parsers using do notation in Haskell.

Of course, recursive descent parsers defined by hand lack the efficiency of bottom-up parsers generated by machine (Aho et al., 1986; Mogensen, 1993; Gill and Marlow, 1995). However, for many research applications, a simple recursive descent parser is perfectly sufficient. Moreover, while parser generators typically offer a fixed set of combinators for describing grammars, the method described here is completely extensible: parsers are first-class values, and we have the full power of Haskell available to define new combinators for special applications. The method is also an excellent illustration of the elegance of functional programming.

© 1998 Cambridge University Press
Supplementary material: Link
Submit a response


No Discussions have been published for this article.