haskus-utils-1.1: Haskus utility modules

Safe HaskellNone
LanguageHaskell2010

Haskus.Utils.Parser

Description

Tools to write parsers using Flows

Synopsis

Documentation

data ParseError Source #

Parser error

Constructors

SyntaxError 
EndOfInput 
Instances
Eq ParseError Source # 
Instance details

Defined in Haskus.Utils.Parser

Show ParseError Source # 
Instance details

Defined in Haskus.Utils.Parser

data Choice a Source #

Constructors

Choice 
Instances
(x ~ Flow m xs, y ~ Flow m ys, z ~ Flow m zs, a :< xs, Liftable ys zs, Liftable (Filter a xs) zs, zs ~ Union (Filter a xs) ys, Monad m) => Apply (Choice a) (x, y) z Source # 
Instance details

Defined in Haskus.Utils.Parser

Methods

apply :: Choice a -> (x, y) -> z #

choice :: forall m fs zs. (Monad m, HFoldl (Choice ParseError) (Flow m '[ParseError]) fs (Flow m zs)) => HList fs -> Flow m zs Source #

Try to apply the actions in the list in order, until one of them succeeds. Returns the value of the succeeding action, or the value of the last one. Failures are detected with values of type ParseError.

choice' :: forall a m fs zs. (Monad m, HFoldl (Choice a) (Flow m '[a]) fs (Flow m zs)) => HList fs -> Flow m zs Source #

Try to apply the actions in the list in order, until one of them succeeds. Returns the value of the succeeding action, or the value of the last one. Failures are detected with values of type "a".

manyBounded :: forall zs xs m. (zs ~ Filter ParseError xs, Monad m, ParseError :<? xs) => Maybe Word -> Maybe Word -> Flow m xs -> Flow m '[[V zs], ParseError] Source #

Apply the given action at least min times and at most max time

On failure, fails.

manyAtMost :: (zs ~ Filter ParseError xs, Monad m, ParseError :< xs) => Word -> Flow m xs -> Flow m '[[V zs]] Source #

Apply the action zero or more times (up to max) until a ParseError result is returned

manyAtMost' :: (zs ~ Filter ParseError xs, Monad m, ParseError :< xs) => Word -> Flow m xs -> m [V zs] Source #

Apply the action zero or more times (up to max) until a ParseError result is returned

manyAtMost'' :: ('[x] ~ Filter ParseError xs, Monad m, ParseError :< xs) => Word -> Flow m xs -> m [x] Source #

Apply the action zero or more times (up to max) until a ParseError result is returned

many :: (zs ~ Filter ParseError xs, Monad m, ParseError :< xs) => Flow m xs -> Flow m '[[V zs]] Source #

Apply the action zero or more times (until a ParseError result is returned)

manyAtLeast :: (zs ~ Filter ParseError xs, Monad m, ParseError :< xs) => Word -> Flow m xs -> Flow m '[[V zs], ParseError] Source #

Apply the action at least n times or more times (until a ParseError result is returned)

manyTill :: (zs ~ Filter ParseError xs, zs' ~ Filter ParseError ys, Monad m, ParseError :<? xs, ParseError :< ys) => Flow m xs -> Flow m ys -> Flow m '[([V zs], V zs'), ParseError] Source #

Apply the first action zero or more times until the second succeeds. If the first action fails, the whole operation fails.

Return both the list of first values and the ending value

manyTill' :: (zs ~ Filter ParseError xs, Monad m, ParseError :<? xs, ParseError :< ys) => Flow m xs -> Flow m ys -> Flow m '[[V zs], ParseError] Source #

Apply the first action zero or more times until the second succeeds. If the first action fails, the whole operation fails.

Return only the list of first values