haskus-system-0.6.0.0: Haskus system programming framework

Safe HaskellNone
LanguageHaskell2010

Haskus.Utils.Parser

Description

Tools to write parsers using Flows

Synopsis

Documentation

data Choice a Source #

Constructors

Choice 

Instances

((~) * x (Flow m xs), (~) * y (Flow m ys), (~) * z (Flow m zs), Catchable 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 # 

Methods

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

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, MaybeCatchable ParseError xs) => Maybe Word -> Maybe Word -> Flow m xs -> Flow m '[[Variant 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, Catchable ParseError xs) => Word -> Flow m xs -> Flow m '[[Variant 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, Catchable ParseError xs) => Word -> Flow m xs -> m [Variant 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, Catchable 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, Catchable ParseError xs) => Flow m xs -> Flow m '[[Variant zs]] Source #

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

manyAtLeast :: (zs ~ Filter ParseError xs, Monad m, Catchable ParseError xs) => Word -> Flow m xs -> Flow m '[[Variant 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, MaybeCatchable ParseError xs, Catchable ParseError ys) => Flow m xs -> Flow m ys -> Flow m '[([Variant zs], Variant 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, MaybeCatchable ParseError xs, Catchable ParseError ys) => Flow m xs -> Flow m ys -> Flow m '[[Variant 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