Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data VariantF (xs :: [(Type -> Type) -> Type]) (f :: Type -> Type) where
- fromVariantF :: FromVariantF xs result f => VariantF xs f -> FoldSignatureF xs result f
- class InjectPosF (n :: Nat) (x :: (Type -> Type) -> Type) (xs :: [(Type -> Type) -> Type]) | n xs -> x where
- injectPosF :: SNat n -> x f -> VariantF xs f
- pattern In1 :: x1 f -> VariantF (x1 ': xs) f
- pattern In2 :: x2 f -> VariantF (x1 ': (x2 ': xs)) f
- pattern In3 :: x3 f -> VariantF (x1 ': (x2 ': (x3 ': xs))) f
- pattern In4 :: x4 f -> VariantF (x1 ': (x2 ': (x3 ': (x4 ': xs)))) f
- pattern In5 :: x5 f -> VariantF (x1 ': (x2 ': (x3 ': (x4 ': (x5 ': xs))))) f
Documentation
data VariantF (xs :: [(Type -> Type) -> Type]) (f :: Type -> Type) where Source #
A Variant is similar to nested Either
s. For example, Variant '[Int,
Bool, Char]
is isomorphic to Either Int (Either Bool Char)
. VariantF
is a variant for higher-kinded types, which means that the type-level list
holds types of kind (Type -> Type) -> Type
, and the second parameter is
the type constructor f :: Type -> Type
. To pattern match on a variant,
HereF
and ThereF
can be used:
getFromVariant :: Variant '[Int, Bool, String] -> Bool getFromVariant (ThereF (HereF b)) = b
Instances
(TraversableB x, TraversableB (VariantF xs)) => TraversableB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Het.Variant btraverse :: Applicative t => (forall (a :: k). f a -> t (g a)) -> VariantF (x ': xs) f -> t (VariantF (x ': xs) g) # | |
TraversableB (VariantF ([] :: [(Type -> Type) -> Type])) Source # | |
Defined in Options.Harg.Het.Variant btraverse :: Applicative t => (forall (a :: k). f a -> t (g a)) -> VariantF [] f -> t (VariantF [] g) # | |
(FunctorB x, FunctorB (VariantF xs)) => FunctorB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # | |
Defined in Options.Harg.Het.Variant | |
FunctorB (VariantF ([] :: [(Type -> Type) -> Type])) Source # | |
Defined in Options.Harg.Het.Variant |
fromVariantF :: FromVariantF xs result f => VariantF xs f -> FoldSignatureF xs result f Source #
class InjectPosF (n :: Nat) (x :: (Type -> Type) -> Type) (xs :: [(Type -> Type) -> Type]) | n xs -> x where Source #
Given a type-level natural that designates a position of injection into
a VariantF
, return a function that performs this injection. For example,
S Z
which corresponds to 1 or the second position in the type-level list
the variant holds, can give the injection b f -> VariantF [a, b, c] f
.
The injection can as well be constructed without providing the position, but
it helps in case x
is not unique in xs
.
injectPosF :: SNat n -> x f -> VariantF xs f Source #
Instances
InjectPosF Z x (x ': xs) Source # | |
Defined in Options.Harg.Het.Variant | |
InjectPosF n x xs => InjectPosF (S n) x (y ': xs) Source # | |
Defined in Options.Harg.Het.Variant |