sparse-0.5: Lightweight parsing library based on partial functions.

Portabilitynon-portable (GNTD, DeriveFunctor, OverloadedStrings)
Stabilityexperimental
Maintainerhans@hanshoglund.se
Safe HaskellNone

Data.Sparse

Contents

Description

Lightweight parsing library based on partial functions.

Synopsis

Sparse

Running

runSparseT :: SparseT a b -> a -> Maybe bSource

runSparseT' :: SparseT a b -> a -> Maybe (a, b)Source

Primitives

headP :: (b -> Bool) -> SparseT [b] bSource

Consumes one input element.

Fails if the predicate fails, or if there is no more input.

splitP :: ([a] -> Int) -> SparseT [a] [a]Source

Consume one or more input elements.

The given function receives the entire remaining input, and must return the number of consumed elements.

Fails if the predicate return 0 or less, or if there is no more input.

Basic parsers

Combinators

optionally :: (Monad f, Alternative f) => a -> f a -> f aSource

optionallyMaybe :: (Monad f, Alternative f) => f a -> f (Maybe a)Source

optional :: (Monad f, Alternative f) => f a -> f ()Source

between :: Monad m => m a -> m a1 -> m b -> m bSource

skipMany1 :: (Monad m, Alternative m) => m a -> m ()Source

skipMany :: (Monad f, Alternative f) => f a -> f ()Source

many1 :: (Monad m, Alternative m) => m a -> m [a]Source

sepBy :: (Monad f, Alternative f) => f a1 -> f a -> f [a1]Source

sepBy1 :: (Monad m, Alternative m) => m a1 -> m a -> m [a1]Source

sepEndBy1 :: (Monad m, Alternative m) => m a1 -> m a -> m [a1]Source

sepEndBy :: (Monad m, Alternative m) => m a1 -> m a -> m [a1]Source

endBy1 :: (Monad m, Alternative m) => m a -> m a1 -> m [a]Source

endBy :: (Monad f, Alternative f) => f a -> f a1 -> f [a]Source

count :: Monad m => Int -> m a -> m [a]Source