ChristmasTree-0.1: Changing Haskell's Read Implementation Such That by Mainpulating Abstract Syntax Trees it Reads Expressions EfficientlySource codeContentsIndex
Grammar Description
Reading Functions

Alternative approach of read that composes grammars instead of parsers. Grammars describing the data types are composed dynamically, removing possible left-recursion and combining common prefixes of alternatives.

The function gread defined here is able to handle the associativities defined for infix operators.

The function gread reads data in linear time, while the function read has an exponential behavior in some cases of data types with infix operators.

Non uniform data types are not supported, because they generate infinite grammars.

The library is documented in the paper: Haskell, do you read me?: constructing and composing efficient top-down parsers at runtime

Bibtex entry:;filename=GRead.bib

For more documentation see the TTTAS webpage: .

module Text.GRead.Grammar
gread :: Gram a => String -> GReadResult a
type GReadMsg = Message Token (Maybe Token)
data GReadResult a
= Ok a
| Rep a [GReadMsg]
Grammar Description
module Text.GRead.Grammar
Reading Functions
gread :: Gram a => String -> GReadResult aSource

The gread reads input from a string, which must be completely consumed by the input process. Returns Ok value on a successful parse. Otherwise returns Rep value msgs, where the value results of parsing a repaired input. The list msgs contains the "corrections" done to the input.

For example, a read-like implementation can be:

 read :: (Gram a) => String -> a
 read input = case gread input of
                  Ok  a       -> a
                  Rep _ (m:_) -> error $ show m
type GReadMsg = Message Token (Maybe Token)Source
Type of error repair messages.
data GReadResult a Source
Type of gread results.
Ok a
Rep a [GReadMsg]
show/hide Instances
Produced by Haddock version 2.3.0