Copyright | (c) 2020-2021 Tim Emiola |
---|---|
License | BSD3 |
Maintainer | Tim Emiola <adetokunbo@users.noreply.github.com> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Defines type-level data structures and combinators used by System.TmpProc.Docker and System.TmpProc.Warp.
HList
implements a heterogenous list used to define types that represent
multiple concurrent tmp procs
.
KV
is intended for internal use within the tmp-proc
package. It allows
indexing and sorting of lists of tmp procs.
Synopsis
- data HList :: [Type] -> Type where
- (&:) :: x -> HList xs -> HList (x ': xs)
- only :: x -> HList '[x]
- (&:&) :: x -> y -> HList '[x, y]
- both :: x -> y -> HList '[x, y]
- hHead :: HList (a ': as) -> a
- hOf :: forall y xs. IsInProof y xs => Proxy y -> HList xs -> y
- class ReorderH xs ys where
- data KV :: Symbol -> Type -> Type where
- select :: forall k t xs. MemberKV k t xs => HList xs -> t
- selectMany :: forall ks ts xs. ManyMemberKV ks ts xs => HList xs -> HList ts
- data LookupKV (k :: Symbol) t (xs :: [Type]) where
- class MemberKV (k :: Symbol) (t :: Type) (xs :: [Type]) where
- lookupProof :: LookupKV k t xs
- class ManyMemberKV (ks :: [Symbol]) (ts :: [Type]) (kvs :: [Type]) where
- manyProof :: LookupMany ks ts kvs
- type family IsAbsent e r :: Constraint where ...
- class IsInProof t (tys :: [Type])
- module System.TmpProc.TypeLevel.Sort
Heterogenous List
data HList :: [Type] -> Type where Source #
Defines a Heterogenous list.
hOf :: forall y xs. IsInProof y xs => Proxy y -> HList xs -> y Source #
Get an item in an HList
given its type.
class ReorderH xs ys where Source #
Allows reordering of similar
.HList
s
Examples
>>>
hReorder @_ @'[Bool, Int] ('c' &: (3 :: Int) &: True &: (3.1 :: Double) &: HNil)
True &: 3 &: HNil
>>>
hReorder @_ @'[Double, Bool, Int] ('c' &: (3 :: Int) &: True &: (3.1 :: Double) &: HNil)
3.1 &: True &: 3 &: HNil
A type-level Key-Value
data KV :: Symbol -> Type -> Type where Source #
Use a type-level symbol as key type that indexes a value type.
Instances
ManyMemberKV ks ts kvs => ManyMemberKV ks ts (KV ok ot ': kvs) Source # | |
Defined in System.TmpProc.TypeLevel | |
MemberKV k t '[KV k t] Source # | |
Defined in System.TmpProc.TypeLevel lookupProof :: LookupKV k t '[KV k t] Source # | |
MemberKV k t (KV k t ': kvs) Source # | |
Defined in System.TmpProc.TypeLevel lookupProof :: LookupKV k t (KV k t ': kvs) Source # | |
MemberKV k t kvs => MemberKV k t (KV ok ot ': kvs) Source # | |
Defined in System.TmpProc.TypeLevel lookupProof :: LookupKV k t (KV ok ot ': kvs) Source # | |
ManyMemberKV '[k] '[t] (KV k t ': ks) Source # | |
Defined in System.TmpProc.TypeLevel | |
ManyMemberKV ks ts kvs => ManyMemberKV (k ': ks) (t ': ts) (KV k t ': kvs) Source # | |
Defined in System.TmpProc.TypeLevel |
selectMany :: forall ks ts xs. ManyMemberKV ks ts xs => HList xs -> HList ts Source #
Select items with specified keys from an
of HList
by key.KV
s
N.B. this this is an internal function.
The keys must be provided in the same order as they occur in the HList, any other order will likely result in an compiler error.
Examples
>>>
selectMany @'["b"] @'[Bool] @'[KV "b" Bool, KV "d" Double] (V True &: V (3.1 :: Double) &: HNil)
True &: HNil
data LookupKV (k :: Symbol) t (xs :: [Type]) where Source #
Proves a symbol and its type occur as entry in a list of
types.KV
class MemberKV (k :: Symbol) (t :: Type) (xs :: [Type]) where Source #
Generate proof instances of LookupKV
.
lookupProof :: LookupKV k t xs Source #
Instances
MemberKV k t '[KV k t] Source # | |
Defined in System.TmpProc.TypeLevel lookupProof :: LookupKV k t '[KV k t] Source # | |
MemberKV k t (KV k t ': kvs) Source # | |
Defined in System.TmpProc.TypeLevel lookupProof :: LookupKV k t (KV k t ': kvs) Source # | |
MemberKV k t kvs => MemberKV k t (KV ok ot ': kvs) Source # | |
Defined in System.TmpProc.TypeLevel lookupProof :: LookupKV k t (KV ok ot ': kvs) Source # |
class ManyMemberKV (ks :: [Symbol]) (ts :: [Type]) (kvs :: [Type]) where Source #
Generate proof instances of LookupMany
.
Instances
ManyMemberKV ks ts kvs => ManyMemberKV ks ts (KV ok ot ': kvs) Source # | |
Defined in System.TmpProc.TypeLevel | |
ManyMemberKV '[k] '[t] (KV k t ': ks) Source # | |
Defined in System.TmpProc.TypeLevel | |
ManyMemberKV ks ts kvs => ManyMemberKV (k ': ks) (t ': ts) (KV k t ': kvs) Source # | |
Defined in System.TmpProc.TypeLevel |
Other combinators
type family IsAbsent e r :: Constraint where ... Source #
A constraint that confirms that a type is not present in a type-level list.
class IsInProof t (tys :: [Type]) Source #
Generate proof instances of IsIn
.
provedIsIn
Instances
IsInProof t tys => IsInProof t (a ': tys) Source # | |
Defined in System.TmpProc.TypeLevel provedIsIn :: IsIn t (a ': tys) | |
IsInProof t (t ': tys) Source # | |
Defined in System.TmpProc.TypeLevel provedIsIn :: IsIn t (t ': tys) |