Control.Monad.Combinators.NonEmpty

parser-combinators-1.3.0: Lightweight package providing commonly useful parser combinators

Copyright | © 2017–present Mark Karpov
License | BSD 3 clause
Maintainer | Mark Karpov <markkarpov92@gmail.com>
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Control.Monad.Combinators.NonEmpty

Description

The module provides `NonEmpty` list variants of some of the functions from Control.Monad.Combinators.

Since: 0.4.0

Synopsis

- some :: MonadPlus m => m a -> m (NonEmpty a)
- endBy1 :: MonadPlus m => m a -> m sep -> m (NonEmpty a)
- someTill :: MonadPlus m => m a -> m end -> m (NonEmpty a)
- sepBy1 :: MonadPlus m => m a -> m sep -> m (NonEmpty a)
- sepEndBy1 :: MonadPlus m => m a -> m sep -> m (NonEmpty a)

# Documentation

some :: MonadPlus m => m a -> m (NonEmpty a) #

``some` p` applies the parser `p` one or more times and returns a list of the values returned by `p`.

    word = some letter

endBy1 :: MonadPlus m => m a -> m sep -> m (NonEmpty a) #

``endBy1` p sep` parses one or more occurrences of `p`, separated and ended by `sep`. Returns a non-empty list of values returned by `p`.

someTill :: MonadPlus m => m a -> m end -> m (NonEmpty a) #

``someTill` p end` works similarly to ``manyTill` p end`, but `p` should succeed at least once.

See also: `skipSome`, `skipSomeTill`.

sepBy1 :: MonadPlus m => m a -> m sep -> m (NonEmpty a) #

``sepBy1` p sep` parses one or more occurrences of `p`, separated by `sep`. Returns a non-empty list of values returned by `p`.

sepEndBy1 :: MonadPlus m => m a -> m sep -> m (NonEmpty a) #

``sepEndBy1` p sep` parses one or more occurrences of `p`, separated and optionally ended by `sep`. Returns a non-empty list of values returned by `p`.