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 ...
- data Free f 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]
- 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
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
Heterogeneous Free Monad
data Free f t a where Source #
Free1 :: f (s ': t) (Free f t a) -> Free f (s ': t) a | |
Free0 :: f t (Free f t a) -> Free f t a | |
Pure :: AppTags t a -> Free f t a |
(View Floating ([] Tag) alg' t, View Fractional ([] Tag) alg' t, View Num ([] Tag) alg' t) => Floating (Free (Sig alg') t a) Source # | |
(View Fractional ([] Tag) alg' t, View Num ([] Tag) alg' t) => Fractional (Free (Sig alg') t a) Source # | |
View Num ([] Tag) alg' t => Num (Free (Sig alg') t a) Source # | |
(Show (AppTags t a), Show (f t (Free f t a)), ShowUntag (f t (Free f t a))) => Show (Free f t a) Source # | |
Converting between FAlgebras
class (FAlgebra alg1, FAlgebra alg2) => View alg1 t1 alg2 t2 where Source #
Variable definitions
Template Haskell
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