mini-0.1.0.0: Minimal essentials
Safe HaskellSafe-Inferred
LanguageHaskell2010

Mini.Transformers.ParserT

Description

Turning strings into things

Synopsis

Types

data ParserT s m a Source #

A monad for parsing symbols of type s with inner monad m and return type a

Instances

Instances details
MonadTrans (ParserT s) Source # 
Instance details

Defined in Mini.Transformers.ParserT

Methods

lift :: Monad m => m a -> ParserT s m a Source #

(Monad m, Eq s) => Alternative (ParserT s m) Source # 
Instance details

Defined in Mini.Transformers.ParserT

Methods

empty :: ParserT s m a #

(<|>) :: ParserT s m a -> ParserT s m a -> ParserT s m a #

some :: ParserT s m a -> ParserT s m [a] #

many :: ParserT s m a -> ParserT s m [a] #

Monad m => Applicative (ParserT s m) Source # 
Instance details

Defined in Mini.Transformers.ParserT

Methods

pure :: a -> ParserT s m a #

(<*>) :: ParserT s m (a -> b) -> ParserT s m a -> ParserT s m b #

liftA2 :: (a -> b -> c) -> ParserT s m a -> ParserT s m b -> ParserT s m c #

(*>) :: ParserT s m a -> ParserT s m b -> ParserT s m b #

(<*) :: ParserT s m a -> ParserT s m b -> ParserT s m a #

Monad m => Functor (ParserT s m) Source # 
Instance details

Defined in Mini.Transformers.ParserT

Methods

fmap :: (a -> b) -> ParserT s m a -> ParserT s m b #

(<$) :: a -> ParserT s m b -> ParserT s m a #

Monad m => Monad (ParserT s m) Source # 
Instance details

Defined in Mini.Transformers.ParserT

Methods

(>>=) :: ParserT s m a -> (a -> ParserT s m b) -> ParserT s m b #

(>>) :: ParserT s m a -> ParserT s m b -> ParserT s m b #

return :: a -> ParserT s m a #

data ParseError s Source #

Abstract representation of a parse error for symbols of type s

Instances

Instances details
Show s => Show (ParseError s) Source # 
Instance details

Defined in Mini.Transformers.ParserT

Runners

runParserT :: ParserT s m a -> [s] -> m (Either [ParseError s] (a, [s])) Source #

Unwrap a ParserT given a string of symbols

Parsers

sat :: Applicative m => (s -> Bool) -> ParserT s m s Source #

From a predicate to a parser for symbols satisfying the predicate

digit = sat Data.Char.isDigit

spaces = Control.Applicative.many $ sat Data.Char.isSpace

item :: Applicative m => ParserT s m s Source #

A parser for any symbol

symbol :: (Applicative m, Eq s) => s -> ParserT s m s Source #

A parser for the given symbol

string :: (Monad m, Traversable t, Eq s) => t s -> ParserT s m (t s) Source #

A parser for the given string of symbols

oneOf :: (Applicative m, Foldable t, Eq s) => t s -> ParserT s m s Source #

A parser for any of the given symbols

noneOf :: (Applicative m, Foldable t, Eq s) => t s -> ParserT s m s Source #

A parser for any symbol excluding the given symbols

Combinators

sepBy :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] Source #

Turn a parser and another parser into a parser for zero or more of the former separated by the latter

sepBy1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] Source #

Turn a parser and another parser into a parser for one or more of the former separated by the latter

endBy :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] Source #

Turn a parser and another parser into a parser for zero or more of the former separated and ended by the latter

endBy1 :: (Monad m, Eq s) => ParserT s m a -> ParserT s m b -> ParserT s m [a] Source #

Turn a parser and another parser into a parser for one or more of the former separated and ended by the latter

between :: Monad m => ParserT s m open -> ParserT s m close -> ParserT s m a -> ParserT s m a Source #

Turn a first, second and third parser into a parser for the third enclosed between the first and the second, returning the result of the third

option :: (Monad m, Eq s) => a -> ParserT s m a -> ParserT s m a Source #

From a default value and a parser to the parser returning the default value in case of failure