Safe Haskell | None |
---|---|
Language | Haskell2010 |
Extensible ADT
Synopsis
- type EADT xs = Fix (VariantF xs)
- type family f :<: xs where ...
- type family xs :<<: ys :: Constraint where ...
- pattern VF :: forall e f cs. (e ~ EADT cs, f :<: cs) => f (EADT cs) -> EADT cs
- appendEADT :: forall ys xs zs. (zs ~ Concat xs ys, ApplyAll (EADT zs) zs ~ Concat (ApplyAll (EADT zs) xs) (ApplyAll (EADT zs) ys), Functor (VariantF xs)) => EADT xs -> EADT zs
- liftEADT :: forall e as bs. (e ~ Fix (VariantF bs), LiftVariantF as bs e, Functor (VariantF as)) => EADT as -> EADT bs
- popEADT :: forall f xs e. (f :<: xs, e ~ EADT xs, f e :< ApplyAll e xs) => EADT xs -> Either (VariantF (Remove f xs) (EADT xs)) (f (EADT xs))
- type AlterEADT c xs = AlterVariantF c (EADT xs) xs
- alterEADT :: forall c xs. AlterEADT c xs => (forall f. c f => f (EADT xs) -> f (EADT xs)) -> EADT xs -> EADT xs
- type AlgEADT c r xs = AlgVariantF c (EADT xs) r xs
- algEADT :: forall c r xs. AlgEADT c r xs => (forall f. c f => f (EADT xs) -> r) -> EADT xs -> r
- eadtToCont :: ContVariant (ApplyAll (Fix (VariantF xs)) xs) => Fix (VariantF xs) -> ContFlow (ApplyAll (Fix (VariantF xs)) xs) r
- eadtToContM :: (ContVariant (ApplyAll (Fix (VariantF xs)) xs), Monad m) => m (Fix (VariantF xs)) -> ContFlow (ApplyAll (Fix (VariantF xs)) xs) (m r)
- contToEADT :: ContVariant (ApplyAll (Fix (VariantF xs)) xs) => ContFlow (ApplyAll (Fix (VariantF xs)) xs) (V (ApplyAll (Fix (VariantF xs)) xs)) -> Fix (VariantF xs)
- contToEADTM :: (ContVariant (ApplyAll (Fix (VariantF xs)) xs), Monad f) => ContFlow (ApplyAll (Fix (VariantF xs)) xs) (f (V (ApplyAll (Fix (VariantF xs)) xs))) -> f (Fix (VariantF xs))
- module Haskus.Utils.Functor
- module Haskus.Utils.VariantF
Documentation
type family xs :<<: ys :: Constraint where ... Source #
Forall x
in xs
, `x :<: ys`
pattern VF :: forall e f cs. (e ~ EADT cs, f :<: cs) => f (EADT cs) -> EADT cs Source #
Pattern-match in an extensible ADT
appendEADT :: forall ys xs zs. (zs ~ Concat xs ys, ApplyAll (EADT zs) zs ~ Concat (ApplyAll (EADT zs) xs) (ApplyAll (EADT zs) ys), Functor (VariantF xs)) => EADT xs -> EADT zs Source #
Append new "constructors" to the EADT
liftEADT :: forall e as bs. (e ~ Fix (VariantF bs), LiftVariantF as bs e, Functor (VariantF as)) => EADT as -> EADT bs Source #
Lift an EADT into another
popEADT :: forall f xs e. (f :<: xs, e ~ EADT xs, f e :< ApplyAll e xs) => EADT xs -> Either (VariantF (Remove f xs) (EADT xs)) (f (EADT xs)) Source #
Pop an EADT value
type AlterEADT c xs = AlterVariantF c (EADT xs) xs Source #
alterEADT :: forall c xs. AlterEADT c xs => (forall f. c f => f (EADT xs) -> f (EADT xs)) -> EADT xs -> EADT xs Source #
Alter an EADT value
type AlgEADT c r xs = AlgVariantF c (EADT xs) r xs Source #
algEADT :: forall c r xs. AlgEADT c r xs => (forall f. c f => f (EADT xs) -> r) -> EADT xs -> r Source #
Apply an algebra to an EADT value
eadtToCont :: ContVariant (ApplyAll (Fix (VariantF xs)) xs) => Fix (VariantF xs) -> ContFlow (ApplyAll (Fix (VariantF xs)) xs) r Source #
Convert an EADT into a multi-continuation
eadtToContM :: (ContVariant (ApplyAll (Fix (VariantF xs)) xs), Monad m) => m (Fix (VariantF xs)) -> ContFlow (ApplyAll (Fix (VariantF xs)) xs) (m r) Source #
Convert an EADT into a multi-continuation
contToEADT :: ContVariant (ApplyAll (Fix (VariantF xs)) xs) => ContFlow (ApplyAll (Fix (VariantF xs)) xs) (V (ApplyAll (Fix (VariantF xs)) xs)) -> Fix (VariantF xs) Source #
Convert a multi-continuation into an EADT
contToEADTM :: (ContVariant (ApplyAll (Fix (VariantF xs)) xs), Monad f) => ContFlow (ApplyAll (Fix (VariantF xs)) xs) (f (V (ApplyAll (Fix (VariantF xs)) xs))) -> f (Fix (VariantF xs)) Source #
Convert a multi-continuation into an EADT
Reexport
module Haskus.Utils.Functor
module Haskus.Utils.VariantF