sexp-grammar-2.3.0: Invertible grammar combinators for S-expressions
Safe HaskellSafe
LanguageHaskell2010

Language.SexpGrammar.Generic

Synopsis

GHC.Generics helpers

with :: forall a b s t (c :: Meta) (d :: Meta) (f :: Type -> Type) p. (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 :: forall a (bs :: [Type]) t p s. (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 b a t s (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 a t. Coproduct p s ('[] :: [Type]) a t