Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Extend a monad with the ability to parse symbol sequences
Synopsis
- newtype ParserT s m a = ParserT ([s] -> m (Either ParseError (a, [s])))
- newtype ParseError = ParseError {
- unexpected :: String
- runParserT :: ParserT s m a -> [s] -> m (Either ParseError (a, [s]))
- sat :: (Applicative m, Show s) => (s -> Bool) -> ParserT s m s
- item :: (Applicative m, Show s) => ParserT s m s
- symbol :: (Applicative m, Show s, Eq s) => s -> ParserT s m s
- string :: (Monad m, Traversable t, Show s, Eq s) => t s -> ParserT s m (t s)
- oneOf :: (Applicative m, Foldable t, Show s, Eq s) => t s -> ParserT s m s
- noneOf :: (Applicative m, Foldable t, Show s, Eq s) => t s -> ParserT s m s
- eof :: (Monad m, Show s) => ParserT s m ()
- peek :: (Monad m, Show s) => ParserT s m s
- sepBy :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a]
- sepBy1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a]
- till :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a]
- chainl1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m (a -> a -> a) -> ParserT s m a
- chainr1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m (a -> a -> a) -> ParserT s m a
- between :: Monad m => ParserT s m open -> ParserT s m close -> ParserT s m a -> ParserT s m a
- option :: (Monad m, Eq s) => a -> ParserT s m a -> ParserT s m a
- reject :: (Monad m, Show a) => ParserT s m a -> ParserT s m ()
- accept :: Monad m => ParserT s m a -> ParserT s m a
Types
newtype ParserT s m a Source #
A transformer parsing symbols s, inner monad m, return a
ParserT ([s] -> m (Either ParseError (a, [s]))) |
Instances
MonadTrans (ParserT s) Source # | |
Monad m => MonadFail (ParserT s m) Source # | |
Defined in Mini.Transformers.ParserT | |
(Monad m, Eq s) => Alternative (ParserT s m) Source # | Parse |
Monad m => Applicative (ParserT s m) Source # | |
Defined in Mini.Transformers.ParserT | |
Monad m => Functor (ParserT s m) Source # | |
Monad m => Monad (ParserT s m) Source # | |
(Monad m, Monoid a) => Monoid (ParserT s m a) Source # | |
(Monad m, Semigroup a) => Semigroup (ParserT s m a) Source # | Combine the results of |
newtype ParseError Source #
A parse error
Instances
Show ParseError Source # | |
Defined in Mini.Transformers.ParserT showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS # |
Runner
runParserT :: ParserT s m a -> [s] -> m (Either ParseError (a, [s])) Source #
Unwrap a ParserT
computation with a sequence of symbols to parse
Parsers
sat :: (Applicative m, Show s) => (s -> Bool) -> ParserT s m s Source #
Parse symbols satisfying a predicate
string :: (Monad m, Traversable t, Show s, Eq s) => t s -> ParserT s m (t s) Source #
Parse a sequence of symbols
oneOf :: (Applicative m, Foldable t, Show s, Eq s) => t s -> ParserT s m s Source #
Parse symbols included in a collection
noneOf :: (Applicative m, Foldable t, Show s, Eq s) => t s -> ParserT s m s Source #
Parse symbols excluded from a collection
Combinators
sepBy :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] Source #
Parse zero or more p
separated by q
via p `sepBy` q
sepBy1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] Source #
Parse one or more p
separated by q
via p `sepBy1` q
till :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] Source #
Parse zero or more p
until q
succeeds via p `till` q
chainl1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m (a -> a -> a) -> ParserT s m a Source #
Parse one or more p
left-associatively chained by f
via chainl1 p f
chainr1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m (a -> a -> a) -> ParserT s m a Source #
Parse one or more p
right-associatively chained by f
via chainr1 p f
between :: Monad m => ParserT s m open -> ParserT s m close -> ParserT s m a -> ParserT s m a Source #
Parse p
enclosed by a
and b
via between a b p
option :: (Monad m, Eq s) => a -> ParserT s m a -> ParserT s m a Source #
Parse p
returning a
in case of failure via option a p