papillon-0.1.0.4: packrat parser

Safe HaskellNone
LanguageHaskell98

Text.Papillon.Core

Contents

Synopsis

For Text.Papillon library

class Source sl where Source #

Minimal complete definition

getToken, initialPos, updatePos

Associated Types

type Token sl Source #

data Pos sl Source #

Methods

getToken :: sl -> Maybe (Token sl, sl) Source #

initialPos :: Pos sl Source #

updatePos :: Token sl -> Pos sl -> Pos sl Source #

Instances

Source ByteString Source # 
SourceList c => Source [c] Source # 

Associated Types

type Token [c] :: * Source #

data Pos [c] :: * Source #

Methods

getToken :: [c] -> Maybe (Token [c], [c]) Source #

initialPos :: Pos [c] Source #

updatePos :: Token [c] -> Pos [c] -> Pos [c] Source #

class SourceList c where Source #

Minimal complete definition

listToken, listInitialPos, listUpdatePos

Associated Types

data ListPos c Source #

Methods

listToken :: [c] -> Maybe (c, [c]) Source #

listInitialPos :: ListPos c Source #

listUpdatePos :: c -> ListPos c -> ListPos c Source #

For parse error message

data ParseError pos drv Source #

Instances

Error (ParseError pos drv) Source # 

Methods

noMsg :: ParseError pos drv #

strMsg :: String -> ParseError pos drv #

mkParseError :: forall pos drv. String -> String -> String -> drv -> [String] -> pos -> ParseError pos drv Source #

peDerivs :: ParseError pos drv -> drv Source #

pePosition :: ParseError pos drv -> pos Source #

pePositionS :: forall drv. ParseError (Pos String) drv -> (Int, Int) Source #

For papillon command

(<*>) :: Applicative f => forall a b. f (a -> b) -> f a -> f b #

Sequential application.

(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #

An infix synonym for fmap.

The name of this operator is an allusion to $. Note the similarities between their types:

 ($)  ::              (a -> b) ->   a ->   b
(<$>) :: Functor f => (a -> b) -> f a -> f b

Whereas $ is function application, <$> is function application lifted over a Functor.

Examples

Convert from a Maybe Int to a Maybe String using show:

>>> show <$> Nothing
Nothing
>>> show <$> Just 3
Just "3"

Convert from an Either Int Int to an Either Int String using show:

>>> show <$> Left 17
Left 17
>>> show <$> Right 17
Right "17"

Double each element of a list:

>>> (*2) <$> [1,2,3]
[2,4,6]

Apply even to the second element of a pair:

>>> even <$> (2,2)
(2,True)

runError :: forall err a. ErrorT err Identity a -> Either err a Source #