sexp-grammar-1.3.0: Invertible parsers for S-expressions

Safe HaskellSafe
LanguageHaskell2010

Language.SexpGrammar.Generic

Contents

Synopsis

GHC.Generics helpers

with :: forall a b s t g c d f. (Generic a, MkPrismList (Rep a), MkStackPrism f, Rep a ~ M1 D d (M1 C c f), StackPrismLhs f t ~ b, Constructor c) => (Grammar g b (a :- t) -> Grammar g s (a :- t)) -> Grammar g s (a :- t) Source #

Provide a data constructor/stack isomorphism to a grammar working on stacks. Works for types with one data constructor. For sum types use match and Coproduct.

match :: (Generic a, MkPrismList (Rep a), Match (Rep a) bs t, bs ~ Coll (Rep a) t) => Coproduct g s bs a t -> Grammar g s (a :- t) Source #

Combine all grammars provided in Coproduct list into a single grammar.

data Coproduct g s bs a t where Source #

Heterogenous list of grammars, each one matches a data constructor of type a. With is used to provide a data constructor/stack isomorphism to a grammar working on stacks. End ends the list of matches.

Constructors

With :: (Grammar g b (a :- t) -> Grammar g s (a :- t)) -> Coproduct g s bs a t -> Coproduct g s (b ': bs) a t 
End :: Coproduct g s '[] a t