Safe Haskell | Safe |
---|---|
Language | GHC2021 |
Data.HList
Synopsis
- data InList xs x where
- pattern There2 :: InList xs x -> InList (y0 : (y1 : xs)) x
- pattern There3 :: InList xs x -> InList (y0 : (y1 : (y2 : xs))) x
- pattern There4 :: InList xs x -> InList (y0 : (y1 : (y2 : (y3 : xs)))) x
- pattern There5 :: InList xs x -> InList (y0 : (y1 : (y2 : (y3 : (y4 : xs))))) x
- pattern There6 :: InList xs x -> InList (y0 : (y1 : (y2 : (y3 : (y4 : (y5 : xs)))))) x
- pattern InList0 :: InList (x : xs) x
- pattern InList1 :: InList (y0 : (x : xs)) x
- pattern InList2 :: InList (y0 : (y1 : (x : xs))) x
- pattern InList3 :: InList (y0 : (y1 : (y2 : (x : xs)))) x
- pattern InList4 :: InList (y0 : (y1 : (y2 : (y3 : (x : xs))))) x
- pattern InList5 :: InList (y0 : (y1 : (y2 : (y3 : (y4 : (x : xs)))))) x
- pattern InList6 :: InList (y0 : (y1 : (y2 : (y3 : (y4 : (y5 : (x : xs))))))) x
- data SomeIndex xs where
- data SomeValue xs where
- padMessageIndex :: SomeValue ts -> SomeValue (t : ts)
- data Port = Type :> Type
- type family PortTxType p where ...
- type family PortRxType p where ...
- type family PortDual p where ...
- type PortInList x y xs = InList xs (x :> y)
- type family Fst p where ...
- type family MapFst l where ...
- type family Snd p where ...
- type family Zip l l' where ...
- data SomeRxMess xs where
- SomeRxMess :: InList xs p -> PortRxType p -> SomeRxMess xs
- data SomeTxMess xs where
- SomeTxMess :: InList xs p -> PortTxType p -> SomeTxMess xs
- data HList f (types :: [a]) where
- data KnownHPPortsD ports where
- KnownHPPortsZ :: KnownHPPortsD '[]
- KnownHPPortsS :: KnownHPPortsD ports -> KnownHPPortsD ((HListPair xl xr :> HListPair yl yr) : ports)
- type HListPair l r = (HList Identity l, HList Identity r)
- type family Concat2 l r p where ...
- type family MapConcat2 l r ports where ...
- (++) :: HList f l -> HList f r -> HList f (Concat l r)
- (+++) :: HListPair l r -> HListPair l' r' -> HListPair (Concat l l') (Concat r r')
- class KnownHPPorts ports where
- getKnownHPPorts :: KnownHPPortsD ports
- data KnownLenD :: forall a. [a] -> Type where
- class KnownLen l where
- getKnownLenPrf :: KnownLenD l
- data SameLenD :: forall a b. [a] -> [b] -> Type where
- SameLenNil :: SameLenD '[] '[]
- SameLenCons :: SameLenD l l' -> SameLenD (x : l) (x' : l')
- class SameLen l l' where
- proveSameLength :: SameLenD l l'
- type family Concat xs ys where ...
- concatAssocPrf :: forall p p' s' l s. ListSplitD l p s -> Concat p (Concat p' s') :~: Concat (Concat p p') s'
- concatInjPrf :: forall xs ys ys'. (Concat xs ys :~: Concat xs ys') -> KnownLenD xs -> ys :~: ys'
- data ListSplitD :: forall a. [a] -> [a] -> [a] -> Type where
- SplitHere :: ListSplitD l '[] l
- SplitThere :: ListSplitD l p s -> ListSplitD (x : l) (x : p) s
- type ListSplitConcat p s = ListSplitD (Concat p s) p s
- class ListSplit l p s where
- getListSplit :: ListSplitD l p s
- getListSplit' :: KnownLenD p -> ListSplitD (Concat p s) p s
- listSplitConcat :: ListSplitD l p s -> Concat p s :~: l
- listSplitAdd :: ListSplitD l p s -> ListSplitD s p' s' -> ListSplitD l (Concat p p') s'
- listConcatSplit :: ListSplitD l p s -> ListSplitD (Concat p s') p s'
- listSplitPopSuffix :: ListSplitD (Concat p (x : s)) p (x : s) -> ListSplitD (Concat p s) p s
- listSplitSubst :: ListSplitD l' p' (s : rest) -> ListSplitConcat p' (f : rest)
- listSplitSwap :: ListSplitD l p (f : l') -> ListSplitD l' p' (s : rest) -> (ListSplitConcat p (s : Concat p' (f : rest)), ListSplitConcat p' (f : rest))
- listSplitSuff2 :: ListSplitD l p (f : l') -> ListSplitD l' p' (s : rest) -> (ListSplitConcat p (Concat p' rest), ListSplitConcat p' rest)
- pattern Split0 :: ListSplitD l '[] l
- pattern Split1 :: ListSplitD (x0 : l) '[x0] l
- pattern Split2 :: ListSplitD (x0 : (x1 : l)) (x0 : '[x1]) l
- pattern Split3 :: ListSplitD (x0 : (x1 : (x2 : l))) (x0 : (x1 : '[x2])) l
- pattern Split4 :: ListSplitD (x0 : (x1 : (x2 : (x3 : l)))) (x0 : (x1 : (x2 : '[x3]))) l
- pattern Split5 :: ListSplitD (x0 : (x1 : (x2 : (x3 : (x4 : l))))) (x0 : (x1 : (x2 : (x3 : '[x4])))) l
- hlistDrop :: ListSplitD l p s -> HList f l -> HList f s
- hlistTakeHead :: HList f (x : xs) -> HList f '[x]
- pattern HListMatch0 :: HList f '[]
- pattern HListMatch1 :: f a -> HList f '[a]
- pattern HListMatch2 :: f a -> f a' -> HList f '[a, a']
- pattern HListMatch3 :: f a -> f a' -> f a'' -> HList f '[a, a', a'']
- data HList2 f (x :: [a]) (y :: [b]) where
- pattern HList2Match0 :: HList2 f '[] '[]
- pattern HList2Match1 :: f a b -> HList2 f '[a] '[b]
- pattern HList2Match2 :: f a b -> f a' b' -> HList2 f '[a, a'] '[b, b']
- pattern HList2Match3 :: f a b -> f a' b' -> f a'' b'' -> HList2 f '[a, a', a''] '[b, b', b'']
- (!!) :: HList f types -> InList types x -> f x
- forIthFst :: Monad m => InList xs x -> HList2 f xs ys -> (forall y. f x y -> m (f x y, z)) -> m (HList2 f xs ys, z)
- forIth :: Monad m => InList types x -> HList f types -> (f x -> m (f x, z)) -> m (HList f types, z)
- hMap :: (forall a. InList types a -> f a -> g a) -> HList f types -> HList g types
- homogenize :: forall t (types :: [t]) (f :: t -> Type) a. (forall x. InList types x -> f x -> a) -> HList f types -> [a]
- knownLenToSplit :: KnownLenD p -> ListSplitD (Concat p s) p s
- splitHList :: ListSplitD l p s -> HList f l -> (HList f p, HList f s)
- someRxMessThere :: SomeRxMess ports' -> SomeRxMess (x : ports')
- data ConstrAllD (c :: Type -> Constraint) (l :: [Type]) where
- ConstrAllNil :: ConstrAllD c '[]
- ConstrAllCons :: c t => ConstrAllD c l -> ConstrAllD c (t : l)
- knownLenfromConstrAllD :: ConstrAllD c l -> KnownLenD l
- class ConstrAll c l where
- getConstrAllD :: ConstrAllD c l
- data HListShow l where
Dependent pointer into a list
Dependent index of an element of type (x, y)
in list xs
We use lists of pairs to encode the ports an algorithm has access to,
as well heterogenous lists HList
that occur during interpretation of our
algorithms. And this type serves as a pointer into one of such ports in
the list.
Instances
TestEquality (InList xs :: k -> Type) # | Compare two indices for equality |
Defined in Data.HList |
padMessageIndex :: SomeValue ts -> SomeValue (t : ts) #
Pad the index to make it valid after applying (::)
to the list.
Port Lists
A port is defined by a pair of types.
A
allows asyncronously sending values of type:>
BA
and receivingB
.A
allows to do the same syncronously,:|>
BA
allows serving syncronous requests.:>|
B
Instances
KnownHPPorts ('[] :: [Port]) # | |
Defined in Data.HList Methods getKnownHPPorts :: KnownHPPortsD '[] # | |
(KnownHPPorts ports, p ~ (HListPair xl xr ':> HListPair yl yr)) => KnownHPPorts (p ': ports) # | |
Defined in Data.HList Methods getKnownHPPorts :: KnownHPPortsD (p ': ports) # |
type family PortTxType p where ... #
Equations
PortTxType (x :> _) = x |
type family PortRxType p where ... #
Equations
PortRxType (_ :> x) = x |
type PortInList x y xs = InList xs (x :> y) #
A pointer into the list of ports xs
.
The
is a proof of PortInList
x y xsx
being in :>
yxs
.
data SomeRxMess xs where #
Constructors
SomeRxMess :: InList xs p -> PortRxType p -> SomeRxMess xs |
data SomeTxMess xs where #
Constructors
SomeTxMess :: InList xs p -> PortTxType p -> SomeTxMess xs |
Heterogenous Lists
data HList f (types :: [a]) where #
Heterogenous List
Instances
Flattenable (HListPair '[sid] '[Pid]) # | |
Defined in LambdaUC.UC.Flatten Methods getFlattenableD :: FlattenableD (HListPair '[sid] '[Pid]) # | |
Flattenable (HListPair '[sid] ('[] :: [Type])) # | |
Defined in LambdaUC.UC.Flatten Methods getFlattenableD :: FlattenableD (HListPair '[sid] '[]) # | |
Flattenable (HListPair ('[] :: [Type]) '[Pid, m]) # | |
Defined in LambdaUC.UC.Flatten Methods getFlattenableD :: FlattenableD (HListPair '[] '[Pid, m]) # | |
Flattenable (HListPair ('[] :: [Type]) '[m]) # | |
Defined in LambdaUC.UC.Flatten Methods getFlattenableD :: FlattenableD (HListPair '[] '[m]) # |
data KnownHPPortsD ports where #
Constructors
KnownHPPortsZ :: KnownHPPortsD '[] | |
KnownHPPortsS :: KnownHPPortsD ports -> KnownHPPortsD ((HListPair xl xr :> HListPair yl yr) : ports) |
type family MapConcat2 l r ports where ... #
Equations
MapConcat2 _ _ '[] = '[] | |
MapConcat2 l r (p : ports) = Concat2 l r p : MapConcat2 l r ports |
class KnownHPPorts ports where #
Methods
getKnownHPPorts :: KnownHPPortsD ports #
Instances
KnownHPPorts ('[] :: [Port]) # | |
Defined in Data.HList Methods getKnownHPPorts :: KnownHPPortsD '[] # | |
(KnownHPPorts ports, p ~ (HListPair xl xr ':> HListPair yl yr)) => KnownHPPorts (p ': ports) # | |
Defined in Data.HList Methods getKnownHPPorts :: KnownHPPortsD (p ': ports) # |
data KnownLenD :: forall a. [a] -> Type where #
Signleton type to express the list structure (length) but not the contents.
Class of list values for which their length is known at compile time.
Methods
getKnownLenPrf :: KnownLenD l #
Instances
KnownLen ('[] :: [a]) # | |
Defined in Data.HList Methods getKnownLenPrf :: KnownLenD '[] # | |
KnownLen xs => KnownLen (x ': xs :: [a]) # | |
Defined in Data.HList Methods getKnownLenPrf :: KnownLenD (x ': xs) # |
data SameLenD :: forall a b. [a] -> [b] -> Type where #
Constructors
SameLenNil :: SameLenD '[] '[] | |
SameLenCons :: SameLenD l l' -> SameLenD (x : l) (x' : l') |
Methods
proveSameLength :: SameLenD l l' #
Instances
SameLen ('[] :: [a]) ('[] :: [b]) # | |
Defined in Data.HList Methods proveSameLength :: SameLenD '[] '[] # | |
SameLen l l' => SameLen (x ': l :: [a]) (x' ': l' :: [b]) # | |
Defined in Data.HList Methods proveSameLength :: SameLenD (x ': l) (x' ': l') # |
concatAssocPrf :: forall p p' s' l s. ListSplitD l p s -> Concat p (Concat p' s') :~: Concat (Concat p p') s' #
Proof of `p ++ (p' ++ s') == (p ++ p') ++ s'`.
data ListSplitD :: forall a. [a] -> [a] -> [a] -> Type where #
Statement
says that ListSplitD
l p sl = p ++ s
, i.e. that l
can be
cut into prefix p
and suffix s
.
Structure-wise, this is just a pointer, like InList
, but it carries
different information on type-level.
Constructors
SplitHere :: ListSplitD l '[] l | |
SplitThere :: ListSplitD l p s -> ListSplitD (x : l) (x : p) s |
type ListSplitConcat p s = ListSplitD (Concat p s) p s #
Methods
getListSplit :: ListSplitD l p s #
Instances
(KnownLen p, l ~ Concat p s) => ListSplit (l :: [a]) (p :: [a]) (s :: [a]) # | |
Defined in Data.HList Methods getListSplit :: ListSplitD l p s # |
getListSplit' :: KnownLenD p -> ListSplitD (Concat p s) p s #
listSplitConcat :: ListSplitD l p s -> Concat p s :~: l #
listSplitAdd :: ListSplitD l p s -> ListSplitD s p' s' -> ListSplitD l (Concat p p') s' #
listConcatSplit :: ListSplitD l p s -> ListSplitD (Concat p s') p s' #
listSplitPopSuffix :: ListSplitD (Concat p (x : s)) p (x : s) -> ListSplitD (Concat p s) p s #
listSplitSubst :: ListSplitD l' p' (s : rest) -> ListSplitConcat p' (f : rest) #
listSplitSwap :: ListSplitD l p (f : l') -> ListSplitD l' p' (s : rest) -> (ListSplitConcat p (s : Concat p' (f : rest)), ListSplitConcat p' (f : rest)) #
listSplitSuff2 :: ListSplitD l p (f : l') -> ListSplitD l' p' (s : rest) -> (ListSplitConcat p (Concat p' rest), ListSplitConcat p' rest) #
pattern Split0 :: ListSplitD l '[] l #
pattern Split1 :: ListSplitD (x0 : l) '[x0] l #
pattern Split2 :: ListSplitD (x0 : (x1 : l)) (x0 : '[x1]) l #
pattern Split3 :: ListSplitD (x0 : (x1 : (x2 : l))) (x0 : (x1 : '[x2])) l #
pattern Split4 :: ListSplitD (x0 : (x1 : (x2 : (x3 : l)))) (x0 : (x1 : (x2 : '[x3]))) l #
pattern Split5 :: ListSplitD (x0 : (x1 : (x2 : (x3 : (x4 : l))))) (x0 : (x1 : (x2 : (x3 : '[x4])))) l #
hlistDrop :: ListSplitD l p s -> HList f l -> HList f s #
hlistTakeHead :: HList f (x : xs) -> HList f '[x] #
pattern HListMatch0 :: HList f '[] #
pattern HListMatch1 :: f a -> HList f '[a] #
pattern HListMatch2 :: f a -> f a' -> HList f '[a, a'] #
pattern HListMatch3 :: f a -> f a' -> f a'' -> HList f '[a, a', a''] #
pattern HList2Match0 :: HList2 f '[] '[] #
pattern HList2Match1 :: f a b -> HList2 f '[a] '[b] #
pattern HList2Match2 :: f a b -> f a' b' -> HList2 f '[a, a'] '[b, b'] #
pattern HList2Match3 :: f a b -> f a' b' -> f a'' b'' -> HList2 f '[a, a', a''] '[b, b', b''] #
(!!) :: HList f types -> InList types x -> f x #
Fetch the value under given index. Statically checked version of Prelude.(!!)
.
Arguments
:: Monad m | |
=> InList xs x | Element index |
-> HList2 f xs ys | List |
-> (forall y. f x y -> m (f x y, z)) | Action |
-> m (HList2 f xs ys, z) |
Applies given mutating action to one of the elements in the list
Arguments
:: Monad m | |
=> InList types x | Action |
-> HList f types | Element index |
-> (f x -> m (f x, z)) | List |
-> m (HList f types, z) |
Applies given mutating action to one of the elements in the list
homogenize :: forall t (types :: [t]) (f :: t -> Type) a. (forall x. InList types x -> f x -> a) -> HList f types -> [a] #
Convert HList
to a regular list.
knownLenToSplit :: KnownLenD p -> ListSplitD (Concat p s) p s #
splitHList :: ListSplitD l p s -> HList f l -> (HList f p, HList f s) #
someRxMessThere :: SomeRxMess ports' -> SomeRxMess (x : ports') #
data ConstrAllD (c :: Type -> Constraint) (l :: [Type]) where #
Constructors
ConstrAllNil :: ConstrAllD c '[] | |
ConstrAllCons :: c t => ConstrAllD c l -> ConstrAllD c (t : l) |
knownLenfromConstrAllD :: ConstrAllD c l -> KnownLenD l #
Methods
getConstrAllD :: ConstrAllD c l #
Instances
ConstrAll c ('[] :: [Type]) # | |
Defined in Data.HList Methods getConstrAllD :: ConstrAllD c '[] # | |
(c t, ConstrAll c l) => ConstrAll c (t ': l) # | |
Defined in Data.HList Methods getConstrAllD :: ConstrAllD c (t ': l) # |
Instances
Eq (HListShow l) # | |
Ord (HListShow l) # | |
Defined in Data.HList |