variant-1.0.2: Variant and EADT
Safe HaskellNone
LanguageHaskell2010

Data.Variant.VariantF

Description

VariantF functor

Synopsis

Documentation

newtype VariantF (xs :: [t -> Type]) (e :: t) Source #

Recursive Functor-like Variant

Constructors

VariantF (V (ApplyAll e xs)) 

Instances

Instances details
(Eq1 f, Eq1 (VariantF fs), ConstraintAll1 Eq1 fs) => Eq1 (VariantF (f ': fs)) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

liftEq :: (a -> b -> Bool) -> VariantF (f ': fs) a -> VariantF (f ': fs) b -> Bool #

Eq1 (VariantF ('[] :: [Type -> Type])) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

liftEq :: (a -> b -> Bool) -> VariantF ('[] :: [Type -> Type]) a -> VariantF ('[] :: [Type -> Type]) b -> Bool #

(Ord1 f, Ord1 (VariantF fs), ConstraintAll1 Eq1 fs, ConstraintAll1 Ord1 fs) => Ord1 (VariantF (f ': fs)) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

liftCompare :: (a -> b -> Ordering) -> VariantF (f ': fs) a -> VariantF (f ': fs) b -> Ordering #

Ord1 (VariantF ('[] :: [Type -> Type])) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

liftCompare :: (a -> b -> Ordering) -> VariantF ('[] :: [Type -> Type]) a -> VariantF ('[] :: [Type -> Type]) b -> Ordering #

(Show1 f, Show1 (VariantF fs), ConstraintAll1 Show1 fs) => Show1 (VariantF (f ': fs)) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> VariantF (f ': fs) a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [VariantF (f ': fs) a] -> ShowS #

Show1 (VariantF ('[] :: [Type -> Type])) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> VariantF ('[] :: [Type -> Type]) a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [VariantF ('[] :: [Type -> Type]) a] -> ShowS #

(Functor (VariantF fs), Functor f) => Functor (VariantF (f ': fs)) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

fmap :: (a -> b) -> VariantF (f ': fs) a -> VariantF (f ': fs) b #

(<$) :: a -> VariantF (f ': fs) b -> VariantF (f ': fs) a #

Functor (VariantF ('[] :: [Type -> Type])) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

fmap :: (a -> b) -> VariantF ('[] :: [Type -> Type]) a -> VariantF ('[] :: [Type -> Type]) b #

(<$) :: a -> VariantF ('[] :: [Type -> Type]) b -> VariantF ('[] :: [Type -> Type]) a #

(Show1 (VariantF xs), ConstraintAll1 Show1 xs, Show e) => Show (VariantF xs e) Source #

Show instance for VariantF

>>> let a = FV (ConsF 'a' "Test") :: VariantF [ConsF Char,NilF] String
>>> let b = FV (NilF :: NilF String) :: VariantF [ConsF Char,NilF] String
>>> print a
ConsF 'a' "Test"
>>> print b
NilF
Instance details

Defined in Data.Variant.VariantF

Methods

showsPrec :: Int -> VariantF xs e -> ShowS #

show :: VariantF xs e -> String #

showList :: [VariantF xs e] -> ShowS #

NFData (V (ApplyAll e xs)) => NFData (VariantF xs e) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

rnf :: VariantF xs e -> () #

(Eq1 (VariantF xs), ConstraintAll1 Eq1 xs, Eq e) => Eq (VariantF xs e) Source #

Eq instance for VariantF

>>> let a = FV (ConsF 'a' "Test") :: VariantF [ConsF Char,NilF] String
>>> let a' = FV (ConsF 'a' "XXX") :: VariantF [ConsF Char,NilF] String
>>> let b = FV (ConsF 'b' "Test") :: VariantF [ConsF Char,NilF] String
>>> a == a
True
>>> a == a'
False
>>> a == b
False
>>> let c = FV (ConsF 'c' b) :: VariantF [ConsF Char,NilF] (VariantF [ConsF Char, NilF] String)
>>> c == c
True
>>> let n1 = FV (NilF :: NilF ()) :: VariantF [ConsF Char,NilF] ()
>>> let n2 = FV (NilF :: NilF ()) :: VariantF [ConsF Char,NilF] ()
>>> n1 == n2
True
Instance details

Defined in Data.Variant.VariantF

Methods

(==) :: VariantF xs e -> VariantF xs e -> Bool #

(/=) :: VariantF xs e -> VariantF xs e -> Bool #

(Ord1 (VariantF xs), ConstraintAll1 Ord1 xs, ConstraintAll1 Eq1 xs, Ord e) => Ord (VariantF xs e) Source #

Ord instance for VariantF

>>> let a = FV (ConsF 'a' "Test") :: VariantF [ConsF Char,NilF] String
>>> let a' = FV (ConsF 'a' "XXX") :: VariantF [ConsF Char,NilF] String
>>> let b = FV (ConsF 'b' "Test") :: VariantF [ConsF Char,NilF] String
>>> compare a a
EQ
>>> compare a a'
LT
>>> compare a b
LT
Instance details

Defined in Data.Variant.VariantF

Methods

compare :: VariantF xs e -> VariantF xs e -> Ordering #

(<) :: VariantF xs e -> VariantF xs e -> Bool #

(<=) :: VariantF xs e -> VariantF xs e -> Bool #

(>) :: VariantF xs e -> VariantF xs e -> Bool #

(>=) :: VariantF xs e -> VariantF xs e -> Bool #

max :: VariantF xs e -> VariantF xs e -> VariantF xs e #

min :: VariantF xs e -> VariantF xs e -> VariantF xs e #

ContVariant (ApplyAll e xs) => MultiCont (VariantF xs e) Source # 
Instance details

Defined in Data.Variant.VariantF

Associated Types

type MultiContTypes (VariantF xs e) 
Instance details

Defined in Data.Variant.VariantF

type MultiContTypes (VariantF xs e) = ApplyAll e xs

Methods

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

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

type Base (VariantF xs a) Source # 
Instance details

Defined in Data.Variant.VariantF

type Base (VariantF xs a) = VariantF xs
type MultiContTypes (VariantF xs e) Source # 
Instance details

Defined in Data.Variant.VariantF

type MultiContTypes (VariantF xs e) = ApplyAll e xs

type family ApplyAll (e :: t) (xs :: [t -> k]) :: [k] where ... Source #

Apply its first argument to every element of the 2nd arg list

ApplyAll e [f,g,h] ==> [f e, g e, h e]

Equations

ApplyAll (e :: t) ('[] :: [t -> k]) = '[] :: [k] 
ApplyAll (e :: t) (f ': fs :: [t -> k]) = f e ': ApplyAll e fs 

pattern FV :: forall {t} c cs e. c :< ApplyAll e cs => c -> VariantF cs e Source #

Pattern-match in a VariantF

>>> FV (NilF :: NilF String) :: VariantF [ConsF Char,NilF] String
NilF

appendVariantF :: forall (ys :: [Type -> Type]) (xs :: [Type -> Type]) e. ApplyAll e (Concat xs ys) ~ Concat (ApplyAll e xs) (ApplyAll e ys) => VariantF xs e -> VariantF (Concat xs ys) e Source #

prependVariantF :: forall (xs :: [Type -> Type]) (ys :: [Type -> Type]) e. (ApplyAll e (Concat xs ys) ~ Concat (ApplyAll e xs) (ApplyAll e ys), KnownNat (Length (ApplyAll e xs))) => VariantF ys e -> VariantF (Concat xs ys) e Source #

toVariantFHead :: forall {t} x (xs :: [t -> Type]) (e :: t). x e -> VariantF (x ': xs) e Source #

Set the first value

toVariantFTail :: forall {t} (x :: t -> Type) (xs :: [t -> Type]) (e :: t). VariantF xs e -> VariantF (x ': xs) e Source #

Set the tail

popVariantFHead :: forall {t} x (xs :: [t -> Type]) (e :: t). VariantF (x ': xs) e -> Either (VariantF xs e) (x e) Source #

Pop VariantF head

variantFToValue :: forall {t} f (e :: t). VariantF '[f] e -> f e Source #

Retrieve a single value

type MapVariantF (a :: t -> Type) (b :: t -> Type) (cs :: [t -> Type]) (ds :: [t -> Type]) (e :: t) = (MapVariant (a e) (b e) (ApplyAll e cs), ds ~ ReplaceNS (IndexesOf a cs) b cs, ApplyAll e ds ~ ReplaceNS (IndexesOf (a e) (ApplyAll e cs)) (b e) (ApplyAll e cs)) Source #

mapVariantF :: forall {t} a b (cs :: [t -> Type]) (ds :: [t -> Type]) (e :: t). MapVariantF a b cs ds e => (a e -> b e) -> VariantF cs e -> VariantF ds e Source #

Map the matching types of a variant

type PopVariantF (x :: t -> Type) (xs :: [t -> Type]) (e :: t) = (x e :< ApplyAll e xs, Remove (x e) (ApplyAll e xs) ~ ApplyAll e (Remove x xs)) Source #

popVariantF :: forall {t} x (xs :: [t -> Type]) (e :: t). PopVariantF x xs e => VariantF xs e -> Either (VariantF (Remove x xs) e) (x e) Source #

Pop VariantF

type LiftVariantF (xs :: [t -> Type]) (ys :: [t -> Type]) (e :: t) = LiftVariant (ApplyAll e xs) (ApplyAll e ys) Source #

xs is liftable in ys

liftVariantF :: forall {t} (as :: [t -> Type]) (bs :: [t -> Type]) (e :: t). LiftVariantF as bs e => VariantF as e -> VariantF bs e Source #

Lift a VariantF into another

type SplitVariantF (as :: [t -> Type]) (xs :: [t -> Type]) (e :: t) = (Complement (ApplyAll e xs) (ApplyAll e as) ~ ApplyAll e (Complement xs as), SplitVariant (ApplyAll e as) (ApplyAll e (Complement xs as)) (ApplyAll e xs)) Source #

splitVariantF :: forall {t} (as :: [t -> Type]) (xs :: [t -> Type]) (e :: t). SplitVariantF as xs e => VariantF xs e -> Either (VariantF (Complement xs as) e) (VariantF as e) Source #

Split a VariantF in two

variantFToCont :: forall {t} (e :: t) (xs :: [t -> Type]) r. ContVariant (ApplyAll e xs) => VariantF xs e -> ContFlow (ApplyAll e xs) r Source #

Convert a VariantF into a multi-continuation

variantFToContM :: forall {t} (e :: t) (xs :: [t -> Type]) m r. (ContVariant (ApplyAll e xs), Monad m) => m (VariantF xs e) -> ContFlow (ApplyAll e xs) (m r) Source #

Convert a VariantF into a multi-continuation

contToVariantF :: forall {t} (xs :: [t -> Type]) (e :: t). ContVariant (ApplyAll e xs) => ContFlow (ApplyAll e xs) (V (ApplyAll e xs)) -> VariantF xs e Source #

Convert a multi-continuation into a VariantF

contToVariantFM :: forall {t} (xs :: [t -> Type]) (e :: t) m. (ContVariant (ApplyAll e xs), Monad m) => ContFlow (ApplyAll e xs) (m (V (ApplyAll e xs))) -> m (VariantF xs e) Source #

Convert a multi-continuation into a VariantF

Algebras

type family BottomUpF (c :: (Type -> Type) -> Constraint) (fs :: [Type -> Type]) where ... Source #

Equations

BottomUpF c fs = (Functor (VariantF fs), BottomUp c fs) 

class BottomUp (c :: (t -> Type) -> Constraint) (fs :: [t -> Type]) where Source #

Methods

toBottomUp :: forall (a :: t) b. (forall (f :: t -> Type). c f => f a -> b) -> VariantF fs a -> b Source #

Instances

Instances details
BottomUp (c :: (t -> Type) -> Constraint) ('[] :: [t -> Type]) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

toBottomUp :: forall (a :: t) b. (forall (f :: t -> Type). c f => f a -> b) -> VariantF ('[] :: [t -> Type]) a -> b Source #

(BottomUp c fs, c f) => BottomUp (c :: (t -> Type) -> Constraint) (f ': fs :: [t -> Type]) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

toBottomUp :: forall (a :: t) b. (forall (f0 :: t -> Type). c f0 => f0 a -> b) -> VariantF (f ': fs) a -> b Source #

class BottomUpOrig (c :: (Type -> Type) -> Constraint) (fs :: [Type -> Type]) where Source #

Methods

toBottomUpOrig :: (forall (f :: Type -> Type). c f => f (t, a) -> b) -> VariantF fs (t, a) -> b Source #

Instances

Instances details
BottomUpOrig c ('[] :: [Type -> Type]) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

toBottomUpOrig :: (forall (f :: Type -> Type). c f => f (t, a) -> b) -> VariantF ('[] :: [Type -> Type]) (t, a) -> b Source #

(BottomUpOrig c fs, c f) => BottomUpOrig c (f ': fs) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

toBottomUpOrig :: (forall (f0 :: Type -> Type). c f0 => f0 (t, a) -> b) -> VariantF (f ': fs) (t, a) -> b Source #

type family BottomUpOrigF (c :: (Type -> Type) -> Constraint) (fs :: [Type -> Type]) where ... Source #

Equations

BottomUpOrigF c fs = (Functor (VariantF fs), BottomUpOrig c fs) 

class TopDownStop (c :: (Type -> Type) -> Constraint) (fs :: [Type -> Type]) where Source #

Methods

toTopDownStop :: (forall (f :: Type -> Type). c f => TopDownStopT a f) -> TopDownStopT a (VariantF fs) Source #

Instances

Instances details
TopDownStop c ('[] :: [Type -> Type]) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

toTopDownStop :: (forall (f :: Type -> Type). c f => TopDownStopT a f) -> TopDownStopT a (VariantF ('[] :: [Type -> Type])) Source #

(TopDownStop c fs, Functor f, c f) => TopDownStop c (f ': fs) Source # 
Instance details

Defined in Data.Variant.VariantF

Methods

toTopDownStop :: (forall (f0 :: Type -> Type). c f0 => TopDownStopT a f0) -> TopDownStopT a (VariantF (f ': fs)) Source #

type family TopDownStopF (c :: (Type -> Type) -> Constraint) (fs :: [Type -> Type]) where ... Source #

Equations

TopDownStopF c fs = (Functor (VariantF fs), TopDownStop c fs) 

Reexport

class NoConstraint a Source #

Useful to specify a "Type -> Constraint" function returning an empty constraint

Instances

Instances details
NoConstraint a Source # 
Instance details

Defined in Data.Variant