sexp-grammar-2.1.0: Invertible grammar combinators for S-expressions

Safe HaskellNone
LanguageHaskell2010

Language.SexpGrammar.Generic

Contents

Synopsis

GHC.Generics helpers

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

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 p s bs a t -> Grammar p s (a :- t) #

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

data Coproduct p s (bs :: [Type]) a t where #

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 :: forall p s (bs :: [Type]) a t b (bs1 :: [Type]). (Grammar p b (a :- t) -> Grammar p s (a :- t)) -> Coproduct p s bs1 a t -> Coproduct p s (b ': bs1) a t 
End :: forall p s (bs :: [Type]) a t. Coproduct p s ([] :: [Type]) a t