Safe Haskell | None |
---|---|
Language | Haskell2010 |
The HList library
(C) 2004, Oleg Kiselyov, Ralf Laemmel, Keean Schupke
Type-indexed co-products. The public interface is exposed in CommonMain#TIC
(There are other ways: see ConsUnion.hs, for example)
- newtype TIC l = TIC (Variant l)
- ticVariant :: (Profunctor p, Functor f) => p (Variant t) (f (Variant l)) -> p (TIC t) (f (TIC l))
- ticVariant' :: (Profunctor p, Functor f) => p (Variant t) (f (Variant t)) -> p (TIC t) (f (TIC t))
- class TypeIndexed r tr | r -> tr, tr -> r where
- typeIndexed :: forall p f s t a b. (TypeIndexedCxt s t a b, Profunctor p, Functor f) => p (tr (TagR a)) (f (tr (TagR b))) -> p (r s) (f (r t))
- type TypeIndexedCxt s t a b = (HMapCxt HList TaggedFn b t, RecordValues s, RecordValues t, a ~ RecordValuesR s, b ~ RecordValuesR t, SameLabels s t, SameLength s t, SameLength b a, Coercible (TagR b) t, Coercible (TagR a) s, HAllTaggedLV s, HRLabelSet t, TagUntag a, TagUntag b)
- typeIndexed' :: (TypeIndexed r tr, TagUntagFD (RecordValuesR s) (TagR (RecordValuesR s)), HLabelSet [*] (LabelsOf s), RecordValues s, HMapAux HList TaggedFn (RecordValuesR s) s, SameLength' * * (RecordValuesR s) (RecordValuesR s), SameLength' * * s s, SameLabels [*] [*] s s, HAllTaggedLV s, Profunctor p, Coercible [*] (TagR (RecordValuesR s)) s, Functor f) => p (tr (TagR (RecordValuesR s))) (f (tr (TagR (RecordValuesR s)))) -> p (r s) (f (r s))
- mkTIC' :: forall i l proxy. (HTypeIndexed l, MkVariant i i l) => i -> proxy l -> TIC l
- mkTIC1 :: forall i. MkVariant i i `[Tagged i i]` => i -> TIC `[Tagged i i]`
- mkTIC :: (HAllTaggedEq l, HLabelSet [*] (LabelsOf l), HasField * i (Record l) i, HFind1 * i (UnLabel * i (LabelsOf l)) n, HAllTaggedLV l, KnownNat (HNat2Nat n)) => i -> TIC l
- class TICPrism s t a b | s a b -> t, t a b -> s where
- ticPrism :: (SameLength s t, Choice p, Applicative f) => (a `p` f b) -> TIC s `p` f (TIC t)
- ticPrism' :: forall s t a b. (HPrism a s t a b, a ~ b, s ~ t) => forall f p. (Applicative f, Choice p) => (a `p` f b) -> TIC s `p` f (TIC t)
Documentation
A datatype for type-indexed co-products. A TIC
is just a Variant
,
where the elements of the type-level list "l"
are in the form
Tagged x x
.
TypeIndexed Variant TIC | |
HMapAux Variant f xs ys => HMapAux TIC f xs ys | |
(TICPrism s t a b, (~) * x a, (~) * a b, (~) [*] s t, SameLength * * s t) => Labelable * x TIC s t a b | hLens' :: Label a -> Prism' (TIC s) a note that a more general function |
HasField * o (Variant l) (Maybe o) => HasField * o (TIC l) (Maybe o) | Public destructor (or, open union's projection function) |
(HasField * o (TIC l) mo, (~) * mo (Maybe o)) => HOccurs mo (TIC l) | |
((~) * me (Maybe e), HOccursNot * (Tagged * e e) l) => HExtend me (TIC l) | Nothing .*. x = x Just a .*. y = mkTIC a |
Bounded (Variant l) => Bounded (TIC l) | |
Enum (Variant l) => Enum (TIC l) | |
Eq (Variant l) => Eq (TIC l) | |
(TypeablePolyK [*] xs, Typeable * (Variant xs), Data (Variant xs)) => Data (TIC xs) | |
Ord (Variant l) => Ord (TIC l) | |
(ReadVariant l, HAllTaggedEq l, HRLabelSet l) => Read (TIC l) | |
ShowVariant l => Show (TIC l) | TICs are not opaque |
Ix (Variant l) => Ix (TIC l) | |
Monoid (Variant l) => Monoid (TIC l) | |
Typeable ([*] -> *) TIC | |
type LabelableTy TIC = LabelablePrism | |
type HExtendR me (TIC l) = TIC ((:) * (Tagged * (UnMaybe me) (UnMaybe me)) l) |
ticVariant :: (Profunctor p, Functor f) => p (Variant t) (f (Variant l)) -> p (TIC t) (f (TIC l)) Source
Iso (TIC s) (TIC t) (Variant s) (Variant t)
typeIndexed
may be more appropriate
ticVariant' :: (Profunctor p, Functor f) => p (Variant t) (f (Variant t)) -> p (TIC t) (f (TIC t)) Source
Iso' (TIC s) (Variant s)
class TypeIndexed r tr | r -> tr, tr -> r where Source
Conversion between type indexed collections (TIC
and TIP
)
and the corresponding collection that has other label types (Variant
and Record
respectively)
See typeIndexed'
typeIndexed :: forall p f s t a b. (TypeIndexedCxt s t a b, Profunctor p, Functor f) => p (tr (TagR a)) (f (tr (TagR b))) -> p (r s) (f (r t)) Source
Iso (r s) (r t) (tr a) (tr b)
type TypeIndexedCxt s t a b = (HMapCxt HList TaggedFn b t, RecordValues s, RecordValues t, a ~ RecordValuesR s, b ~ RecordValuesR t, SameLabels s t, SameLength s t, SameLength b a, Coercible (TagR b) t, Coercible (TagR a) s, HAllTaggedLV s, HRLabelSet t, TagUntag a, TagUntag b) Source
typeIndexed' :: (TypeIndexed r tr, TagUntagFD (RecordValuesR s) (TagR (RecordValuesR s)), HLabelSet [*] (LabelsOf s), RecordValues s, HMapAux HList TaggedFn (RecordValuesR s) s, SameLength' * * (RecordValuesR s) (RecordValuesR s), SameLength' * * s s, SameLabels [*] [*] s s, HAllTaggedLV s, Profunctor p, Coercible [*] (TagR (RecordValuesR s)) s, Functor f) => p (tr (TagR (RecordValuesR s))) (f (tr (TagR (RecordValuesR s)))) -> p (r s) (f (r s)) Source
:: (HTypeIndexed l, MkVariant i i l) | |
=> i | |
-> proxy l | the ordering of types in the |
-> TIC l |
Public constructor (or, open union's injection function)
mkTIC1 :: forall i. MkVariant i i `[Tagged i i]` => i -> TIC `[Tagged i i]` Source
make a TIC that contains one element
mkTIC :: (HAllTaggedEq l, HLabelSet [*] (LabelsOf l), HasField * i (Record l) i, HFind1 * i (UnLabel * i (LabelsOf l)) n, HAllTaggedLV l, KnownNat (HNat2Nat n)) => i -> TIC l Source
make a TIC for use in contexts where the result type is fixed
class TICPrism s t a b | s a b -> t, t a b -> s where Source
similar to HPrism
ticPrism :: (SameLength s t, Choice p, Applicative f) => (a `p` f b) -> TIC s `p` f (TIC t) Source
(MkVariant * b b t, HasField * a (Variant s) (Maybe a), SameLength * * s t, HFindLabel * b t n, HFindLabel * a s n, (~) [*] (HUpdateAtHNatR n (Tagged * b b) s) t, (~) [*] (HUpdateAtHNatR n (Tagged * a a) t) s) => TICPrism s t a b |