haskus-utils-variant-3.0: Variant and EADT

Safe HaskellNone
LanguageHaskell2010

Haskus.Utils.EADT

Contents

Description

Extensible ADT

Synopsis

Documentation

newtype EADT fs Source #

An extensible ADT

Constructors

EADT (VariantF fs (EADT fs)) 
Instances
Eq1 (VariantF fs) => Eq (EADT fs) Source # 
Instance details

Defined in Haskus.Utils.EADT

Methods

(==) :: EADT fs -> EADT fs -> Bool #

(/=) :: EADT fs -> EADT fs -> Bool #

Ord1 (VariantF fs) => Ord (EADT fs) Source # 
Instance details

Defined in Haskus.Utils.EADT

Methods

compare :: EADT fs -> EADT fs -> Ordering #

(<) :: EADT fs -> EADT fs -> Bool #

(<=) :: EADT fs -> EADT fs -> Bool #

(>) :: EADT fs -> EADT fs -> Bool #

(>=) :: EADT fs -> EADT fs -> Bool #

max :: EADT fs -> EADT fs -> EADT fs #

min :: EADT fs -> EADT fs -> EADT fs #

Show1 (VariantF fs) => Show (EADT fs) Source # 
Instance details

Defined in Haskus.Utils.EADT

Methods

showsPrec :: Int -> EADT fs -> ShowS #

show :: EADT fs -> String #

showList :: [EADT fs] -> ShowS #

Functor (VariantF fs) => Corecursive (EADT fs) Source # 
Instance details

Defined in Haskus.Utils.EADT

Methods

embed :: Base (EADT fs) (EADT fs) -> EADT fs #

ana :: (a -> Base (EADT fs) a) -> a -> EADT fs #

apo :: (a -> Base (EADT fs) (Either (EADT fs) a)) -> a -> EADT fs #

postpro :: Recursive (EADT fs) => (forall b. Base (EADT fs) b -> Base (EADT fs) b) -> (a -> Base (EADT fs) a) -> a -> EADT fs #

gpostpro :: (Recursive (EADT fs), Monad m) => (forall b. m (Base (EADT fs) b) -> Base (EADT fs) (m b)) -> (forall c. Base (EADT fs) c -> Base (EADT fs) c) -> (a -> Base (EADT fs) (m a)) -> a -> EADT fs #

Functor (VariantF fs) => Recursive (EADT fs) Source # 
Instance details

Defined in Haskus.Utils.EADT

Methods

project :: EADT fs -> Base (EADT fs) (EADT fs) #

cata :: (Base (EADT fs) a -> a) -> EADT fs -> a #

para :: (Base (EADT fs) (EADT fs, a) -> a) -> EADT fs -> a #

gpara :: (Corecursive (EADT fs), Comonad w) => (forall b. Base (EADT fs) (w b) -> w (Base (EADT fs) b)) -> (Base (EADT fs) (EnvT (EADT fs) w a) -> a) -> EADT fs -> a #

prepro :: Corecursive (EADT fs) => (forall b. Base (EADT fs) b -> Base (EADT fs) b) -> (Base (EADT fs) a -> a) -> EADT fs -> a #

gprepro :: (Corecursive (EADT fs), Comonad w) => (forall b. Base (EADT fs) (w b) -> w (Base (EADT fs) b)) -> (forall c. Base (EADT fs) c -> Base (EADT fs) c) -> (Base (EADT fs) (w a) -> a) -> EADT fs -> a #

(Functor (VariantF xs), ContVariant (ApplyAll (EADT xs) xs)) => MultiCont (EADT xs) Source #

MultiCont instance

>>> let f x = toCont x >::> (const "[]", \(ConsF u us) -> u ++ ":" ++ f us)
>>> f a
"Hello:World:[]"
Instance details

Defined in Haskus.Utils.EADT

Associated Types

type MultiContTypes (EADT xs) :: [Type] Source #

Methods

toCont :: EADT xs -> ContFlow (MultiContTypes (EADT xs)) r Source #

toContM :: Monad m => m (EADT xs) -> ContFlow (MultiContTypes (EADT xs)) (m r) Source #

type Base (EADT fs) Source # 
Instance details

Defined in Haskus.Utils.EADT

type Base (EADT fs) = VariantF fs
type MultiContTypes (EADT xs) Source # 
Instance details

Defined in Haskus.Utils.EADT

type MultiContTypes (EADT xs) = ApplyAll (EADT xs) xs

type family f :<: xs where ... Source #

Constructor f is in xs

Equations

f :<: xs = EADTF' f (EADT xs) xs 

type family xs :<<: ys :: Constraint where ... Source #

Forall x in xs, `x :<: ys`

Equations

'[] :<<: ys = () 
(x ': xs) :<<: ys = (x :<: ys, xs :<<: 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 ~ EADT 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

contToEADT :: ContVariant (ApplyAll (EADT xs) xs) => ContFlow (ApplyAll (EADT xs) xs) (V (ApplyAll (EADT xs) xs)) -> EADT xs Source #

Convert a multi-continuation into an EADT

contToEADTM :: (ContVariant (ApplyAll (EADT xs) xs), Monad f) => ContFlow (ApplyAll (EADT xs) xs) (f (V (ApplyAll (EADT xs) xs))) -> f (EADT xs) Source #

Convert a multi-continuation into an EADT

Reexport