harg-0.5.0.0: Haskell program configuration using higher kinded data
Safe HaskellNone
LanguageHaskell2010

Options.Harg.Het.Variant

Synopsis

Documentation

data VariantF (xs :: [(Type -> Type) -> Type]) (f :: Type -> Type) where Source #

A Variant is similar to nested Eithers. 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

Constructors

HereF :: x f -> VariantF (x ': xs) f 
ThereF :: VariantF xs f -> VariantF (y ': xs) f 

Instances

Instances details
(FunctorB x, FunctorB (VariantF xs)) => FunctorB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

bmap :: (forall (a :: k). f a -> g a) -> VariantF (x ': xs) f -> VariantF (x ': xs) g

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

Defined in Options.Harg.Het.Variant

Methods

bmap :: (forall (a :: k). f a -> g a) -> VariantF '[] f -> VariantF '[] g

(TraversableB x, TraversableB (VariantF xs)) => TraversableB (VariantF (x ': xs) :: (Type -> Type) -> Type) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> VariantF (x ': xs) f -> e (VariantF (x ': xs) g)

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

Defined in Options.Harg.Het.Variant

Methods

btraverse :: Applicative e => (forall (a :: k). f a -> e (g a)) -> VariantF '[] f -> e (VariantF '[] g)

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.

Methods

injectPosF :: SNat n -> x f -> VariantF xs f Source #

Instances

Instances details
InjectPosF 'Z x (x ': xs) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

injectPosF :: forall (f :: Type -> Type). SNat 'Z -> x f -> VariantF (x ': xs) f Source #

InjectPosF n x xs => InjectPosF ('S n) x (y ': xs) Source # 
Instance details

Defined in Options.Harg.Het.Variant

Methods

injectPosF :: forall (f :: Type -> Type). SNat ('S n) -> x f -> VariantF (y ': xs) f Source #

pattern In1 :: x1 f -> VariantF (x1 ': xs) f Source #

pattern In2 :: x2 f -> VariantF (x1 ': (x2 ': xs)) f Source #

pattern In3 :: x3 f -> VariantF (x1 ': (x2 ': (x3 ': xs))) f Source #

pattern In4 :: x4 f -> VariantF (x1 ': (x2 ': (x3 ': (x4 ': xs)))) f Source #

pattern In5 :: x5 f -> VariantF (x1 ': (x2 ': (x3 ': (x4 ': (x5 ': xs))))) f Source #