Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class Typeable alg => FAlgebra alg where
- type AST alg t a = Free (Sig alg) t a
- runAST :: forall alg t a. (FAlgebra alg, alg a) => Free (Sig alg) t a -> AppTags t a
- type Tag = Type
- type family AppTag (t :: Tag) (a :: Type)
- type family AppTags (t :: [Tag]) (a :: Type) :: Type where ...
- type family ConsTag (t :: Tag) (ts :: [Tag]) :: [Tag]
- data Free f t a where
- type family FreeConstraints (t :: [Tag]) (a :: Type) :: Constraint
- class MkFree s t a where
- class (FAlgebra alg1, FAlgebra alg2) => View alg1 t1 alg2 t2 where
- data Var
- var1 :: AppTags t Var ~ Var => AST alg t Var
- var2 :: AppTags t Var ~ Var => AST alg t Var
- var3 :: AppTags t Var ~ Var => AST alg t Var
- mkFAlgebra :: Name -> Q [Dec]
- mkTag :: Name -> Q [Dec]
- mkTagFromCxt :: Cxt -> Name -> Q [Dec]
- unsafeExtractSigTag0 :: View alg1 '[] alg2 t => Sig alg2 t (Free (Sig alg2) t a) -> Sig alg1 '[] (Free (Sig alg2) t a)
- unsafeExtractSigTag :: View alg1 '[s] alg2 (s ': t) => Sig alg2 (s ': t) (Free (Sig alg2) t a) -> Sig alg1 '[s] (Free (Sig alg2) t a)
- unsafeCoerceSigTag :: proxy t' -> Sig alg t a -> Sig alg t' a
- runSig1Snoc :: forall proxy alg a s ttt t u. (FAlgebra alg, alg (AppTag u a)) => Proxy (u :: Tag) -> Proxy (s :: Tag) -> Proxy (t :: [Tag]) -> Proxy a -> Sig alg ttt (AppTags t a) -> AppTag s (AppTags t a)
- runSig0Snoc :: forall proxy alg a t u. (FAlgebra alg, alg (AppTag u a)) => Proxy u -> Proxy a -> Sig alg t (AppTags (t `Snoc` u) a) -> AppTags (t `Snoc` u) a
- embedSigTag :: View alg1 (t ': t1) alg2 (t ': t2) => Sig alg1 (t ': t1) a -> Sig alg2 (t ': t2) a
- type family Snoc (xs :: [k]) (y :: k) where ...
- data Proxy k t :: forall k. k -> * = Proxy
- class Typeable k a
- data Constraint :: *
Constrained FAlgebras
class Typeable alg => FAlgebra alg where Source #
runSig1 :: alg a => proxy a -> Sig alg (s ': t) (AppTags t a) -> AppTags (s ': t) a Source #
runSig0 :: alg a => proxy a -> Sig alg t (AppTags t a) -> AppTags t a Source #
mapRun :: FreeConstraints t' a => (forall s. Free (Sig alg') s a -> AppTags s a) -> Sig alg t (Free (Sig alg') t' a) -> Sig alg t (AppTags t' a) Source #
Dealing with Type Families
This type synonym represents the kind of tags. Using this synonym requires the -XTypeInType extension.
NOTE: We would get more type safety if this were implemented as an open kind, but open kinds aren't yet implemented in GHC.
type family AppTags (t :: [Tag]) (a :: Type) :: Type where ... Source #
Apply a (possibly empty) list of tags to a type
type family ConsTag (t :: Tag) (ts :: [Tag]) :: [Tag] Source #
An alternative method for constructing kinds of [Tag] that obeys the equality constraints
Constrained Free Monad
data Free f t a where Source #
The constrained free monad
type family FreeConstraints (t :: [Tag]) (a :: Type) :: Constraint Source #
The constraints we are placing on the free monad
Converting between FAlgebras
class (FAlgebra alg1, FAlgebra alg2) => View alg1 t1 alg2 t2 where Source #
Variable definitions
Template Haskell
mkFAlgebra :: Name -> Q [Dec] Source #
Generates the FAlgebra instance for the specified name and all of its dependencies recursively
mkTag :: Name -> Q [Dec] Source #
Constructs the needed declarations for a type family assuming no constraints on the type family
mkTagFromCxt :: Cxt -> Name -> Q [Dec] Source #
Constructs the declarations for a type family that is constrainted by some context. Currently, the only supported constraints are idempocency constraints.
Helper functions
unsafeExtractSigTag0 :: View alg1 '[] alg2 t => Sig alg2 t (Free (Sig alg2) t a) -> Sig alg1 '[] (Free (Sig alg2) t a) Source #
unsafeExtractSigTag :: View alg1 '[s] alg2 (s ': t) => Sig alg2 (s ': t) (Free (Sig alg2) t a) -> Sig alg1 '[s] (Free (Sig alg2) t a) Source #
unsafeCoerceSigTag :: proxy t' -> Sig alg t a -> Sig alg t' a Source #
runSig1Snoc :: forall proxy alg a s ttt t u. (FAlgebra alg, alg (AppTag u a)) => Proxy (u :: Tag) -> Proxy (s :: Tag) -> Proxy (t :: [Tag]) -> Proxy a -> Sig alg ttt (AppTags t a) -> AppTag s (AppTags t a) Source #
runSig0Snoc :: forall proxy alg a t u. (FAlgebra alg, alg (AppTag u a)) => Proxy u -> Proxy a -> Sig alg t (AppTags (t `Snoc` u) a) -> AppTags (t `Snoc` u) a Source #
embedSigTag :: View alg1 (t ': t1) alg2 (t ': t2) => Sig alg1 (t ': t1) a -> Sig alg2 (t ': t2) a Source #
Other need types
data Proxy k t :: forall k. k -> * #
A concrete, poly-kinded proxy type
Monad (Proxy *) | |
Functor (Proxy *) | |
Applicative (Proxy *) | |
Foldable (Proxy *) | |
Traversable (Proxy *) | |
Generic1 (Proxy *) | |
Alternative (Proxy *) | |
MonadPlus (Proxy *) | |
Bounded (Proxy k s) | |
Enum (Proxy k s) | |
Eq (Proxy k s) | |
Ord (Proxy k s) | |
Read (Proxy k s) | |
Show (Proxy k s) | |
Ix (Proxy k s) | |
Generic (Proxy k t) | |
Monoid (Proxy k s) | |
type Rep1 (Proxy *) | |
type Rep (Proxy k t) | |
The class Typeable
allows a concrete representation of a type to
be calculated.
data Constraint :: * #
The kind of constraints, like Show a