syntax-1.0.0.0: Reversible parsing and pretty-printing.

Copyright(c) Daan Leijen 1999-2001, Bryan O'Sullivan 2007-2014, Paweł Nowak 2014
LicenseMIT
MaintainerPaweł Nowak <pawel834@gmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Syntax.Combinator

Contents

Description

Combinators that work with any sequence type.

Synopsis

Combinators.

optional :: SIArrow cat => cat () a -> cat () (Maybe a) Source

One or zero occurences of f.

opt :: SIArrow cat => cat () () -> cat () () Source

Like optional, but specialized for ().

opt_ :: SIArrow cat => cat () () -> cat () () Source

Parser one or zero occurences of f, but prints nothing.

choice :: SIArrow cat => [cat () a] -> cat () a Source

Tries to apply the actions in the list in order, until one of them succeeds. Returns the value of the succeeding action.

eitherOf :: SIArrow cat => cat () a -> cat () b -> cat () (Either a b) Source

Combine two alternatives.

Lists.

manyTill :: SIArrow cat => cat () a -> cat () () -> cat () [a] Source

manyTill p end applies action p zero or more times until action end succeeds, and returns the list of values returned by p.

sepBy :: SIArrow cat => cat () a -> cat () () -> cat () [a] Source

Zero or more occurences of v separated by s.

sepBy1 :: SIArrow cat => cat () a -> cat () () -> cat () [a] Source

One or more occurences of v separated by s.

Arrowized combinators.

takeArr :: Syntax syn => syn Int (Seq syn) Source

A string of given length.

Vectors.

vecNSepBy :: Syntax syn => Int -> syn () a -> syn () () -> syn () (Vector a) Source

Constant size vector with separators.

vecNSepBy n e sep describes a size n vector with elements e separated by sep.

ivecNSepBy :: Syntax syn => Int -> syn Int (Int, a) -> syn () () -> syn () (Vector a) Source

Constant size vector with separators and index-aware elements.

ivecNSepBy n e sep describes a size n vector with elements e separated by sep. Each element gets its index and should output a value and the index unchanged.

vec :: Syntax syn => syn () a -> syn Int (Vector a) Source

Runtime sized vector. The size can depend on the result of some computation.

vec e describes a vector with elements e.

vecSepBy :: Syntax syn => syn () a -> syn () () -> syn Int (Vector a) Source

Runtime sized vector with separators. The size can depend on the result of some computation.

vecSepBy e sep describes a vector with elements e separated by sep.

ivec :: Syntax syn => syn Int (Int, a) -> syn Int (Vector a) Source

Runtime sized vector with index-aware elements. The size can depend on the result of some computation.

ivec e describes a vector with elements e.

ivecSepBy :: Syntax syn => syn Int (Int, a) -> syn () () -> syn Int (Vector a) Source

Runtime sized vector with index-aware elements and separators. The size can depend on the result of some computation.

ivecSepBy e sep describes a vector with elements e separated by sep.

Unboxed vectors.

uvecNSepBy :: (Syntax syn, Unbox a) => Int -> syn () a -> syn () () -> syn () (Vector a) Source

Constant size unboxed vector with separators.

uvecNSepBy n e sep describes a size n vector with elements e separated by sep.

uivecNSepBy :: (Syntax syn, Unbox a) => Int -> syn Int (Int, a) -> syn () () -> syn () (Vector a) Source

Constant size unboxed vector with separators and index-aware elements.

uivecNSepBy n e sep describes a size n vector with elements e separated by sep. Each element gets its index and should output a value and the index unchanged.

uvec :: (Syntax syn, Unbox a) => syn () a -> syn Int (Vector a) Source

Runtime sized unboxed vector. The size can depend on the result of some computation.

uvec e describes a vector with elements e.

uvecSepBy :: (Syntax syn, Unbox a) => syn () a -> syn () () -> syn Int (Vector a) Source

Runtime sized unboxed vector with separators. The size can depend on the result of some computation.

uvecSepBy e sep describes a vector with elements e separated by sep.

uivec :: (Syntax syn, Unbox a) => syn Int (Int, a) -> syn Int (Vector a) Source

Runtime sized unboxed vector with index-aware elements. The size can depend on the result of some computation.

uivec e describes a vector with elements e.

uivecSepBy :: (Syntax syn, Unbox a) => syn Int (Int, a) -> syn () () -> syn Int (Vector a) Source

Runtime sized unboxed vector with index-aware elements and separators. The size can depend on the result of some computation.

uivecSepBy e sep describes a vector with elements e separated by sep.