distributors-0.6.0.0: Unifying Parsers, Printers & Grammars
Copyright(C) 2026 - Eitan Chatav
LicenseBSD-style (see the file LICENSE)
MaintainerEitan Chatav <eitan.chatav@gmail.com>
Stabilityprovisional
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Profunctor.Grammar.Parsector

Contents

Description

Synopsis

Parsector

newtype Parsector s a b Source #

Parsector is an invertible LL(1) parser which is intended to provide detailed failure information, based on Parsec.

Constructors

Parsector 

Fields

Instances

Instances details
Category (Parsector s :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

id :: Parsector s a a #

(.) :: Parsector s b c -> Parsector s a b -> Parsector s a c #

(Categorized token, Item s ~ token, Cons s s token token, Snoc s s token token) => TokenAlgebra token (Parsector s token token) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

tokenClass :: TokenClass token -> Parsector s token token Source #

(Categorized token, Item s ~ token, Cons s s token token, Snoc s s token token) => TerminalSymbol token (Parsector s () ()) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

terminal :: [token] -> Parsector s () () Source #

(Categorized token, Item s ~ token, Cons s s token token, Snoc s s token token) => Tokenized token (Parsector s token token) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

anyToken :: Parsector s token token Source #

token :: token -> Parsector s token token Source #

oneOf :: Foldable f => f token -> Parsector s token token Source #

notOneOf :: Foldable f => f token -> Parsector s token token Source #

asIn :: Categorize token -> Parsector s token token Source #

notAsIn :: Categorize token -> Parsector s token token Source #

Categorized (Item s) => Arrow (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

arr :: (b -> c) -> Parsector s b c #

first :: Parsector s b c -> Parsector s (b, d) (c, d) #

second :: Parsector s b c -> Parsector s (d, b) (d, c) #

(***) :: Parsector s b c -> Parsector s b' c' -> Parsector s (b, b') (c, c') #

(&&&) :: Parsector s b c -> Parsector s b c' -> Parsector s b (c, c') #

Categorized (Item s) => ArrowChoice (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

left :: Parsector s b c -> Parsector s (Either b d) (Either c d) #

right :: Parsector s b c -> Parsector s (Either d b) (Either d c) #

(+++) :: Parsector s b c -> Parsector s b' c' -> Parsector s (Either b b') (Either c c') #

(|||) :: Parsector s b d -> Parsector s c d -> Parsector s (Either b c) d #

Categorized (Item s) => ArrowPlus (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

(<+>) :: Parsector s b c -> Parsector s b c -> Parsector s b c #

Categorized (Item s) => ArrowZero (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

zeroArrow :: Parsector s b c #

Categorized (Item s) => Alternator (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

alternate :: Either (Parsector s a b) (Parsector s c d) -> Parsector s (Either a c) (Either b d) Source #

someP :: Parsector s a b -> Parsector s [a] [b] Source #

optionP :: APrism a b () () -> Parsector s a b -> Parsector s a b Source #

Categorized (Item s) => Distributor (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

zeroP :: Parsector s Void Void Source #

(>+<) :: Parsector s a b -> Parsector s c d -> Parsector s (Either a c) (Either b d) Source #

optionalP :: Parsector s a b -> Parsector s (Maybe a) (Maybe b) Source #

manyP :: Parsector s a b -> Parsector s [a] [b] Source #

Categorized (Item s) => Filtrator (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

filtrate :: Parsector s (Either a c) (Either b d) -> (Parsector s a b, Parsector s c d) Source #

Categorized (Item s) => Choice (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

left' :: Parsector s a b -> Parsector s (Either a c) (Either b c) #

right' :: Parsector s a b -> Parsector s (Either c a) (Either c b) #

Categorized (Item s) => Cochoice (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

unleft :: Parsector s (Either a d) (Either b d) -> Parsector s a b #

unright :: Parsector s (Either d a) (Either d b) -> Parsector s a b #

Strong (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

first' :: Parsector s a b -> Parsector s (a, c) (b, c) #

second' :: Parsector s a b -> Parsector s (c, a) (c, b) #

Profunctor (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

dimap :: (a -> b) -> (c -> d) -> Parsector s b c -> Parsector s a d #

lmap :: (a -> b) -> Parsector s b c -> Parsector s a c #

rmap :: (b -> c) -> Parsector s a b -> Parsector s a c #

(#.) :: forall a b c q. Coercible c b => q b c -> Parsector s a b -> Parsector s a c #

(.#) :: forall a b c q. Coercible b a => Parsector s b c -> q a b -> Parsector s a c #

Categorized (Item s) => MonadFail (Parsector s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

fail :: String -> Parsector s a a0 #

Categorized (Item s) => Alternative (Parsector s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

empty :: Parsector s a a0 #

(<|>) :: Parsector s a a0 -> Parsector s a a0 -> Parsector s a a0 #

some :: Parsector s a a0 -> Parsector s a [a0] #

many :: Parsector s a a0 -> Parsector s a [a0] #

Categorized (Item s) => Applicative (Parsector s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

pure :: a0 -> Parsector s a a0 #

(<*>) :: Parsector s a (a0 -> b) -> Parsector s a a0 -> Parsector s a b #

liftA2 :: (a0 -> b -> c) -> Parsector s a a0 -> Parsector s a b -> Parsector s a c #

(*>) :: Parsector s a a0 -> Parsector s a b -> Parsector s a b #

(<*) :: Parsector s a a0 -> Parsector s a b -> Parsector s a a0 #

Functor (Parsector s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

fmap :: (a0 -> b) -> Parsector s a a0 -> Parsector s a b #

(<$) :: a0 -> Parsector s a b -> Parsector s a a0 #

Categorized (Item s) => Monad (Parsector s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

(>>=) :: Parsector s a a0 -> (a0 -> Parsector s a b) -> Parsector s a b #

(>>) :: Parsector s a a0 -> Parsector s a b -> Parsector s a b #

return :: a0 -> Parsector s a a0 #

Categorized (Item s) => MonadPlus (Parsector s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

mzero :: Parsector s a a0 #

mplus :: Parsector s a a0 -> Parsector s a a0 -> Parsector s a a0 #

Categorized (Item s) => MonadTry (Parsector s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

try :: Parsector s a a0 -> Parsector s a a0 Source #

Categorized (Item s) => Filterable (Parsector s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

mapMaybe :: (a0 -> Maybe b) -> Parsector s a a0 -> Parsector s a b #

catMaybes :: Parsector s a (Maybe a0) -> Parsector s a a0 #

filter :: (a0 -> Bool) -> Parsector s a a0 -> Parsector s a a0 #

drain :: Parsector s a a0 -> Parsector s a b #

BackusNaurForm (Parsector s a b) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

rule :: String -> Parsector s a b -> Parsector s a b Source #

ruleRec :: String -> (Parsector s a b -> Parsector s a b) -> Parsector s a b Source #

parsecP Source #

Arguments

:: Categorized (Item s) 
=> Parsector s a b 
-> s

input stream

-> ParsecState s b 

Run Parsector as a parser: consume tokens from s, left to right, returning a ParsecState whose parsecResult is Nothing on failure and Just the output syntax value on success.

unparsecP Source #

Arguments

:: Categorized (Item s) 
=> Parsector s a b 
-> a

input syntax

-> s

input stream

-> ParsecState s b 

Run Parsector as a printer: given a syntax value a and an input stream, append tokens to s left to right, returning a ParsecState whose parsecResult is Nothing on failure or Just a successful output syntax value, in which case, parsecStream is the output stream.

data ParsecState s a Source #

ParsecState is both the input and output type of the underlying function inside Parsector. Parsector s a b is equivalent to

ParsecState s a -> ParsecState s b

So ParsecState has a dual interpretation as input and output.

Constructors

ParsecState 

Fields

Instances

Instances details
Foldable (ParsecState s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

fold :: Monoid m => ParsecState s m -> m #

foldMap :: Monoid m => (a -> m) -> ParsecState s a -> m #

foldMap' :: Monoid m => (a -> m) -> ParsecState s a -> m #

foldr :: (a -> b -> b) -> b -> ParsecState s a -> b #

foldr' :: (a -> b -> b) -> b -> ParsecState s a -> b #

foldl :: (b -> a -> b) -> b -> ParsecState s a -> b #

foldl' :: (b -> a -> b) -> b -> ParsecState s a -> b #

foldr1 :: (a -> a -> a) -> ParsecState s a -> a #

foldl1 :: (a -> a -> a) -> ParsecState s a -> a #

toList :: ParsecState s a -> [a] #

null :: ParsecState s a -> Bool #

length :: ParsecState s a -> Int #

elem :: Eq a => a -> ParsecState s a -> Bool #

maximum :: Ord a => ParsecState s a -> a #

minimum :: Ord a => ParsecState s a -> a #

sum :: Num a => ParsecState s a -> a #

product :: Num a => ParsecState s a -> a #

Traversable (ParsecState s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

traverse :: Applicative f => (a -> f b) -> ParsecState s a -> f (ParsecState s b) #

sequenceA :: Applicative f => ParsecState s (f a) -> f (ParsecState s a) #

mapM :: Monad m => (a -> m b) -> ParsecState s a -> m (ParsecState s b) #

sequence :: Monad m => ParsecState s (m a) -> m (ParsecState s a) #

Functor (ParsecState s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

fmap :: (a -> b) -> ParsecState s a -> ParsecState s b #

(<$) :: a -> ParsecState s b -> ParsecState s a #

(Categorized (Item s), Read (Item s), Read (Categorize (Item s)), Read a, Read s) => Read (ParsecState s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

(Categorized (Item s), Show (Item s), Show (Categorize (Item s)), Show a, Show s) => Show (ParsecState s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

showsPrec :: Int -> ParsecState s a -> ShowS #

show :: ParsecState s a -> String #

showList :: [ParsecState s a] -> ShowS #

(Categorized (Item s), Eq a, Eq s) => Eq (ParsecState s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

(==) :: ParsecState s a -> ParsecState s a -> Bool #

(/=) :: ParsecState s a -> ParsecState s a -> Bool #

(Categorized (Item s), Ord a, Ord s) => Ord (ParsecState s a) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

compare :: ParsecState s a -> ParsecState s a -> Ordering #

(<) :: ParsecState s a -> ParsecState s a -> Bool #

(<=) :: ParsecState s a -> ParsecState s a -> Bool #

(>) :: ParsecState s a -> ParsecState s a -> Bool #

(>=) :: ParsecState s a -> ParsecState s a -> Bool #

max :: ParsecState s a -> ParsecState s a -> ParsecState s a #

min :: ParsecState s a -> ParsecState s a -> ParsecState s a #

data ParsecFailure s Source #

ParsecFailure is the failure payload produced by Parsector, stored in parsecFailure. ParsecFailure is a Monoid and Parsector merges failures/hints when control flow reaches the same offset without commitment.

Constructors

ParsecFailure 

Fields

Instances

Instances details
Categorized (Item s) => Monoid (ParsecFailure s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Categorized (Item s) => Semigroup (ParsecFailure s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

(Categorized (Item s), Read (Item s), Read (Categorize (Item s))) => Read (ParsecFailure s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

(Categorized (Item s), Show (Item s), Show (Categorize (Item s))) => Show (ParsecFailure s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Categorized (Item s) => Eq (ParsecFailure s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Categorized (Item s) => Ord (ParsecFailure s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector