papillon-0.1.1.0: packrat parser

Safe HaskellNone
LanguageHaskell98

Text.Papillon.Core

Contents

Synopsis

For Text.Papillon library

class Source sl where Source #

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 # 
Instance details

Defined in Text.Papillon.Papillon

Associated Types

type Token ByteString :: Type Source #

data Pos ByteString :: Type Source #

SourceList c => Source [c] Source # 
Instance details

Defined in Text.Papillon.Papillon

Associated Types

type Token [c] :: Type Source #

data Pos [c] :: Type 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 #

Associated Types

data ListPos c Source #

Methods

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

listInitialPos :: ListPos c Source #

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

Instances
SourceList Char Source # 
Instance details

Defined in Text.Papillon.Papillon

Associated Types

data ListPos Char :: Type Source #

For parse error message

data ParseError pos drv Source #

Instances
Error (ParseError pos drv) Source # 
Instance details

Defined in Text.Papillon.Papillon

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

data PPragma Source #

Instances
Show PPragma Source # 
Instance details

Defined in Text.Papillon.Parser

(<*>) :: Applicative f => f (a -> b) -> f a -> f b infixl 4 #

Sequential application.

A few functors support an implementation of <*> that is more efficient than the default one.

(<$>) :: 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

Expand

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 #