|
|
|
# Replacing the Read Class
|
|
|
|
|
|
|
|
## Problems with the Haskell 98 class
|
|
|
|
|
|
|
|
- the backtracking parser is very inefficient
|
|
|
|
|
|
|
|
- writing instances is painful, compared to a monadic interface
|
|
|
|
|
|
|
|
- on failure, parsers give no indication of what went wrong
|
|
|
|
|
|
|
|
## Proposed replacements
|
|
|
|
|
|
|
|
- parsers based on [ ReadP](http://www.haskell.org/ghc/docs/latest/html/libraries/base/Text-ParserCombinators-ReadP.html), from [ Parallel Parsing Processes](http://www.md.chalmers.se/~koen/Papers/parsing-pearl.ps) by Koen Classen, JFP 2004.
|
|
|
|
|
|
|
|
- monadic interface
|
|
|
|
- supports nondeterminism without needing explicit committed choice
|
|
|
|
- mostly deterministic parsers are much more efficient than `ReadS`
|
|
|
|
- no error reporting
|
|
|
|
- requires [PolymorphicComponents](polymorphic-components)
|
|
|
|
|
|
|
|
GHC has used a new `Read` class based on these parsers since 5.04 (July 2002).
|
|
|
|
|
|
|
|
- Malcolm's experimental Poly parser in the CVS version of HaXml?.
|
|
|
|
|
|
|
|
- monadic interface
|
|
|
|
- deterministic parser with committed choice
|
|
|
|
- returns an error string on failure |