Copyright | (C) 2004 Oleg Kiselyov Ralf Laemmel Keean Schupke |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
The HList library
This module re-exports everything needed to use HList.
Synopsis
- module Data.HList.FakePrelude
- module Data.HList.HListPrelude
- module Data.HList.HArray
- module Data.HList.HOccurs
- module Data.HList.HTypeIndexed
- module Data.HList.Record
- module Data.HList.RecordPuns
- data RecordU l
- data RecordUS (x :: [*])
- class SortForRecordUS x x' | x -> x' where
- sortForRecordUS :: Record x -> Record x'
- class HUpdateMany lv rx where
- hUpdateMany :: Record lv -> rx -> rx
- hMapRU :: HMapCxt RecordU f x y => f -> RecordU x -> RecordU y
- class HFindMany (ls :: [k]) (r :: [k]) (ns :: [HNat]) | ls r -> ns
- class HNats2Integrals (ns :: [HNat]) where
- hNats2Integrals :: Integral i => Proxy ns -> [i]
- class RecordUSCxt (x :: [*]) (u :: [*]) | x -> u, u -> x
- class HLookupByHNatUS (n :: HNat) (us :: [*]) (e :: *) | n us -> e
- class HLookupByHNatUS1 (r :: Either HNat HNat) (n :: HNat) (u :: [*]) (us :: [*]) (e :: *) | r n u us -> e
- type family HSubtract (n1 :: HNat) (n2 :: HNat) :: Either HNat HNat
- class HMapUnboxF (xs :: [*]) (us :: [*]) | xs -> us, us -> xs
- data UnboxF
- data BoxF
- data EqTagValue
- type family GetElemTy (x :: [*]) :: *
- class ElemTyEq (xs :: [*])
- class RecordToRecordU x
- class RecordUToRecord x
- data UncurrySappend = UncurrySappend
- data UncurryMappend = UncurryMappend
- data ConstMempty = ConstMempty
- class HZipList x y l | x y -> l, l -> x y where
- class HSpanEqBy2 (b :: Bool) (f :: t) (x :: *) (y :: *) (ys :: [*]) (i :: [*]) (o :: [*]) | b f x y ys -> i o where
- class HSpanEqBy1 (f :: t) (x :: *) (y :: [*]) (i :: [*]) (o :: [*]) | f x y -> i o where
- hSpanEqBy1 :: Proxy f -> x -> HList y -> (HList i, HList o)
- class HSpanEqBy (f :: t) (x :: *) (y :: [*]) (fst :: [*]) (snd :: [*]) | f x y -> fst snd, fst snd -> y where
- class HGroupBy (f :: t) (as :: [*]) (gs :: [*]) | f as -> gs, gs -> as where
- class HPartitionEq1 (b :: Bool) f x1 x xs xi xo | b f x1 x xs -> xi xo where
- class HPartitionEq f x1 xs xi xo | f x1 xs -> xi xo where
- type family HMapTail (xxs :: [*]) :: [*]
- type family HMapCons (x :: *) (xxs :: [*]) :: [*]
- data FHCons2 x = FHCons2 x
- class HInits1 a b | a -> b, b -> a where
- class HInits a b | a -> b, b -> a where
- class HTails a b | a -> b, b -> a where
- class HTuple v t | v -> t, t -> v where
- hToTuple :: HList v -> t
- hFromTuple :: t -> HList v
- class HDrop (n :: HNat) xs ys | n xs -> ys where
- class HTake (n :: HNat) xs ys | n xs -> ys where
- class HStripPrefix xs xsys ys | xs xsys -> ys
- class HStripPrefix xs xsys ys => HAppendList1 (xs :: [k]) (ys :: [k]) (xsys :: [k]) | xs ys -> xsys, xs xsys -> ys
- class HLengthGe (xs :: [*]) (n :: HNat)
- class HLengthEq2 (xs :: [*]) n | xs -> n
- class HLengthEq1 (xs :: [*]) n
- class (SameLength' (HReplicateR n ()) xs, HLengthEq1 xs n, HLengthEq2 xs n) => HLengthEq (xs :: [*]) (n :: HNat) | xs -> n
- class HSplitAt1 accum (n :: HNat) xsys xs ys | accum n xsys -> xs ys where
- class (HLengthEq xs n, HAppendList1 xs ys xsys) => HSplitAt (n :: HNat) xsys xs ys | n xsys -> xs ys, xs ys -> xsys, xs -> n where
- class HSplit l where
- data HRmTag = HRmTag
- data HAddTag t = HAddTag t
- data HFromJust = HFromJust
- class FromHJustR (ToHJustR l) ~ l => FromHJust l where
- type FromHJustR l :: [*]
- fromHJust :: HList l -> HList (FromHJustR l)
- class FromHJustR (ToHJustR l) ~ l => ToHJust l where
- class HList2List l e | l -> e where
- hList2List :: HList l -> [e]
- list2HListSuffix :: [e] -> Maybe (HList l, [e])
- class HTIntersectBool (b :: Bool) h t l1 l2 | b h t l1 -> l2 where
- hTIntersectBool :: Proxy b -> h -> HList t -> HList l1 -> HList l2
- class HTIntersect l1 l2 l3 | l1 l2 -> l3 where
- hTIntersect :: HList l1 -> HList l2 -> HList l3
- class HTMember e (l :: [*]) (b :: Bool) | e l -> b
- class HFind2 (b :: Bool) (e :: k) (l :: [k]) (l0 :: [k]) (n :: HNat) | b e l -> n
- class HFind1 (e :: k) (l :: [k]) (l0 :: [k]) (n :: HNat) | e l -> n
- class HFind1 e l l n => HFind (e :: k) (l :: [k]) (n :: HNat) | e l -> n
- class HMemberM2 (b :: Maybe [k]) (e1 :: k) (l :: [k]) (r :: Maybe [k]) | b e1 l -> r
- class HMemberM1 (b :: Bool) (e1 :: k) (l :: [k]) (r :: Maybe [k]) | b e1 l -> r
- class HMemberM (e1 :: k) (l :: [k]) (r :: Maybe [k]) | e1 l -> r
- type family HMemberP' pred e1 (l :: [*]) pb :: Bool
- type family HMemberP pred e1 (l :: [*]) :: Bool
- class HMember' (b0 :: Bool) (e1 :: k) (l :: [k]) (b :: Bool) | b0 e1 l -> b
- class HMember (e1 :: k) (l :: [k]) (b :: Bool) | e1 l -> b
- type family HNats (l :: [*]) :: [HNat]
- type HMapOut f l e = HFoldr (Mapcar f) [e] l [e]
- newtype Mapcar f = Mapcar f
- class (Applicative m, SameLength a b) => HSequence m a b | a -> b, m b -> a where
- class HMapAux (r :: [*] -> *) f (x :: [*]) (y :: [*])
- class (SameLength a b, HMapAux r f a b) => HMapCxt r f a b
- newtype HMapL f = HMapL f
- newtype HMap f = HMap f
- class HAppendFD a b ab | a b -> ab where
- class HConcatFD xxs xs | xxs -> xs where
- type family UnHList a :: [*]
- type family HConcatR (a :: [*]) :: [*]
- type HConcat xs = HConcatFD xs (HConcatR xs)
- class HLengthEq r n => HIterate n f z r where
- class HLengthEq r n => HReplicateF (n :: HNat) f z r | r -> n where
- hReplicateF :: HLengthEq r n => Proxy n -> f -> z -> HList r
- type family HReplicateR (n :: HNat) (e :: k) :: [k]
- type HReplicate n e = HReplicateFD n e (HReplicateR n e)
- class HLengthEq es n => HReplicateFD (n :: HNat) e es | n e -> es, es -> n where
- hReplicate :: Proxy n -> e -> HList es
- class HUnfoldFD p res z | p res -> z where
- type HUnfold' p res = HUnfoldFD p (ApplyR p res) (HUnfold p res)
- type family HUnfoldR p res :: [*]
- type HUnfold p s = HUnfoldR p (ApplyR p s)
- class HFoldl f (z :: *) xs (r :: *) where
- class HFoldr1 f (l :: [*]) r where
- class HScanr f z ls rs where
- class HFoldr f v (l :: [*]) r where
- class HBuild' l r where
- class HReverse xs sx | xs -> sx, sx -> xs where
- class HRevApp l1 l2 l3 | l1 l2 -> l3 where
- type family HRevAppR (l1 :: [k]) (l2 :: [k]) :: [k]
- class HAppendList l1 l2 where
- hAppendList :: HList l1 -> HList l2 -> HList (HAppendListR l1 l2)
- type family HAppendListR (l1 :: [k]) (l2 :: [k]) :: [k]
- type family HLength (x :: [k]) :: HNat
- class HInit xs where
- data ReadElement = ReadElement
- type family DropProxy (xs :: k) :: k
- type family AddProxy (xs :: k) :: k
- type HProxies xs = HProxiesFD xs (AddProxy xs)
- class HProxiesFD (xs :: [*]) pxs | pxs -> xs, xs -> pxs where
- data family HList (l :: [*])
- hHead :: HList (e ': l) -> e
- hTail :: HList (e ': l) -> HList l
- hLast :: forall (l1 :: [Type]) e (l :: [Type]). HRevApp l1 ('[] :: [Type]) (e ': l) => HList l1 -> e
- hLength :: HLengthEq l n => HList l -> Proxy n
- hReverse_ :: forall (l1 :: [Type]) (l3 :: [Type]). HRevApp l1 ('[] :: [Type]) l3 => HList l1 -> HList l3
- hEnd :: HList l -> HList l
- hBuild :: HBuild' '[] r => r
- hUnfold :: forall f a (z :: [Type]). (HUnfoldFD f (ApplyR f a) z, Apply f a) => f -> a -> HList z
- hConcat :: HConcat xs => HList xs -> HList (HConcatR xs)
- hMap :: forall (a :: [Type]) (b :: [Type]) r f. (SameLength' a b, SameLength' b a, HMapAux r f a b) => f -> r a -> r b
- hMapL :: forall (a :: [Type]) (b :: [Type]) f. (SameLength' a b, SameLength' b a, HMapAux HList f a b) => f -> HList a -> HList b
- hComposeList :: HFoldr Comp (a -> a) l (t -> a) => HList l -> t -> a
- hMapOut :: forall f e l. HMapOut f l e => f -> HList l -> [e]
- hMapM :: (Monad m, HMapOut f l (m e)) => f -> HList l -> [m e]
- hMapM_ :: (Monad m, HMapOut f l (m ())) => f -> HList l -> m ()
- hNats :: HList l -> Proxy (HNats l)
- hMember :: HMember e l b => Proxy e -> Proxy l -> Proxy b
- hTMember :: HTMember e l b => e -> HList l -> Proxy b
- list2HList :: HList2List l e => [e] -> Maybe (HList l)
- listAsHList :: forall (l1 :: [Type]) e1 (l2 :: [Type]) e2 p f. (HList2List l1 e1, HList2List l2 e2, Choice p, Applicative f) => p (HList l2) (f (HList l1)) -> p [e2] (f [e1])
- listAsHList' :: forall (l :: [Type]) e p f. (HList2List l e, Choice p, Applicative f) => p (HList l) (f (HList l)) -> p [e] (f [e])
- toHJust2 :: (HMapCxt r (HJust ()) a b, ToHJust a, b ~ ToHJustR a) => r a -> r b
- fromHJust2 :: HMapCxt r HFromJust a b => r a -> r b
- hAddTag :: forall (a :: [Type]) (b :: [Type]) r t. (SameLength' a b, SameLength' b a, HMapAux r (HAddTag t) a b) => t -> r a -> r b
- hRmTag :: forall (a :: [Type]) (b :: [Type]) r. (SameLength' a b, SameLength' b a, HMapAux r HRmTag a b) => r a -> r b
- hFlag :: forall (a :: [Type]) (b :: [Type]) r. (SameLength' a b, SameLength' b a, HMapAux r (HAddTag (Proxy 'True)) a b) => r a -> r b
- hTuple :: forall p f (v1 :: [Type]) a (v2 :: [Type]) t. (Profunctor p, Functor f, HTuple v1 a, HTuple v2 t) => p a (f t) -> p (HList v1) (f (HList v2))
- hTuple' :: forall p f (v :: [Type]) a. (Profunctor p, Functor f, HTuple v a) => p a (f a) -> p (HList v) (f (HList v))
- module Data.HList.HZip
- hSort :: HSort x y => HList x -> HList y
- type HSort x y = HSortBy HLeFn x y
- class (SameLength a b, HEqByFn le) => HSortBy le (a :: [*]) (b :: [*]) | le a -> b where
- data HLeFn
- data HDown a
- class HSetBy (HNeq HLeFn) ps => HSet (ps :: [*])
- class HEqByFn lt => HSetBy lt (ps :: [*])
- class HIsSet (ps :: [*]) (b :: Bool) | ps -> b
- class HEqByFn lt => HIsSetBy lt (ps :: [*]) (b :: Bool) | lt ps -> b
- class HEqByFn le => HAscList le (ps :: [*])
- class HEqByFn le => HIsAscList le (xs :: [*]) (b :: Bool) | le xs -> b
- class HLengthEq xs n => HCurry' (n :: HNat) f xs r | f xs -> r, r xs -> f, n f -> xs, xs -> n where
- hCurry :: forall (n :: HNat) f (xs :: [Type]) r. (HCurry' n f xs r, ArityFwd f n, ArityRev f n) => (HList xs -> r) -> f
- hUncurry :: forall (n :: HNat) f (xs :: [Type]) r. (HCurry' n f xs r, ArityFwd f n, ArityRev f n) => f -> HList xs -> r
- hCompose :: forall (xs1 :: [Type]) (xs2 :: [Type]) (xsys :: [Type]) (n1 :: HNat) f1 r (n2 :: HNat) b (n3 :: HNat) f2 x. (HAppendList1 xs1 xs2 xsys, HCurry' n1 f1 xsys r, HCurry' n2 b xs2 r, HCurry' n3 f2 xs1 x, ArityFwd b n2, ArityFwd f2 n3, ArityRev b n2, ArityRev f2 n3, HSplitAt1 ('[] :: [Type]) n3 xsys xs1 xs2) => (x -> b) -> f2 -> f1
- data TIP (l :: [*])
- emptyTIP :: TIP '[]
- tipyUpdate :: forall record v (r :: [Type]). (HUpdateAtLabel record v v r r, SameLength' r r) => v -> record r -> record r
- tipyLens :: forall (n :: HNat) x (xs1 :: [Type]) (l1 :: [Type]) a1 (xs2 :: [Type]) (b :: Bool) a2 f. (HSplitAt1 ('[] :: [Type]) n (Tagged x x ': xs1) l1 (Tagged a1 a1 ': xs2), HAppendList1 l1 (Tagged a1 a1 ': xs2) (Tagged x x ': xs1), SameLength' (HReplicateR n ()) l1, HLengthEq1 l1 n, HLengthEq2 l1 n, HEq (Label a1) (Label x) b, HFind2 b (Label a1) (LabelsOf xs1) (Label x ': LabelsOf xs1) n, HAllTaggedEq (HAppendListR l1 (Tagged a2 a2 ': xs2)), HLabelSet (LabelsOf (HAppendListR l1 (Tagged a2 a2 ': xs2))), HAllTaggedLV (HAppendListR l1 (Tagged a2 a2 ': xs2)), HAppendList l1 (Tagged a2 a2 ': xs2), Functor f) => (a1 -> f a2) -> TIP (Tagged x x ': xs1) -> f (TIP (HAppendListR l1 (Tagged a2 a2 ': xs2)))
- tipyLens' :: forall a (t :: [Type]) f. (HasField a (Record t) a, HUpdateAtLabel2 a a t t, HAllTaggedEq t, HLabelSet (LabelsOf t), HAllTaggedLV t, SameLength' t t, SameLabels t t, Functor f) => (a -> f a) -> TIP t -> f (TIP t)
- tipyProject :: forall (l :: [Type]) (ls :: [Type]) (t :: [Type]) (b :: [Type]) proxy. (HAllTaggedEq l, HLabelSet (LabelsOf l), HAllTaggedLV l, H2ProjectByLabels ls t l b) => proxy ls -> TIP t -> TIP l
- tipyProject2 :: forall (ls :: [Type]) (r :: [Type]) (l1 :: [Type]) (l2 :: [Type]) proxy. (H2ProjectByLabels ls r l1 l2, HAllTaggedEq l1, HAllTaggedEq l2, HLabelSet (LabelsOf l1), HLabelSet (LabelsOf l2), HAllTaggedLV l1, HAllTaggedLV l2) => proxy ls -> TIP r -> (TIP l1, TIP l2)
- tipyTuple :: forall b r (v1 :: [Type]) (v2 :: [Type]) a (v3 :: [Type]) (v'1 :: [Type]) (v'2 :: [Type]). (HOccurs b (r v1), HOccurs b (r v2), HOccurs a (r v2), HOccurs a (r v3), HDeleteAtLabel r b v1 v'1, HDeleteAtLabel r b v2 v3, HDeleteAtLabel r a v2 v1, HDeleteAtLabel r a v3 v'2) => r v2 -> (a, b)
- tipyTuple3 :: forall b r (v1 :: [Type]) (v2 :: [Type]) (v3 :: [Type]) c (v4 :: [Type]) (v5 :: [Type]) a (v6 :: [Type]) (v7 :: [Type]) (v'1 :: [Type]) (v'2 :: [Type]) (v'3 :: [Type]). (HOccurs b (r v1), HOccurs b (r v2), HOccurs b (r v3), HOccurs c (r v4), HOccurs c (r v3), HOccurs c (r v5), HOccurs a (r v3), HOccurs a (r v6), HOccurs a (r v7), HDeleteAtLabel r b v1 v4, HDeleteAtLabel r b v2 v'1, HDeleteAtLabel r b v3 v5, HDeleteAtLabel r c v4 v'2, HDeleteAtLabel r c v3 v6, HDeleteAtLabel r c v5 v7, HDeleteAtLabel r a v3 v1, HDeleteAtLabel r a v6 v2, HDeleteAtLabel r a v7 v'3) => r v3 -> (a, b, c)
- tipyTuple4 :: forall b r (v1 :: [Type]) (v2 :: [Type]) (v3 :: [Type]) (v4 :: [Type]) c (v5 :: [Type]) (v6 :: [Type]) (v7 :: [Type]) d (v8 :: [Type]) (v9 :: [Type]) (v10 :: [Type]) a (v11 :: [Type]) (v12 :: [Type]) (v13 :: [Type]) (v'1 :: [Type]) (v'2 :: [Type]) (v'3 :: [Type]) (v'4 :: [Type]). (HOccurs b (r v1), HOccurs b (r v2), HOccurs b (r v3), HOccurs b (r v4), HOccurs c (r v5), HOccurs c (r v6), HOccurs c (r v4), HOccurs c (r v7), HOccurs d (r v8), HOccurs d (r v4), HOccurs d (r v9), HOccurs d (r v10), HOccurs a (r v4), HOccurs a (r v11), HOccurs a (r v12), HOccurs a (r v13), HDeleteAtLabel r b v1 v5, HDeleteAtLabel r b v2 v6, HDeleteAtLabel r b v3 v'1, HDeleteAtLabel r b v4 v7, HDeleteAtLabel r c v5 v8, HDeleteAtLabel r c v6 v'2, HDeleteAtLabel r c v4 v9, HDeleteAtLabel r c v7 v10, HDeleteAtLabel r d v8 v'3, HDeleteAtLabel r d v4 v11, HDeleteAtLabel r d v9 v12, HDeleteAtLabel r d v10 v13, HDeleteAtLabel r a v4 v1, HDeleteAtLabel r a v11 v2, HDeleteAtLabel r a v12 v3, HDeleteAtLabel r a v13 v'4) => r v4 -> (a, b, c, d)
- tipyTuple5 :: forall b r (v1 :: [Type]) (v2 :: [Type]) (v3 :: [Type]) (v4 :: [Type]) (v5 :: [Type]) c (v6 :: [Type]) (v7 :: [Type]) (v8 :: [Type]) (v9 :: [Type]) d (v10 :: [Type]) (v11 :: [Type]) (v12 :: [Type]) (v13 :: [Type]) e (v14 :: [Type]) (v15 :: [Type]) (v16 :: [Type]) (v17 :: [Type]) a (v18 :: [Type]) (v19 :: [Type]) (v20 :: [Type]) (v21 :: [Type]) (v'1 :: [Type]) (v'2 :: [Type]) (v'3 :: [Type]) (v'4 :: [Type]) (v'5 :: [Type]). (HOccurs b (r v1), HOccurs b (r v2), HOccurs b (r v3), HOccurs b (r v4), HOccurs b (r v5), HOccurs c (r v6), HOccurs c (r v7), HOccurs c (r v8), HOccurs c (r v5), HOccurs c (r v9), HOccurs d (r v10), HOccurs d (r v11), HOccurs d (r v5), HOccurs d (r v12), HOccurs d (r v13), HOccurs e (r v14), HOccurs e (r v5), HOccurs e (r v15), HOccurs e (r v16), HOccurs e (r v17), HOccurs a (r v5), HOccurs a (r v18), HOccurs a (r v19), HOccurs a (r v20), HOccurs a (r v21), HDeleteAtLabel r b v1 v6, HDeleteAtLabel r b v2 v7, HDeleteAtLabel r b v3 v8, HDeleteAtLabel r b v4 v'1, HDeleteAtLabel r b v5 v9, HDeleteAtLabel r c v6 v10, HDeleteAtLabel r c v7 v11, HDeleteAtLabel r c v8 v'2, HDeleteAtLabel r c v5 v12, HDeleteAtLabel r c v9 v13, HDeleteAtLabel r d v10 v14, HDeleteAtLabel r d v11 v'3, HDeleteAtLabel r d v5 v15, HDeleteAtLabel r d v12 v16, HDeleteAtLabel r d v13 v17, HDeleteAtLabel r e v14 v'4, HDeleteAtLabel r e v5 v18, HDeleteAtLabel r e v15 v19, HDeleteAtLabel r e v16 v20, HDeleteAtLabel r e v17 v21, HDeleteAtLabel r a v5 v1, HDeleteAtLabel r a v18 v2, HDeleteAtLabel r a v19 v3, HDeleteAtLabel r a v20 v4, HDeleteAtLabel r a v21 v'5) => r v5 -> (a, b, c, d, e)
- type TagUntag xs = TagUntagFD xs (TagR xs)
- class SameLength a ta => TagUntagFD a ta | a -> ta, ta -> a where
- type family TagR (a :: [*]) :: [*]
- class TransTIP op db where
- class Monad m => TransTIPM m op db where
- data TIC (l :: [*])
- mkTIC :: forall i (l :: [Type]) (n :: HNat). (HFind1 i (UnLabel i (LabelsOf l)) (UnLabel i (LabelsOf l)) n, HasField i (Record l) i, KnownNat (HNat2Nat n), HAllTaggedLV l, HLabelSet (LabelsOf l), HAllTaggedEq l) => i -> TIC l
- mkTIC1 :: forall i. MkVariant i i '[Tagged i i] => i -> TIC '[Tagged i i]
- mkTIC' :: forall i l proxy. (HTypeIndexed l, MkVariant i i l) => i -> proxy l -> TIC l
- ticPrism :: (TICPrism s t a b, 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)
- data Variant (vs :: [*])
- mkVariant :: MkVariant x v vs => Label x -> v -> proxy vs -> Variant vs
- mkVariant1 :: forall k (l :: k) e. Label l -> e -> Variant '[Tagged l e]
- castVariant :: (RecordValuesR v ~ RecordValuesR v', SameLength v v') => Variant v -> Variant v'
- newtype HMapV f = HMapV f
- hMapV :: forall f (x :: [Type]) (y :: [Type]). (HMapAux Variant (HFmap f) x y, SameLength' x y, SameLength' y x) => f -> Variant x -> Variant y
- hMapOutV :: forall x y z f. (SameLength x y, HMapAux Variant (HFmap f) x y, Unvariant y z, HMapOutV_gety x z ~ y) => f -> Variant x -> z
- class ZipVariant x y xy | x y -> xy, xy -> x y where
- zipVariant :: Variant x -> Variant y -> Maybe (Variant xy)
- class (SameLength v v', SameLabels v v') => ZipVR fs v v' | fs v -> v' where
- zipVR :: (SameLabels fs v, SameLength fs v, ZipVR fs v v', ZipVRCxt fs v v') => Record fs -> Variant v -> Variant v'
- class (ProjectVariant x yin, ProjectVariant x yout) => SplitVariant x yin yout where
- splitVariant :: Variant x -> Either (Variant yin) (Variant yout)
- class ProjectVariant x y where
- projectVariant :: Variant x -> Maybe (Variant y)
- class (HAllTaggedLV y, HAllTaggedLV x) => ExtendsVariant x y where
- extendsVariant :: Variant x -> Variant y
- class HAllTaggedLV y => ProjectExtendVariant x y where
- projectExtendVariant :: Variant x -> Maybe (Variant y)
- class (SameLength s t, SameLabels s t) => HPrism x s t a b | x s -> a, x t -> b, x s b -> t, x t a -> s where
- unvarianted :: (Unvariant' s a, Unvariant' t b, SameLabels s t, SameLength s t, Functor f) => (a -> f b) -> Variant s -> f (Variant t)
- unvarianted' :: forall (b :: Bool) (t :: [Type]) a f. (Unvariant1 b t a, HAllEqVal' (Tagged () a ': t), HAllEqVal t b, HAllEqVal (Tagged () a ': t) b, SameLabels t t, SameLength' t t, Functor f) => (a -> f a) -> Variant t -> f (Variant t)
- splitVariant1 :: Variant (Tagged s x ': xs) -> Either x (Variant xs)
- splitVariant1' :: Variant (x ': xs) -> Either x (Variant xs)
- extendVariant :: Variant l -> Variant (e ': l)
- class Unvariant v e | v -> e where
- class Unvariant' v e | v -> e where
- unvariant' :: Variant v -> e
- 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))
- typeIndexed' :: forall r tr (t :: [Type]) p f. (TypeIndexed r tr, HMapAux HList TaggedFn (RecordValuesR t) t, RecordValues t, SameLabels t t, HAllTaggedLV t, HLabelSet (LabelsOf t), TagUntagFD (RecordValuesR t) (TagR (RecordValuesR t)), Profunctor p, Functor f, SameLength' t t, SameLength' (RecordValuesR t) (RecordValuesR t), Coercible (TagR (RecordValuesR t)) t) => p (tr (TagR (RecordValuesR t))) (f (tr (TagR (RecordValuesR t)))) -> p (r t) (f (r t))
- tipHList :: forall p f (a1 :: [Type]) (ta :: [Type]) (a2 :: [Type]) (l :: [Type]). (Profunctor p, Functor f, TagUntagFD a1 ta, TagUntagFD a2 l) => p (HList a1) (f (HList a2)) -> p (TIP ta) (f (TIP l))
- tipHList' :: forall p f (a :: [Type]) (l :: [Type]). (Profunctor p, Functor f, TagUntagFD a l) => p (HList a) (f (HList a)) -> p (TIP l) (f (TIP l))
- unboxed :: forall x y f p. (Profunctor p, Functor f, RecordToRecordU x, RecordUToRecord y) => (RecordU x `p` f (RecordU y)) -> Record x `p` f (Record y)
- unboxed' :: forall p f (y :: [Type]) (n :: HNat). (Profunctor p, Functor f, RecordValues y, HList2List (RecordValuesR y) (GetElemTy y), KnownNat (HNat2Nat n), HLengthEq1 y n, HLengthEq2 y n, IArray UArray (GetElemTy y), SameLength' (HReplicateR n ()) y, HMapAux HList TaggedFn (RecordValuesR y) y) => p (RecordU y) (f (RecordU y)) -> p (Record y) (f (Record y))
- unboxedS :: forall (g1 :: [Type]) (u1 :: [Type]) (g2 :: [Type]) (u2 :: [Type]) (x1 :: [Type]) (x2 :: [Type]) p f. (HMapUnboxF g1 u1, HMapUnboxF g2 u2, HGroupBy EqTagValue x1 g1, HGroupBy EqTagValue x2 g2, Profunctor p, Functor f, HConcatFD g1 x1, SameLength' u2 g2, SameLength' g2 u2, SameLength' u1 g1, SameLength' g1 u1, HMapAux HList UnboxF g2 u2, HMapAux HList BoxF u1 g1) => p (RecordUS x2) (f (RecordUS x1)) -> p (Record x2) (f (Record x1))
- unboxedS' :: forall (g :: [Type]) (u :: [Type]) (x :: [Type]) p f. (HMapUnboxF g u, HGroupBy EqTagValue x g, Profunctor p, Functor f, HConcatFD g x, SameLength' u g, SameLength' g u, HMapAux HList UnboxF g u, HMapAux HList BoxF u g) => p (RecordUS x) (f (RecordUS x)) -> p (Record x) (f (Record x))
- hMaybied :: forall (x :: [Type]) (v1 :: [Type]) (v2 :: [Type]) (r :: [Type]) p f. (HFoldr HMaybiedToVariantFs [Variant ('[] :: [Type])] x [Variant v1], VariantToHMaybied v2 r, VariantToHMaybied v1 x, SameLength' x r, SameLength' r x, HMapAux HList (HFmap HCastF) x r, Choice p, Applicative f) => p (Variant v1) (f (Variant v2)) -> p (Record x) (f (Record r))
- hMaybied' :: forall (x :: [Type]) (v :: [Type]) p f. (HFoldr HMaybiedToVariantFs [Variant ('[] :: [Type])] x [Variant v], VariantToHMaybied v x, SameLength' x x, HMapAux HList (HFmap HCastF) x x, Choice p, Applicative f) => p (Variant v) (f (Variant v)) -> p (Record x) (f (Record x))
- ticVariant :: forall p f (l1 :: [Type]) (l2 :: [Type]). (Profunctor p, Functor f) => p (Variant l1) (f (Variant l2)) -> p (TIC l1) (f (TIC l2))
- ticVariant' :: forall p f (l :: [Type]). (Profunctor p, Functor f) => p (Variant l) (f (Variant l)) -> p (TIC l) (f (TIC l))
- tipRecord :: forall p f (r :: [Type]) (l :: [Type]). (Profunctor p, Functor f) => p (Record r) (f (Record l)) -> p (TIP r) (f (TIP l))
- tipRecord' :: forall p f (l :: [Type]). (Profunctor p, Functor f) => p (Record l) (f (Record l)) -> p (TIP l) (f (TIP l))
- class VariantToHMaybied v r | v -> r, r -> v where
- variantToHMaybied :: Variant v -> Record r
- data HMaybiedToVariantFs
- hMaybiedToVariants :: (HFoldr HMaybiedToVariantFs [Variant '[]] r [Variant v], VariantToHMaybied v r) => Record r -> [Variant v]
- class Kw (fn :: *) (arg_def :: [*]) r where
- recToKW :: forall a b. (HMapCxt HList TaggedToKW a b, HConcat b) => Record a -> HList (HConcatR b)
- class IsKeyFN (t :: *) (flag :: Bool) | t -> flag
- data K s (c :: *)
- data ErrReqdArgNotFound x
- data ErrUnexpectedKW x
- class Projected r s t a b where
- projected :: (ty ~ LabelableTy r, LabeledOpticP ty p, LabeledOpticF ty f) => (r a `p` f (r b)) -> r s `p` f (r t)
- toLabel :: EnsureLabel x y => x -> y
- class SameLength s t => Labelable (x :: k) (r :: [*] -> *) s t a b | x s -> a, x t -> b, x s b -> t, x t a -> s where
- type LabelableTy r :: LabeledOpticType
- hLens' :: Label x -> LabeledOptic x r s t a b
- type LabeledOptic (x :: k) (r :: [*] -> *) (s :: [*]) (t :: [*]) (a :: *) (b :: *) = forall ty to p f. (ty ~ LabelableTy r, LabeledOpticF ty f, LabeledOpticP ty p, LabeledOpticTo ty x to) => (a `p` f b) `to` (r s `p` f (r t))
- (.==.) :: forall k x (l :: k) v. EnsureLabel x (Label l) => x -> v -> Tagged l v
- projected' :: forall r p f (t :: [Type]) (b :: [Type]). (LabeledOpticP (LabelableTy r) p, LabeledOpticF (LabelableTy r) f, Projected r t t b b) => p (r b) (f (r b)) -> p (r t) (f (r t))
- dredge :: forall k1 k2 (vs1 :: [Type]) (ns1 :: [[Type]]) (vs :: [Type]) (ns :: [[Type]]) (xs :: [Type]) p v (fb :: k1) r (rft :: k1) (l :: k2) (ns2 :: [[Type]]) x. (SameLength' vs1 ns1, SameLength' vs ns, SameLength' ns1 vs1, SameLength' ns vs, LabelablePath xs (p v fb) (p r rft), MapFieldTree (TryCollectionListTF r) ns, MapFieldTreeVal r (TryCollectionListTF r) vs, FilterLastEq (Label l) ns ns ns1, FilterLastEq (Label l) ns vs vs1, FilterVEq1 v vs1 ns1 ns2, HGuardNonNull (NamesDontMatch r ns l) ns1, HSingleton (NonUnique r v l) (TypesDontMatch r ns1 vs1 v) ns2 xs, EnsureLabel x (Label l)) => x -> p v fb -> p r rft
- dredge' :: forall k2 k (vs1 :: [Type]) (ns1 :: [[Type]]) (vs :: [Type]) (ns :: [[Type]]) (xs :: [Type]) p a (f :: Type -> k2) s (l :: k) (ns2 :: [[Type]]) x. (SameLength' vs1 ns1, SameLength' vs ns, SameLength' ns1 vs1, SameLength' ns vs, LabelablePath xs (p a (f a)) (p s (f s)), MapFieldTree (TryCollectionListTF s) ns, MapFieldTreeVal s (TryCollectionListTF s) vs, FilterLastEq (Label l) ns ns ns1, FilterLastEq (Label l) ns vs vs1, FilterVEq1 a vs1 ns1 ns2, HGuardNonNull (NamesDontMatch s ns l) ns1, HSingleton (NonUnique s a l) (TypesDontMatch s ns1 vs1 a) ns2 xs, EnsureLabel x (Label l)) => x -> p a (f a) -> p s (f s)
- dredgeND :: forall k1 k2 (xs :: [Type]) p a (fb :: k1) r (rft :: k1) (ns :: [[Type]]) (l :: k2) (ns' :: [[Type]]) x. (LabelablePath xs (p a fb) (p r rft), MapFieldTree (TryCollectionListTF r) ns, FilterLastEq (Label l) ns ns ns', HSingleton (NonUnique' r l) (NamesDontMatch r ns l) ns' xs, EnsureLabel x (Label l)) => x -> p a fb -> p r rft
- dredgeND' :: forall k2 k (xs :: [Type]) p a (f :: Type -> k2) s (ns :: [[Type]]) (l :: k) (ns' :: [[Type]]) x. (LabelablePath xs (p a (f a)) (p s (f s)), MapFieldTree (TryCollectionListTF s) ns, FilterLastEq (Label l) ns ns ns', HSingleton (NonUnique' s l) (NamesDontMatch s ns l) ns' xs, EnsureLabel x (Label l)) => x -> p a (f a) -> p s (f s)
- dredgeTI' :: forall k2 (xs :: [Type]) p a (f :: Type -> k2) s (ns :: [[Type]]) (ns' :: [[Type]]) q. (LabelablePath xs (p a (f a)) (p s (f s)), MapFieldTree (TryCollectionListTF s) ns, FilterLastEq (Label a) ns ns ns', HSingleton (NonUnique' s a) (NamesDontMatch s ns a) ns' xs) => q a -> p a (f a) -> p s (f s)
- hLookupByLabelDredge :: forall k (ls :: [Type]) r1 r2 v (ns :: [[Type]]) (l :: k) (ns' :: [[Type]]). (HasFieldPath 'False ls (r1 r2) v, MapFieldTree (TryCollectionListTF r2) ns, FilterLastEq (Label l) ns ns ns', HSingleton (NonUnique' r2 l) (NamesDontMatch r2 ns l) ns' ls) => Label l -> r1 r2 -> v
- class HasFieldPath (needJust :: Bool) (ls :: [*]) r v | needJust ls r -> v
- type family AddLabel (x :: k) :: * where ...
- data Lbl (x :: HNat) (ns :: *) (desc :: *)
- firstLabel :: ns -> desc -> Label (Lbl HZero ns desc)
- nextLabel :: Label (Lbl x ns desc) -> desc' -> Label (Lbl (HSucc x) ns desc')
- module Data.HList.MakeLabels
- class TupleType (t :: *) (b :: Bool) | t -> b
- class HAllTaggedEq (l :: [*])
Faking dependent types in Haskell
module Data.HList.FakePrelude
Functions for all collections
module Data.HList.HListPrelude
Array-like access to HLists
module Data.HList.HArray
Result-type-driven operations
module Data.HList.HOccurs
Type-indexed operations
module Data.HList.HTypeIndexed
Record
module Data.HList.Record
quasiquoter pun
helps to avoid needing a proxy value with
type Label
in the first place: when you take values out of or into
records with pattern matching, the variable name determines the label
name.
module Data.HList.RecordPuns
Unpacked / Unboxed Records
A type which behaves similarly to Record
, except
all elements must fit in the same UArray
. A consequence of
this is that RecordU
has the following properties:
- it is strict in the element types
- it cannot do type-changing updates of
RecordU
, except if the function applies to all elements - it probably is slower to update the very first elements
of the
RecordU
The benefit is that lookups should be faster and records
should take up less space. However benchmarks done with
a slow HNat2Integral
do not suggest that RecordU is
faster than Record.
Instances
data RecordUS (x :: [*]) Source #
RecordUS
is stored as a HList
of RecordU
to allow the RecordUS
to contain elements of different
types, so long all of the types can be put into an unboxed
array (UArray
).
It is advantageous (at least space-wise) to sort the record to keep
elements with the same types elements adjacent. See SortForRecordUS
for more details.
Instances
(HFindLabel l r n, HLookupByHNatUS n u (Tagged l v), HasField l (Record r) v, RecordUSCxt r u) => HasField (l :: k) (RecordUS r) v Source # | works expected. See examples attached to |
Defined in Data.HList.RecordU hLookupByLabel :: Label l -> RecordUS r -> v Source # | |
(RecordUSCxt x u, Show (HList u)) => Show (RecordUS x) Source # | |
class SortForRecordUS x x' | x -> x' where Source #
Reorders a Record
such that the RecordUS
made from it takes up
less space
Bad
has alternating Double and Int fields
>>>
bad
Record{x=1.0,i=2,y=3.0,j=4}
4 arrays containing one element each are needed when this Record is stored as a RecordUS
>>>
recordToRecordUS bad
RecordUS H[RecordU (array (0,0) [(0,1.0)]),RecordU (array (0,0) [(0,2)]),RecordU (array (0,0) [(0,3.0)]),RecordU (array (0,0) [(0,4)])]
It is possible to sort the record
>>>
sortForRecordUS bad
Record{x=1.0,y=3.0,i=2,j=4}
This allows the same content to be stored in two unboxed arrays
>>>
recordToRecordUS (sortForRecordUS bad)
RecordUS H[RecordU (array (0,1) [(0,1.0),(1,3.0)]),RecordU (array (0,1) [(0,2),(1,4)])]
sortForRecordUS :: Record x -> Record x' Source #
Instances
SortForRecordUS ('[] :: [Type]) ('[] :: [Type]) Source # | |
Defined in Data.HList.RecordU sortForRecordUS :: Record '[] -> Record '[] Source # | |
(HPartitionEq EqTagValue x (x ': xs) xi xo, SortForRecordUS xo xo', sorted ~ HAppendListR xi xo', HAppendList xi xo') => SortForRecordUS (x ': xs) sorted Source # | |
Defined in Data.HList.RecordU sortForRecordUS :: Record (x ': xs) -> Record sorted Source # |
class HUpdateMany lv rx where Source #
analogous flip //
. Similar to .<++.
, except it is restricted
to cases where the left argument holds a subset of elements.
hUpdateMany :: Record lv -> rx -> rx Source #
Instances
(HLeftUnion lv x lvx, HRLabelSet x, HLabelSet (LabelsOf x), HRearrange (LabelsOf x) lvx x) => HUpdateMany lv (Record x) Source # | implementation in terms of |
Defined in Data.HList.RecordU | |
(RecordValues lv, HList2List (RecordValuesR lv) v, HFindMany (LabelsOf lv) (LabelsOf r) ixs, IArray UArray v, v ~ GetElemTy r, HNats2Integrals ixs) => HUpdateMany lv (RecordU r) Source # | |
Defined in Data.HList.RecordU |
internals for types
class HNats2Integrals (ns :: [HNat]) where Source #
hNats2Integrals :: Integral i => Proxy ns -> [i] Source #
Instances
HNats2Integrals ('[] :: [HNat]) Source # | |
Defined in Data.HList.FakePrelude hNats2Integrals :: Integral i => Proxy '[] -> [i] Source # | |
(HNats2Integrals ns, HNat2Integral n) => HNats2Integrals (n ': ns) Source # | |
Defined in Data.HList.FakePrelude hNats2Integrals :: Integral i => Proxy (n ': ns) -> [i] Source # |
class RecordUSCxt (x :: [*]) (u :: [*]) | x -> u, u -> x Source #
connect the unpacked x
representation with the
corresponding list of RecordU u
representation.
Instances
(HGroupBy EqTagValue x g, HMapUnboxF g u) => RecordUSCxt x u Source # | the only instance |
Defined in Data.HList.RecordU recordUSToHList :: RecordUS x -> HList u Source # hListToRecordUS :: HList u -> RecordUS x Source # |
class HLookupByHNatUS (n :: HNat) (us :: [*]) (e :: *) | n us -> e Source #
Instances
(r ~ HSubtract (HLength u) n, RecordU u ~ ru, HLookupByHNatUS1 r n u us e) => HLookupByHNatUS n (ru ': us) e Source # | |
Defined in Data.HList.RecordU hLookupByHNatUS :: Proxy n -> HList (ru ': us) -> e Source # |
class HLookupByHNatUS1 (r :: Either HNat HNat) (n :: HNat) (u :: [*]) (us :: [*]) (e :: *) | r n u us -> e Source #
Instances
(HNat2Integral n, HLookupByHNatR n u ~ le, le ~ Tagged l e, IArray UArray e, e ~ GetElemTy u) => HLookupByHNatUS1 ('Left t :: Either HNat HNat) n u us le Source # | |
Defined in Data.HList.RecordU | |
HLookupByHNatUS t us e => HLookupByHNatUS1 ('Right t :: Either HNat HNat) n u us e Source # | |
Defined in Data.HList.RecordU |
type family HSubtract (n1 :: HNat) (n2 :: HNat) :: Either HNat HNat Source #
HSubtract a b
is Left (a-b)
, Right (b-a)
or Right HZero
class HMapUnboxF (xs :: [*]) (us :: [*]) | xs -> us, us -> xs Source #
Instances
HMapUnboxF ('[] :: [Type]) ('[] :: [Type]) Source # | |
Defined in Data.HList.RecordU | |
HMapUnboxF xs us => HMapUnboxF (HList x ': xs) (RecordU x ': us) Source # | |
Defined in Data.HList.RecordU |
data EqTagValue Source #
Instances
HEqByFn EqTagValue Source # | |
Defined in Data.HList.RecordU | |
(txv ~ Tagged x v, tyw ~ Tagged y w, HEq v w b) => HEqBy EqTagValue (txv :: Type) (tyw :: Type) b Source # | |
Defined in Data.HList.RecordU |
class RecordToRecordU x Source #
Instances
(RecordValues x, HList2List (RecordValuesR x) (GetElemTy x), HNat2Integral n, HLengthEq x n, IArray UArray (GetElemTy x)) => RecordToRecordU x Source # | |
Defined in Data.HList.RecordU recordToRecordU :: Record x -> RecordU x Source # |
class RecordUToRecord x Source #
Instances
(HMapCxt HList TaggedFn (RecordValuesR x) x, IArray UArray (GetElemTy x), HList2List (RecordValuesR x) (GetElemTy x)) => RecordUToRecord x Source # | |
Defined in Data.HList.RecordU recordUToRecord :: RecordU x -> Record x Source # |
HList
A subset of Data.HList.HList is re-exported.
data UncurrySappend Source #
Instances
(aa ~ (a, a), Semigroup a) => ApplyAB UncurrySappend aa a Source # | |
Defined in Data.HList.HList applyAB :: UncurrySappend -> aa -> a Source # |
data UncurryMappend Source #
Instances
(aa ~ (a, a), Monoid a) => ApplyAB UncurryMappend aa a Source # | |
Defined in Data.HList.HList applyAB :: UncurryMappend -> aa -> a Source # |
data ConstMempty Source #
Instances
(x ~ Proxy y, Monoid y) => ApplyAB ConstMempty x y Source # | |
Defined in Data.HList.HList applyAB :: ConstMempty -> x -> y Source # |
class HSpanEqBy2 (b :: Bool) (f :: t) (x :: *) (y :: *) (ys :: [*]) (i :: [*]) (o :: [*]) | b f x y ys -> i o where Source #
Instances
HSpanEqBy2 'False (f :: t) x y ys ('[] :: [Type]) (y ': ys) Source # | |
Defined in Data.HList.HList | |
HSpanEqBy1 f x zs i o => HSpanEqBy2 'True (f :: t) x y zs (y ': i) o Source # | |
Defined in Data.HList.HList |
class HSpanEqBy1 (f :: t) (x :: *) (y :: [*]) (i :: [*]) (o :: [*]) | f x y -> i o where Source #
Instances
HSpanEqBy1 (f :: t) x ('[] :: [Type]) ('[] :: [Type]) ('[] :: [Type]) Source # | |
Defined in Data.HList.HList | |
(HEqBy f x y b, HSpanEqBy2 b f x y ys i o) => HSpanEqBy1 (f :: t) x (y ': ys) i o Source # | |
Defined in Data.HList.HList |
class HSpanEqBy (f :: t) (x :: *) (y :: [*]) (fst :: [*]) (snd :: [*]) | f x y -> fst snd, fst snd -> y where Source #
HSpanEq x y fst snd
is analogous to (fst,snd) =
span
(== x) y
Instances
(HSpanEqBy1 f x y fst snd, HAppendListR fst snd ~ y) => HSpanEqBy (f :: t) x y fst snd Source # | |
class HGroupBy (f :: t) (as :: [*]) (gs :: [*]) | f as -> gs, gs -> as where Source #
class HPartitionEq1 (b :: Bool) f x1 x xs xi xo | b f x1 x xs -> xi xo where Source #
Instances
HPartitionEq f x1 xs xi xo => HPartitionEq1 'False (f :: k1) (x1 :: k2) x xs xi (x ': xo) Source # | |
HPartitionEq f x1 xs xi xo => HPartitionEq1 'True (f :: k1) (x1 :: k2) x xs (x ': xi) xo Source # | |
class HPartitionEq f x1 xs xi xo | f x1 xs -> xi xo where Source #
HPartitionEq f x1 xs xi xo
is analogous to
(xi,xo) = partition (f x1) xs
where f
is a "function" passed in using it's instance of HEqBy
Instances
HPartitionEq (f :: k1) (x1 :: k2) ('[] :: [Type]) ('[] :: [Type]) ('[] :: [Type]) Source # | |
Defined in Data.HList.HList | |
(HEqBy f x1 x b, HPartitionEq1 b f x1 x xs xi xo) => HPartitionEq (f :: k) (x1 :: Type) (x ': xs) xi xo Source # | |
Defined in Data.HList.HList |
class HInits1 a b | a -> b, b -> a where Source #
behaves like tail . inits
class HTuple v t | v -> t, t -> v where Source #
Instances
HTuple ('[] :: [Type]) () Source # | |
Defined in Data.HList.HList | |
HTuple '[a, b] (a, b) Source # | |
Defined in Data.HList.HList | |
HTuple '[a, b, c] (a, b, c) Source # | |
Defined in Data.HList.HList | |
HTuple '[a, b, c, d] (a, b, c, d) Source # | |
Defined in Data.HList.HList | |
HTuple '[a, b, c, d, e] (a, b, c, d, e) Source # | |
Defined in Data.HList.HList | |
HTuple '[a, b, c, d, e, f] (a, b, c, d, e, f) Source # | |
Defined in Data.HList.HList |
class HStripPrefix xs xsys ys | xs xsys -> ys Source #
analog of stripPrefix
Instances
HStripPrefix ('[] :: [k2]) (ys :: k1) (ys :: k1) Source # | |
Defined in Data.HList.HList | |
(x' ~ x, HStripPrefix xs xsys ys) => HStripPrefix (x' ': xs :: [a]) (x ': xsys :: [a]) (ys :: k) Source # | |
Defined in Data.HList.HList |
class HStripPrefix xs xsys ys => HAppendList1 (xs :: [k]) (ys :: [k]) (xsys :: [k]) | xs ys -> xsys, xs xsys -> ys Source #
HAppendList1 xs ys xsys
is the type-level way of saying xs ++ ys == xsys
used by HSplitAt
Instances
HAppendList1 ('[] :: [k]) (ys :: [k]) (ys :: [k]) Source # | |
Defined in Data.HList.HList | |
HAppendList1 xs ys zs => HAppendList1 (x ': xs :: [a]) (ys :: [a]) (x ': zs :: [a]) Source # | |
Defined in Data.HList.HList |
class HLengthGe (xs :: [*]) (n :: HNat) Source #
HLengthGe xs n
says that HLength xs >= n
.
unlike the expression with a type family HLength,
ghc assumes xs ~ (aFresh ': bFresh)
when given a
constraint HLengthGe xs (HSucc HZero)
class HLengthEq2 (xs :: [*]) n | xs -> n Source #
Instances
zero ~ 'HZero => HLengthEq2 ('[] :: [Type]) (zero :: HNat) Source # | |
Defined in Data.HList.HList | |
(HLengthEq xs n, sn ~ 'HSucc n) => HLengthEq2 (x ': xs) (sn :: HNat) Source # | |
Defined in Data.HList.HList |
class HLengthEq1 (xs :: [*]) n Source #
Instances
xxs ~ ('[] :: [Type]) => HLengthEq1 xxs 'HZero Source # | |
Defined in Data.HList.HList | |
(HLengthEq xs n, xxs ~ (x ': xs)) => HLengthEq1 xxs ('HSucc n :: HNat) Source # | |
Defined in Data.HList.HList |
class (SameLength' (HReplicateR n ()) xs, HLengthEq1 xs n, HLengthEq2 xs n) => HLengthEq (xs :: [*]) (n :: HNat) | xs -> n Source #
a better way to write HLength xs ~ n
because:
- it works properly with ghc-7.10 (probably another example of ghc bug #10009)
- it works backwards a bit in that if
n
is known, thenxs
can be refined:
>>>
undefined :: HLengthEq xs HZero => HList xs
H[]
Instances
(SameLength' (HReplicateR n ()) xs, HLengthEq1 xs n, HLengthEq2 xs n) => HLengthEq xs n Source # | |
Defined in Data.HList.HList |
class HSplitAt1 accum (n :: HNat) xsys xs ys | accum n xsys -> xs ys where Source #
helper for HSplitAt
class (HLengthEq xs n, HAppendList1 xs ys xsys) => HSplitAt (n :: HNat) xsys xs ys | n xsys -> xs ys, xs ys -> xsys, xs -> n where Source #
setup
>>>
let two = hSucc (hSucc hZero)
>>>
let xsys = hEnd $ hBuild 1 2 3 4
If a length is explicitly provided, the resulting lists are inferred
>>>
hSplitAt two xsys
(H[1,2],H[3,4])
>>>
let sameLength_ :: SameLength a b => r a -> r b -> r a; sameLength_ = const
>>>
let len2 x = x `sameLength_` HCons () (HCons () HNil)
If the first chunk of the list (a) has to be a certain length, the type of the Proxy argument can be inferred.
>>>
case hSplitAt Proxy xsys of (a,b) -> (len2 a, b)
(H[1,2],H[3,4])
Analogus to Data.List.partition
snd
. See also HPartition
>>>
let (.=.) :: p x -> y -> Tagged x y; _ .=. y = Tagged y
>>>
hSplit $ hTrue .=. 2 .*. hTrue .=. 3 .*. hFalse .=. 1 .*. HNil
(H[2,3],H[1])
it might make more sense to instead have LVPair Bool e
instead of (e, Proxy Bool)
since the former has the same
runtime representation as e
HAddTag t |
class FromHJustR (ToHJustR l) ~ l => FromHJust l where Source #
type FromHJustR l :: [*] Source #
Instances
FromHJust ('[] :: [Type]) Source # | |
Defined in Data.HList.HList type FromHJustR '[] :: [Type] Source # | |
FromHJust l => FromHJust (HJust e ': l) Source # | |
Defined in Data.HList.HList type FromHJustR (HJust e ': l) :: [Type] Source # | |
FromHJust l => FromHJust (HNothing ': l) Source # | |
Defined in Data.HList.HList type FromHJustR (HNothing ': l) :: [Type] Source # |
class FromHJustR (ToHJustR l) ~ l => ToHJust l where Source #
the same as map Just
>>>
toHJust (2 .*. 'a' .*. HNil)
H[HJust 2,HJust 'a']
>>>
toHJust2 (2 .*. 'a' .*. HNil)
H[HJust 2,HJust 'a']
class HList2List l e | l -> e where Source #
hMapOut id
is similar, except this function is restricted
to HLists that actually contain a value (so the list produced
will be nonempty). This restriction allows adding a functional
dependency, which means that less type annotations can be necessary.
hList2List :: HList l -> [e] Source #
list2HListSuffix :: [e] -> Maybe (HList l, [e]) Source #
Instances
HList2List (e' ': l) e => HList2List (e ': (e' ': l)) e Source # | |
Defined in Data.HList.HList hList2List :: HList (e ': (e' ': l)) -> [e] Source # list2HListSuffix :: [e] -> Maybe (HList (e ': (e' ': l)), [e]) Source # | |
HList2List '[e] e Source # | |
Defined in Data.HList.HList hList2List :: HList '[e] -> [e] Source # list2HListSuffix :: [e] -> Maybe (HList '[e], [e]) Source # |
class HTIntersectBool (b :: Bool) h t l1 l2 | b h t l1 -> l2 where Source #
Instances
HTIntersect t l1 l2 => HTIntersectBool 'False h t l1 l2 Source # | |
Defined in Data.HList.HList | |
HTIntersect t l1 l2 => HTIntersectBool 'True h t l1 (h ': l2) Source # | |
Defined in Data.HList.HList |
class HTIntersect l1 l2 l3 | l1 l2 -> l3 where Source #
Instances
HTIntersect ('[] :: [Type]) l ('[] :: [Type]) Source # | |
Defined in Data.HList.HList | |
(HTMember h l1 b, HTIntersectBool b h t l1 l2) => HTIntersect (h ': t) l1 l2 Source # | |
Defined in Data.HList.HList |
class HTMember e (l :: [*]) (b :: Bool) | e l -> b Source #
could be an associated type if HEq had one
class HFind1 (e :: k) (l :: [k]) (l0 :: [k]) (n :: HNat) | e l -> n Source #
Instances
Fail (FieldNotFound e1 l0) => HFind1 (e1 :: k) ('[] :: [k]) (l0 :: [k]) 'HZero Source # | |
Defined in Data.HList.HList | |
(HEq e1 e2 b, HFind2 b e1 l l0 n) => HFind1 (e1 :: a) (e2 ': l :: [a]) (l0 :: [a]) n Source # | |
Defined in Data.HList.HList |
class HFind1 e l l n => HFind (e :: k) (l :: [k]) (n :: HNat) | e l -> n Source #
It is a pure type-level operation
Instances
HFind1 e l l n => HFind (e :: k) (l :: [k]) n Source # | |
Defined in Data.HList.HList |
class HMemberM (e1 :: k) (l :: [k]) (r :: Maybe [k]) | e1 l -> r Source #
Check to see if an element e occurs in a list l If not, return 'Nothing If the element does occur, return 'Just l1 where l1 is a type-level list without e
type family HMemberP pred e1 (l :: [*]) :: Bool Source #
The following is a similar type-only membership test It uses the user-supplied curried type equality predicate pred
class HMember (e1 :: k) (l :: [k]) (b :: Bool) | e1 l -> b Source #
Check to see if an HList contains an element with a given type This is a type-level only test
type family HNats (l :: [*]) :: [HNat] Source #
We do so constructively, converting the HList whose elements are Proxy HNat to [HNat]. The latter kind is unpopulated and is present only at the type level.
Mapcar f |
class (Applicative m, SameLength a b) => HSequence m a b | a -> b, m b -> a where Source #
A heterogeneous version of
sequenceA :: (Applicative m) => [m a] -> m [a]
Only now we operate on heterogeneous lists, where different elements
may have different types a
.
In the argument list of monadic values (m a_i),
although a_i may differ, the monad m
must be the same for all
elements. That's why we needed Data.HList.TypeCastGeneric2 (currently (~)).
The typechecker will complain
if we attempt to use hSequence on a HList of monadic values with different
monads.
The hSequence
problem was posed by Matthias Fischmann
in his message on the Haskell-Cafe list on Oct 8, 2006
http://www.haskell.org/pipermail/haskell-cafe/2006-October/018708.html
http://www.haskell.org/pipermail/haskell-cafe/2006-October/018784.html
Maybe
>>>
hSequence $ Just (1 :: Integer) `HCons` (Just 'c') `HCons` HNil
Just H[1,'c']
>>>
hSequence $ return 1 `HCons` Just 'c' `HCons` HNil
Just H[1,'c']
List
>>>
hSequence $ [1] `HCons` ['c'] `HCons` HNil
[H[1,'c']]
class HMapAux (r :: [*] -> *) f (x :: [*]) (y :: [*]) Source #
Instances
HMapAux HList (HFmap f) x y => HMapAux Record f x y Source # | |
HMapAux Variant f xs ys => HMapAux TIC f xs ys Source # | |
(ApplyAB f (GetElemTy x) (GetElemTy y), IArray UArray (GetElemTy y), IArray UArray (GetElemTy x)) => HMapAux RecordU f x y Source # | |
HMapAux HList f ('[] :: [Type]) ('[] :: [Type]) Source # | |
(ApplyAB f e e', HMapAux HList f l l', SameLength l l') => HMapAux HList f (e ': l) (e' ': l') Source # | |
(ApplyAB f te te', HMapCxt Variant f (l ': ls) (l' ': ls')) => HMapAux Variant f (te ': (l ': ls)) (te' ': (l' ': ls')) Source # | |
ApplyAB f te te' => HMapAux Variant f '[te] '[te'] Source # | |
class (SameLength a b, HMapAux r f a b) => HMapCxt r f a b Source #
Instances
(SameLength a b, HMapAux r f a b) => HMapCxt r f a b Source # | |
Defined in Data.HList.HList |
HMapL f |
hMap is written such that the length of the result list can be determined from the length of the argument list (and the other way around). Similarly, the type of the elements of the list is propagated in both directions too.
>>>
:set -XNoMonomorphismRestriction
>>>
let xs = 1 .*. 'c' .*. HNil
>>>
:t hMap (HJust ()) xs
hMap (HJust ()) xs :: Num y => HList '[HJust y, HJust Char]
These 4 examples show that the constraint on the length (2 in this case)
can be applied before or after the hMap
. That inference is independent of the
direction that type information is propagated for the individual elements.
>>>
let asLen2 xs = xs `asTypeOf` (undefined :: HList '[a,b])
>>>
let lr xs = asLen2 (applyAB (HMap HRead) xs)
>>>
let ls xs = asLen2 (applyAB (HMap HShow) xs)
>>>
let rl xs = applyAB (HMap HRead) (asLen2 xs)
>>>
let sl xs = applyAB (HMap HShow) (asLen2 xs)
>>>
:t lr
lr :: (Read ..., Read ...) => HList '[String, String] -> HList '[..., ...]
>>>
:t rl
rl :: (Read ..., Read ...) => HList '[String, String] -> HList '[..., ...]
>>>
:t ls
ls :: (Show ..., Show ...) => HList '[..., ...] -> HList '[String, String]
>>>
:t sl
sl :: (Show ..., Show ...) => HList '[..., ...] -> HList '[String, String]
HMap f |
type HConcat xs = HConcatFD xs (HConcatR xs) Source #
Like concat
but for HLists of HLists.
Works in ghci... puzzling as what is different in doctest (it isn't
-XExtendedDefaultRules
)
>>>
let a = hEnd $ hBuild 1 2 3
>>>
let b = hEnd $ hBuild 'a' "abc"
>>>
hConcat $ hBuild a b
H[1,2,3,'a',"abc"]
class HLengthEq r n => HIterate n f z r where Source #
This function behaves like iterate
, with an extra
argument to help figure out the result length
>>>
let three = hSucc (hSucc (hSucc hZero))
>>>
let f = Fun Just :: Fun '() Maybe
>>>
:t applyAB f
applyAB f :: a -> Maybe a
f is applied to different types:
>>>
hIterate three f ()
H[(),Just (),Just (Just ())]
It is also possible to specify the length later on,
as done with Prelude.iterate
>>>
let take3 x | _ <- hLength x `asTypeOf` three = x
>>>
take3 $ hIterate Proxy f ()
H[(),Just (),Just (Just ())]
class HLengthEq r n => HReplicateF (n :: HNat) f z r | r -> n where Source #
HReplicate produces lists that can be converted to ordinary lists
>>>
let two = hSucc (hSucc hZero)
>>>
let f = Fun' fromInteger :: Fun' Num Integer
>>>
:t applyAB f
applyAB f :: Num b => Integer -> b
>>>
hReplicateF two f 3
H[3,3]
>>>
hReplicateF Proxy f 3 :: HList [Int, Double, Integer]
H[3,3.0,3]
Instances
HReplicateF 'HZero f z ('[] :: [Type]) Source # | |
Defined in Data.HList.HList | |
(ApplyAB f z fz, HReplicateF n f z r') => HReplicateF ('HSucc n) f z (fz ': r') Source # | |
Defined in Data.HList.HList |
type family HReplicateR (n :: HNat) (e :: k) :: [k] Source #
would be associated with HReplicate
except we want
it to work with e
of any kind, not just *
that you can
put into a HList. An "inverse" of HLength
Instances
type HReplicateR 'HZero (e :: k) Source # | |
Defined in Data.HList.HList | |
type HReplicateR ('HSucc n) (e :: k) Source # | |
Defined in Data.HList.HList |
type HReplicate n e = HReplicateFD n e (HReplicateR n e) Source #
class HLengthEq es n => HReplicateFD (n :: HNat) e es | n e -> es, es -> n where Source #
Sometimes the result type can fix the type of the first argument:
>>>
hReplicate Proxy () :: HList '[ (), (), () ]
H[(),(),()]
However, with HReplicate all elements must have the same type, so it may be
easier to use HList2List
:
>>>
list2HList (repeat 3) :: Maybe (HList [Int, Int, Int])
Just H[3,3,3]
hReplicate :: Proxy n -> e -> HList es Source #
Instances
HReplicateFD 'HZero e ('[] :: [Type]) Source # | |
Defined in Data.HList.HList | |
(HReplicateFD n e es, e ~ e') => HReplicateFD ('HSucc n) e (e' ': es) Source # | |
Defined in Data.HList.HList |
class HFoldl f (z :: *) xs (r :: *) where Source #
like foldl
>>>
hFoldl (uncurry $ flip (:)) [] (1 `HCons` 2 `HCons` HNil)
[2,1]
class HBuild' l r where Source #
Instances
HReverse l l' => HBuild' l (HList l') Source # | |
(HReverse l lRev, HMapTaggedFn lRev l') => HBuild' l (Record l') Source # | This instance allows creating a Record with hBuild 3 |
HBuild' (a ': l) r => HBuild' l (a -> r) Source # | |
Defined in Data.HList.HList | |
(HRevAppR l ('[] :: [Type]) ~ lRev, HExtendRs lRev (Proxy ('[] :: [Type])) ~ Proxy l1, l' ~ l1) => HBuild' l (Proxy l') Source # | see |
class HAppendList l1 l2 where Source #
hAppendList :: HList l1 -> HList l2 -> HList (HAppendListR l1 l2) Source #
the same as hAppend
Instances
HAppendList ('[] :: [Type]) l2 Source # | |
Defined in Data.HList.HList hAppendList :: HList '[] -> HList l2 -> HList (HAppendListR '[] l2) Source # | |
HAppendList l l' => HAppendList (x ': l) l' Source # | |
Defined in Data.HList.HList hAppendList :: HList (x ': l) -> HList l' -> HList (HAppendListR (x ': l) l') Source # |
type family HAppendListR (l1 :: [k]) (l2 :: [k]) :: [k] Source #
Instances
type HAppendListR ('[] :: [k]) (l :: [k]) Source # | |
Defined in Data.HList.HList type HAppendListR ('[] :: [k]) (l :: [k]) = l | |
type HAppendListR (e ': l :: [k]) (l' :: [k]) Source # | |
Defined in Data.HList.HList |
data ReadElement Source #
Instances
(y ~ ReadP x, Read x) => ApplyAB ReadElement (Proxy x) y Source # | |
Defined in Data.HList.HList applyAB :: ReadElement -> Proxy x -> y Source # |
type family DropProxy (xs :: k) :: k Source #
inverse of AddProxy
Instances
type DropProxy ('[] :: [k]) Source # | |
Defined in Data.HList.HList type DropProxy ('[] :: [k]) = '[] :: [k] | |
type DropProxy (Proxy x :: Type) Source # | |
Defined in Data.HList.HList | |
type DropProxy (x ': xs :: [a]) Source # | |
Defined in Data.HList.HList |
type family AddProxy (xs :: k) :: k Source #
Add Proxy
to a type
>>>
let x = undefined :: HList (AddProxy [Char,Int])
>>>
:t x
x :: HList '[Proxy Char, Proxy Int]
Instances
type AddProxy (x :: Type) Source # | |
Defined in Data.HList.HList | |
type AddProxy ('[] :: [k]) Source # | |
Defined in Data.HList.HList type AddProxy ('[] :: [k]) = '[] :: [k] | |
type AddProxy (x ': xs :: [a]) Source # | |
Defined in Data.HList.HList |
type HProxies xs = HProxiesFD xs (AddProxy xs) Source #
class HProxiesFD (xs :: [*]) pxs | pxs -> xs, xs -> pxs where Source #
creates a HList of Proxies
Instances
HProxiesFD ('[] :: [Type]) ('[] :: [Type]) Source # | |
Defined in Data.HList.HList | |
HProxiesFD xs pxs => HProxiesFD (x ': xs) (Proxy x ': pxs) Source # | |
data family HList (l :: [*]) infixr 2 Source #
Instances
(SameLengths '[x, y, xy], HZipList x y xy) => HZip HList x y xy Source # | |
(SameLengths '[x, y, xy], HZipList x y xy) => HUnzip HList x y xy Source # | |
HDeleteMany (e :: k) (HList ('[] :: [Type])) (HList ('[] :: [Type])) Source # | |
Defined in Data.HList.HTypeIndexed | |
HMapAux HList f ('[] :: [Type]) ('[] :: [Type]) Source # | |
(HSpanEqBy f a as fst snd, HGroupBy f snd gs) => HGroupBy (f :: t) (a ': as) (HList (a ': fst) ': gs) Source # | |
(ApplyAB f e e', HMapAux HList f l l', SameLength l l') => HMapAux HList f (e ': l) (e' ': l') Source # | |
(HOccurs e l, HProject l (HList l')) => HProject l (HList (e ': l')) Source # | |
Defined in Data.HList.HOccurs | |
(HOccurrence e (x ': y) l', HOccurs' e l' (x ': y)) => HOccurs e (HList (x ': y)) Source # | |
Defined in Data.HList.HOccurs | |
HExtend e (HList l) Source # | |
HReverse l l' => HBuild' l (HList l') Source # | |
HInits1 a b => HInits a (HList ('[] :: [Type]) ': b) Source # | |
(Bounded x, Bounded (HList xs)) => Bounded (HList (x ': xs)) Source # | |
Bounded (HList ('[] :: [Type])) Source # | |
(Eq x, Eq (HList xs)) => Eq (HList (x ': xs)) Source # | |
Eq (HList ('[] :: [Type])) Source # | |
(Data x, Data (HList xs), TypeablePolyK (x ': xs), Typeable (HList (x ': xs))) => Data (HList (x ': xs)) Source # | |
Defined in Data.HList.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HList (x ': xs) -> c (HList (x ': xs)) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HList (x ': xs)) # toConstr :: HList (x ': xs) -> Constr # dataTypeOf :: HList (x ': xs) -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HList (x ': xs))) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HList (x ': xs))) # gmapT :: (forall b. Data b => b -> b) -> HList (x ': xs) -> HList (x ': xs) # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HList (x ': xs) -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HList (x ': xs) -> r # gmapQ :: (forall d. Data d => d -> u) -> HList (x ': xs) -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HList (x ': xs) -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HList (x ': xs) -> m (HList (x ': xs)) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HList (x ': xs) -> m (HList (x ': xs)) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HList (x ': xs) -> m (HList (x ': xs)) # | |
Typeable (HList ('[] :: [Type])) => Data (HList ('[] :: [Type])) Source # | |
Defined in Data.HList.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HList '[] -> c (HList '[]) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HList '[]) # toConstr :: HList '[] -> Constr # dataTypeOf :: HList '[] -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HList '[])) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HList '[])) # gmapT :: (forall b. Data b => b -> b) -> HList '[] -> HList '[] # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HList '[] -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HList '[] -> r # gmapQ :: (forall d. Data d => d -> u) -> HList '[] -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HList '[] -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> HList '[] -> m (HList '[]) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> HList '[] -> m (HList '[]) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> HList '[] -> m (HList '[]) # | |
(Ord x, Ord (HList xs)) => Ord (HList (x ': xs)) Source # | |
Defined in Data.HList.HList compare :: HList (x ': xs) -> HList (x ': xs) -> Ordering # (<) :: HList (x ': xs) -> HList (x ': xs) -> Bool # (<=) :: HList (x ': xs) -> HList (x ': xs) -> Bool # (>) :: HList (x ': xs) -> HList (x ': xs) -> Bool # (>=) :: HList (x ': xs) -> HList (x ': xs) -> Bool # max :: HList (x ': xs) -> HList (x ': xs) -> HList (x ': xs) # min :: HList (x ': xs) -> HList (x ': xs) -> HList (x ': xs) # | |
Ord (HList ('[] :: [Type])) Source # | |
Defined in Data.HList.HList | |
(HProxies l, Read e, HSequence ReadP (ReadP e ': readP_l) (e ': l), HMapCxt HList ReadElement (AddProxy l) readP_l) => Read (HList (e ': l)) Source # | |
Read (HList ('[] :: [Type])) Source # | |
(Show e, Show (HList l)) => Show (HList (e ': l)) Source # | |
Show (HList ('[] :: [Type])) Source # | |
(Ix x, Ix (HList xs)) => Ix (HList (x ': xs)) Source # | |
Defined in Data.HList.HList range :: (HList (x ': xs), HList (x ': xs)) -> [HList (x ': xs)] # index :: (HList (x ': xs), HList (x ': xs)) -> HList (x ': xs) -> Int # unsafeIndex :: (HList (x ': xs), HList (x ': xs)) -> HList (x ': xs) -> Int # inRange :: (HList (x ': xs), HList (x ': xs)) -> HList (x ': xs) -> Bool # rangeSize :: (HList (x ': xs), HList (x ': xs)) -> Int # unsafeRangeSize :: (HList (x ': xs), HList (x ': xs)) -> Int # | |
Ix (HList ('[] :: [Type])) Source # | |
Defined in Data.HList.HList range :: (HList '[], HList '[]) -> [HList '[]] # index :: (HList '[], HList '[]) -> HList '[] -> Int # unsafeIndex :: (HList '[], HList '[]) -> HList '[] -> Int # inRange :: (HList '[], HList '[]) -> HList '[] -> Bool # rangeSize :: (HList '[], HList '[]) -> Int # unsafeRangeSize :: (HList '[], HList '[]) -> Int # | |
(HZip HList a a aa, HMapCxt HList UncurryMappend aa a) => Semigroup (HList a) Source # | |
(HProxies a, HMapCxt HList ConstMempty (AddProxy a) a, HZip HList a a aa, HMapCxt HList UncurryMappend aa a) => Monoid (HList a) Source # | Analogous to the Monoid instance for tuples
|
(TypeRepsList (HList xs), Typeable x) => TypeRepsList (HList (x ': xs)) Source # | |
Defined in Data.HList.Data typeRepsList :: HList (x ': xs) -> [TypeRep] Source # | |
TypeRepsList (HList ('[] :: [Type])) Source # | |
Defined in Data.HList.Data typeRepsList :: HList '[] -> [TypeRep] Source # | |
(HDeleteAtHNat n l, HType2HNat e l n, l' ~ HDeleteAtHNatR n l) => HDeleteAtLabel HList (e :: Type) l l' Source # | should this instead delete the first element of that type? |
Defined in Data.HList.HTypeIndexed | |
(HEq e1 e b, HDeleteManyCase b e1 e l l1) => HDeleteMany (e1 :: Type) (HList (e ': l)) (HList l1) Source # | |
Defined in Data.HList.HTypeIndexed | |
HProject (HList l) (HList ('[] :: [Type])) Source # | |
HAppendList l1 l2 => HAppend (HList l1) (HList l2) Source # | |
ApplyAB f e e' => ApplyAB (MapCar f) (e, HList l) (HList (e' ': l)) Source # | |
HInits1 ('[] :: [Type]) '[HList ('[] :: [Type])] Source # | |
HTails ('[] :: [Type]) '[HList ('[] :: [Type])] Source # | |
Apply (FHUProj sel ns) (HList l, Proxy ('HSucc n)) => Apply (Proxy 'False, FHUProj sel ns) (HList (e ': l), Proxy n) Source # | |
Apply (Proxy 'True, FHUProj sel ns) (HList (e ': l), Proxy n) Source # | |
(ch ~ Proxy (HBoolEQ sel (KMember n ns)), Apply (ch, FHUProj sel ns) (HList (e ': l), Proxy n)) => Apply (FHUProj sel ns) (HList (e ': l), Proxy n) Source # | |
Apply (FHUProj sel ns) (HList ('[] :: [Type]), n) Source # | |
(HConcatFD as bs, HAppendFD a bs cs) => HConcatFD (HList a ': as) cs Source # | |
(HInits1 xs ys, HMapCxt HList (FHCons2 x) ys ys', HMapCons x ys ~ ys', HMapTail ys' ~ ys) => HInits1 (x ': xs) (HList '[x] ': ys') Source # | |
HTails xs ys => HTails (x ': xs) (HList (x ': xs) ': ys) Source # | |
HMapUnboxF xs us => HMapUnboxF (HList x ': xs) (RecordU x ': us) Source # | |
Defined in Data.HList.RecordU | |
(HList (x ': y) ~ z, HZip3 xs ys zs) => HZip3 (x ': xs) (HList y ': ys) (z ': zs) Source # | |
type HExtendR e (HList l) Source # | |
Defined in Data.HList.HList | |
type HMapCons x (HList a ': b) Source # | |
Defined in Data.HList.HList | |
type UnHList (HList a) Source # | |
Defined in Data.HList.HList | |
data HList ('[] :: [Type]) Source # | |
Defined in Data.HList.HList | |
type HAppendR (HList l1 :: Type) (HList l2 :: Type) Source # | |
Defined in Data.HList.HList | |
type ApplyR (Proxy 'False, FHUProj sel ns) (HList (e ': l), Proxy n) Source # | |
type ApplyR (Proxy 'True, FHUProj sel ns) (HList (e ': l), Proxy n) Source # | |
type ApplyR (FHUProj sel ns) (HList ('[] :: [Type]), n) Source # | |
type ApplyR (FHUProj sel ns) (HList (e ': l), Proxy n) Source # | |
type HMapTail (HList (a ': as) ': bs) Source # | |
Defined in Data.HList.HList | |
data HList (x ': xs) Source # | |
Defined in Data.HList.HList |
hLast :: forall (l1 :: [Type]) e (l :: [Type]). HRevApp l1 ('[] :: [Type]) (e ': l) => HList l1 -> e Source #
hReverse_ :: forall (l1 :: [Type]) (l3 :: [Type]). HRevApp l1 ('[] :: [Type]) l3 => HList l1 -> HList l3 Source #
a version of hReverse
that does not allow the type
information to flow backwards
hEnd :: HList l -> HList l Source #
Note:
x :: HList a
- means:
forall a. x :: HList a
hEnd x
- means:
exists a. x :: HList a
List termination
hUnfold :: forall f a (z :: [Type]). (HUnfoldFD f (ApplyR f a) z, Apply f a) => f -> a -> HList z Source #
hMap :: forall (a :: [Type]) (b :: [Type]) r f. (SameLength' a b, SameLength' b a, HMapAux r f a b) => f -> r a -> r b Source #
hMapL :: forall (a :: [Type]) (b :: [Type]) f. (SameLength' a b, SameLength' b a, HMapAux HList f a b) => f -> HList a -> HList b Source #
hMap constrained to HList
hComposeList :: HFoldr Comp (a -> a) l (t -> a) => HList l -> t -> a Source #
>>>
let xs = length .*. (+1) .*. (*2) .*. HNil
>>>
hComposeList xs "abc"
8
hMapOut :: forall f e l. HMapOut f l e => f -> HList l -> [e] Source #
compare hMapOut f
with hList2List
. hMap
f
hMapM_ :: (Monad m, HMapOut f l (m ())) => f -> HList l -> m () Source #
GHC doesn't like its own type.
hMapM_ :: forall m a f e. (Monad m, HMapOut f a (m e)) => f -> a -> m ()
Without explicit type signature, it's Ok. Sigh. Anyway, Hugs does insist on a better type. So we restrict as follows:
list2HList :: HList2List l e => [e] -> Maybe (HList l) Source #
listAsHList :: forall (l1 :: [Type]) e1 (l2 :: [Type]) e2 p f. (HList2List l1 e1, HList2List l2 e2, Choice p, Applicative f) => p (HList l2) (f (HList l1)) -> p [e2] (f [e1]) Source #
Prism [s] [t] (HList s) (HList t)
listAsHList' :: forall (l :: [Type]) e p f. (HList2List l e, Choice p, Applicative f) => p (HList l) (f (HList l)) -> p [e] (f [e]) Source #
Prism' [a] (HList s)
where s ~ HReplicateR n a
toHJust2 :: (HMapCxt r (HJust ()) a b, ToHJust a, b ~ ToHJustR a) => r a -> r b Source #
alternative implementation. The Apply instance is in Data.HList.FakePrelude. A longer type could be inferred.
fromHJust2 :: HMapCxt r HFromJust a b => r a -> r b Source #
This implementation is shorter.
hAddTag :: forall (a :: [Type]) (b :: [Type]) r t. (SameLength' a b, SameLength' b a, HMapAux r (HAddTag t) a b) => t -> r a -> r b Source #
hRmTag :: forall (a :: [Type]) (b :: [Type]) r. (SameLength' a b, SameLength' b a, HMapAux r HRmTag a b) => r a -> r b Source #
hFlag :: forall (a :: [Type]) (b :: [Type]) r. (SameLength' a b, SameLength' b a, HMapAux r (HAddTag (Proxy 'True)) a b) => r a -> r b Source #
Annotate list with a type-level Boolean
hFlag :: HMapCxt (HAddTag (Proxy True)) l r => HList l -> HList r
hTuple :: forall p f (v1 :: [Type]) a (v2 :: [Type]) t. (Profunctor p, Functor f, HTuple v1 a, HTuple v2 t) => p a (f t) -> p (HList v1) (f (HList v2)) Source #
Iso (HList v) (HList v') a b
hTuple' :: forall p f (v :: [Type]) a. (Profunctor p, Functor f, HTuple v a) => p a (f a) -> p (HList v) (f (HList v)) Source #
Iso' (HList v) a
module Data.HList.HZip
A subset of Data.HList.HSort
class (SameLength a b, HEqByFn le) => HSortBy le (a :: [*]) (b :: [*]) | le a -> b where Source #
quick sort with a special case for sorted lists
Instances
(SameLength a b, HIsAscList le a ok, HSortBy1 ok le a b, HEqByFn le) => HSortBy (le :: k) a b Source # | |
the "standard" <=
for types. Reuses HEqBy
Note that ghc-7.6 is missing instances for Symbol and Nat, so that
sorting only works HNat
(as used by Data.HList.Label3).
Instances
HEqByFn HLeFn Source # | |
Defined in Data.HList.HSort | |
(x <=? y) ~ b => HEqBy HLeFn (x :: Nat) (y :: Nat) b Source # | only in ghc >= 7.7 |
Defined in Data.HList.HSort | |
(HEq (CmpSymbol x y) 'GT nb, HNot nb ~ b) => HEqBy HLeFn (x :: Symbol) (y :: Symbol) b Source # | only in ghc >= 7.7
|
Defined in Data.HList.HSort | |
HLe x y ~ b => HEqBy HLeFn (x :: HNat) (y :: HNat) b Source # | |
Defined in Data.HList.HSort | |
HEqBy HLeFn x y b => HEqBy HLeFn (Proxy x :: Type) (Proxy y :: Type) b Source # | |
Defined in Data.HList.HSort | |
HEqBy HLeFn x y b => HEqBy HLeFn (Label x :: Type) (Label y :: Type) b Source # | |
Defined in Data.HList.HSort | |
HEqBy HLeFn x y b => HEqBy HLeFn (Tagged x v :: Type) (Tagged y w :: Type) b Source # | |
Defined in Data.HList.HSort | |
(HEqBy HLeFn n m b, ns ~ ns') => HEqBy HLeFn (Lbl n ns desc :: Type) (Lbl m ns' desc' :: Type) b Source # | Data.HList.Label3 labels can only be compared if they belong to the same namespace. |
Defined in Data.HList.HSort |
analogous to Down
class HEqByFn lt => HSetBy lt (ps :: [*]) Source #
Provided the labels involved have an appropriate instance of HEqByFn, it would be possible to use the following definitions:
type HRLabelSet = HSet type HLabelSet = HSet
class HIsSet (ps :: [*]) (b :: Bool) | ps -> b Source #
>>>
let xx = Proxy :: HIsSet [Label "x", Label "x"] b => Proxy b
>>>
:t xx
xx :: Proxy 'False
>>>
let xy = Proxy :: HIsSet [Label "x", Label "y"] b => Proxy b
>>>
:t xy
xy :: Proxy 'True
class HEqByFn lt => HIsSetBy lt (ps :: [*]) (b :: Bool) | lt ps -> b Source #
Instances
(HEqByFn lt, HSortBy lt ps ps', HIsAscList lt ps' b) => HIsSetBy (lt :: k) ps b Source # | |
Defined in Data.HList.HSort |
class HEqByFn le => HAscList le (ps :: [*]) Source #
HAscList le xs
confirms that xs is in ascending order,
and reports which element is duplicated otherwise.
class HEqByFn le => HIsAscList le (xs :: [*]) (b :: Bool) | le xs -> b Source #
HIsAscList le xs b
is analogous to
b = all (\(x,y) -> x `le` y) (xs `zip` tail xs)
Instances
HEqByFn le => HIsAscList (le :: k) ('[] :: [Type]) 'True Source # | |
Defined in Data.HList.HSort | |
(HEqBy le x y b1, HIsAscList le (y ': ys) b2, HAnd b1 b2 ~ b3) => HIsAscList (le :: k) (x ': (y ': ys)) b3 Source # | |
Defined in Data.HList.HSort | |
HEqByFn le => HIsAscList (le :: k) '[x] 'True Source # | |
Defined in Data.HList.HSort |
A subset of Data.HList.HCurry
class HLengthEq xs n => HCurry' (n :: HNat) f xs r | f xs -> r, r xs -> f, n f -> xs, xs -> n where Source #
curry
/uncurry
for many arguments and HLists instead of tuples
XXX the last FD xs -> n
is needed to make hCompose infer the right types:
arguably it shouldn't be needed
hCurry :: forall (n :: HNat) f (xs :: [Type]) r. (HCurry' n f xs r, ArityFwd f n, ArityRev f n) => (HList xs -> r) -> f Source #
Note: with ghc-7.10 the Arity constraint added here does not work
properly with hCompose, so it is possible that other uses of hCurry
are better served by hCurry' Proxy
.
hUncurry :: forall (n :: HNat) f (xs :: [Type]) r. (HCurry' n f xs r, ArityFwd f n, ArityRev f n) => f -> HList xs -> r Source #
hCompose :: forall (xs1 :: [Type]) (xs2 :: [Type]) (xsys :: [Type]) (n1 :: HNat) f1 r (n2 :: HNat) b (n3 :: HNat) f2 x. (HAppendList1 xs1 xs2 xsys, HCurry' n1 f1 xsys r, HCurry' n2 b xs2 r, HCurry' n3 f2 xs1 x, ArityFwd b n2, ArityFwd f2 n3, ArityRev b n2, ArityRev f2 n3, HSplitAt1 ('[] :: [Type]) n3 xsys xs1 xs2) => (x -> b) -> f2 -> f1 Source #
compose two functions that take multiple arguments. The result of the second function is the first argument to the first function. An example is probably clearer:
>>>
let f = hCompose (,,) (,)
>>>
:t f
f :: ... -> ... -> ... -> ... -> ((..., ...), ..., ...)
>>>
f 1 2 3 4
((1,2),3,4)
Note: polymorphism can make it confusing as to how many parameters a function
actually takes. For example, the first two ids are id :: (a -> b) -> (a -> b)
in
>>>
(.) id id id 'y'
'y'
>>>
hCompose id id id 'y'
'y'
still typechecks, but in that case hCompose i1 i2 i3 x == i1 ((i2 i3) x)
has id with different types than @(.) i1 i2 i3 x == (i1 (i2 i3)) x
Prompted by http://stackoverflow.com/questions/28932054/can-hlistelim-be-composed-with-another-function
TIP
Public interface of Data.HList.TIP
TIPs are like Record
, except element "i" of the list "l"
has type Tagged e_i e_i
Instances
TypeIndexed Record TIP Source # | |
Defined in Data.HList.TIC | |
(HUnzip TIP x y xy, HZipList xL yL xyL, lty ~ (HList xL -> HList yL -> HList xyL), Coercible lty (TIP x -> TIP y -> TIP xy), UntagR x ~ xL, UntagR y ~ yL, UntagR xy ~ xyL, UntagTag x, UntagTag y, UntagTag xy) => HZip TIP x y xy Source # | |
(HZipList xL yL xyL, lty ~ (HList xyL -> (HList xL, HList yL)), Coercible lty (TIP xy -> (TIP x, TIP y)), UntagR x ~ xL, TagR xL ~ x, UntagR y ~ yL, TagR yL ~ y, UntagR xy ~ xyL, TagR xyL ~ xy, SameLengths '[x, y, xy], UntagTag x, UntagTag y, UntagTag xy) => HUnzip TIP x y xy Source # | |
(HDeleteAtLabel Record e v v', HTypeIndexed v') => HDeleteAtLabel TIP (e :: k) v v' Source # | |
Defined in Data.HList.TIP | |
LabelableTIPCxt x s t a b => Labelable (x :: k) TIP s t a b Source # | make a
|
Defined in Data.HList.Labelable type LabelableTy TIP :: LabeledOpticType Source # | |
HasField e (Record (x ': (y ': l))) e => HOccurs e (TIP (x ': (y ': l))) Source # | |
Defined in Data.HList.TIP | |
tee ~ Tagged e e => HOccurs e (TIP '[tee]) Source # | One occurrence and nothing is left This variation provides an extra feature for singleton lists. That is, the result type is unified with the element in the list. Hence the explicit provision of a result type can be omitted. |
Defined in Data.HList.TIP | |
(HRLabelSet (Tagged e e ': l), HTypeIndexed l) => HExtend e (TIP l) Source # | |
Bounded (HList r) => Bounded (TIP r) Source # | |
Eq (HList a) => Eq (TIP a) Source # | |
(TypeablePolyK xs, Typeable (HList xs), Data (HList xs)) => Data (TIP xs) Source # | |
Defined in Data.HList.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TIP xs -> c (TIP xs) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (TIP xs) # toConstr :: TIP xs -> Constr # dataTypeOf :: TIP xs -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (TIP xs)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (TIP xs)) # gmapT :: (forall b. Data b => b -> b) -> TIP xs -> TIP xs # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TIP xs -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TIP xs -> r # gmapQ :: (forall d. Data d => d -> u) -> TIP xs -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TIP xs -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TIP xs -> m (TIP xs) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TIP xs -> m (TIP xs) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TIP xs -> m (TIP xs) # | |
Ord (HList r) => Ord (TIP r) Source # | |
HMapOut (HComp HShow HUntag) l String => Show (TIP l) Source # | |
Ix (HList r) => Ix (TIP r) Source # | |
Semigroup (HList a) => Semigroup (TIP a) Source # | |
Monoid (HList a) => Monoid (TIP a) Source # | |
(HUpdateAtLabel Record e' e r r', HTypeIndexed r', e ~ e') => HUpdateAtLabel TIP (e' :: Type) e r r' Source # | |
Defined in Data.HList.TIP | |
(e ~ e', HasField e (Record l) e') => HasField (e :: Type) (TIP l) e' Source # | |
Defined in Data.HList.TIP hLookupByLabel :: Label e -> TIP l -> e' Source # | |
(HAppend (HList l) (HList l'), HTypeIndexed (HAppendListR l l')) => HAppend (TIP l) (TIP l') Source # | |
(HOccurs e (TIP l1), SubType (TIP l1) (TIP l2)) => SubType (TIP l1 :: Type) (TIP (e ': l2) :: Type) Source # | |
Defined in Data.HList.TIP | |
SubType (TIP l :: Type) (TIP ('[] :: [Type])) Source # | Subtyping for TIPs |
Defined in Data.HList.TIP | |
type LabelableTy TIP Source # | |
Defined in Data.HList.Labelable | |
type HExtendR e (TIP l) Source # | |
Defined in Data.HList.TIP | |
type HAppendR (TIP l :: Type) (TIP l' :: Type) Source # | |
Defined in Data.HList.TIP |
tipyUpdate :: forall record v (r :: [Type]). (HUpdateAtLabel record v v r r, SameLength' r r) => v -> record r -> record r Source #
tipyLens :: forall (n :: HNat) x (xs1 :: [Type]) (l1 :: [Type]) a1 (xs2 :: [Type]) (b :: Bool) a2 f. (HSplitAt1 ('[] :: [Type]) n (Tagged x x ': xs1) l1 (Tagged a1 a1 ': xs2), HAppendList1 l1 (Tagged a1 a1 ': xs2) (Tagged x x ': xs1), SameLength' (HReplicateR n ()) l1, HLengthEq1 l1 n, HLengthEq2 l1 n, HEq (Label a1) (Label x) b, HFind2 b (Label a1) (LabelsOf xs1) (Label x ': LabelsOf xs1) n, HAllTaggedEq (HAppendListR l1 (Tagged a2 a2 ': xs2)), HLabelSet (LabelsOf (HAppendListR l1 (Tagged a2 a2 ': xs2))), HAllTaggedLV (HAppendListR l1 (Tagged a2 a2 ': xs2)), HAppendList l1 (Tagged a2 a2 ': xs2), Functor f) => (a1 -> f a2) -> TIP (Tagged x x ': xs1) -> f (TIP (HAppendListR l1 (Tagged a2 a2 ': xs2))) Source #
provides a Lens (TIP s) (TIP t) a b
When using set
(also known as .~
), tipyLens'
can address the
ambiguity as to which field "a" should actually be updated.
tipyLens' :: forall a (t :: [Type]) f. (HasField a (Record t) a, HUpdateAtLabel2 a a t t, HAllTaggedEq t, HLabelSet (LabelsOf t), HAllTaggedLV t, SameLength' t t, SameLabels t t, Functor f) => (a -> f a) -> TIP t -> f (TIP t) Source #
provides a Lens' (TIP s) a
. hLens'
:: Label a -> Lens' (TIP s) a
is another option.
projection
tipyProject :: forall (l :: [Type]) (ls :: [Type]) (t :: [Type]) (b :: [Type]) proxy. (HAllTaggedEq l, HLabelSet (LabelsOf l), HAllTaggedLV l, H2ProjectByLabels ls t l b) => proxy ls -> TIP t -> TIP l Source #
Use Labels
to specify the first argument
tipyProject2 :: forall (ls :: [Type]) (r :: [Type]) (l1 :: [Type]) (l2 :: [Type]) proxy. (H2ProjectByLabels ls r l1 l2, HAllTaggedEq l1, HAllTaggedEq l2, HLabelSet (LabelsOf l1), HLabelSet (LabelsOf l2), HAllTaggedLV l1, HAllTaggedLV l2) => proxy ls -> TIP r -> (TIP l1, TIP l2) Source #
The same as tipyProject
, except also return the
types not requested in the proxy
argument
tipyTuple :: forall b r (v1 :: [Type]) (v2 :: [Type]) a (v3 :: [Type]) (v'1 :: [Type]) (v'2 :: [Type]). (HOccurs b (r v1), HOccurs b (r v2), HOccurs a (r v2), HOccurs a (r v3), HDeleteAtLabel r b v1 v'1, HDeleteAtLabel r b v2 v3, HDeleteAtLabel r a v2 v1, HDeleteAtLabel r a v3 v'2) => r v2 -> (a, b) Source #
project a TIP (or HList) into a tuple
tipyTuple' x = (hOccurs
x, hOccurs x)
behaves similarly, except tipyTuple
excludes
the possibility of looking up the same element
twice, which allows inferring a concrete type
in more situations. For example
(\x y z -> tipyTuple (x .*. y .*. emptyTIP) `asTypeOf` (x, z)) () 'x'
has type Char -> ((), Char)
. tipyTuple' would
need a type annotation to decide whether the type
should be Char -> ((), Char)
or () -> ((), ())
tipyTuple3 :: forall b r (v1 :: [Type]) (v2 :: [Type]) (v3 :: [Type]) c (v4 :: [Type]) (v5 :: [Type]) a (v6 :: [Type]) (v7 :: [Type]) (v'1 :: [Type]) (v'2 :: [Type]) (v'3 :: [Type]). (HOccurs b (r v1), HOccurs b (r v2), HOccurs b (r v3), HOccurs c (r v4), HOccurs c (r v3), HOccurs c (r v5), HOccurs a (r v3), HOccurs a (r v6), HOccurs a (r v7), HDeleteAtLabel r b v1 v4, HDeleteAtLabel r b v2 v'1, HDeleteAtLabel r b v3 v5, HDeleteAtLabel r c v4 v'2, HDeleteAtLabel r c v3 v6, HDeleteAtLabel r c v5 v7, HDeleteAtLabel r a v3 v1, HDeleteAtLabel r a v6 v2, HDeleteAtLabel r a v7 v'3) => r v3 -> (a, b, c) Source #
tipyTuple4 :: forall b r (v1 :: [Type]) (v2 :: [Type]) (v3 :: [Type]) (v4 :: [Type]) c (v5 :: [Type]) (v6 :: [Type]) (v7 :: [Type]) d (v8 :: [Type]) (v9 :: [Type]) (v10 :: [Type]) a (v11 :: [Type]) (v12 :: [Type]) (v13 :: [Type]) (v'1 :: [Type]) (v'2 :: [Type]) (v'3 :: [Type]) (v'4 :: [Type]). (HOccurs b (r v1), HOccurs b (r v2), HOccurs b (r v3), HOccurs b (r v4), HOccurs c (r v5), HOccurs c (r v6), HOccurs c (r v4), HOccurs c (r v7), HOccurs d (r v8), HOccurs d (r v4), HOccurs d (r v9), HOccurs d (r v10), HOccurs a (r v4), HOccurs a (r v11), HOccurs a (r v12), HOccurs a (r v13), HDeleteAtLabel r b v1 v5, HDeleteAtLabel r b v2 v6, HDeleteAtLabel r b v3 v'1, HDeleteAtLabel r b v4 v7, HDeleteAtLabel r c v5 v8, HDeleteAtLabel r c v6 v'2, HDeleteAtLabel r c v4 v9, HDeleteAtLabel r c v7 v10, HDeleteAtLabel r d v8 v'3, HDeleteAtLabel r d v4 v11, HDeleteAtLabel r d v9 v12, HDeleteAtLabel r d v10 v13, HDeleteAtLabel r a v4 v1, HDeleteAtLabel r a v11 v2, HDeleteAtLabel r a v12 v3, HDeleteAtLabel r a v13 v'4) => r v4 -> (a, b, c, d) Source #
tipyTuple5 :: forall b r (v1 :: [Type]) (v2 :: [Type]) (v3 :: [Type]) (v4 :: [Type]) (v5 :: [Type]) c (v6 :: [Type]) (v7 :: [Type]) (v8 :: [Type]) (v9 :: [Type]) d (v10 :: [Type]) (v11 :: [Type]) (v12 :: [Type]) (v13 :: [Type]) e (v14 :: [Type]) (v15 :: [Type]) (v16 :: [Type]) (v17 :: [Type]) a (v18 :: [Type]) (v19 :: [Type]) (v20 :: [Type]) (v21 :: [Type]) (v'1 :: [Type]) (v'2 :: [Type]) (v'3 :: [Type]) (v'4 :: [Type]) (v'5 :: [Type]). (HOccurs b (r v1), HOccurs b (r v2), HOccurs b (r v3), HOccurs b (r v4), HOccurs b (r v5), HOccurs c (r v6), HOccurs c (r v7), HOccurs c (r v8), HOccurs c (r v5), HOccurs c (r v9), HOccurs d (r v10), HOccurs d (r v11), HOccurs d (r v5), HOccurs d (r v12), HOccurs d (r v13), HOccurs e (r v14), HOccurs e (r v5), HOccurs e (r v15), HOccurs e (r v16), HOccurs e (r v17), HOccurs a (r v5), HOccurs a (r v18), HOccurs a (r v19), HOccurs a (r v20), HOccurs a (r v21), HDeleteAtLabel r b v1 v6, HDeleteAtLabel r b v2 v7, HDeleteAtLabel r b v3 v8, HDeleteAtLabel r b v4 v'1, HDeleteAtLabel r b v5 v9, HDeleteAtLabel r c v6 v10, HDeleteAtLabel r c v7 v11, HDeleteAtLabel r c v8 v'2, HDeleteAtLabel r c v5 v12, HDeleteAtLabel r c v9 v13, HDeleteAtLabel r d v10 v14, HDeleteAtLabel r d v11 v'3, HDeleteAtLabel r d v5 v15, HDeleteAtLabel r d v12 v16, HDeleteAtLabel r d v13 v17, HDeleteAtLabel r e v14 v'4, HDeleteAtLabel r e v5 v18, HDeleteAtLabel r e v15 v19, HDeleteAtLabel r e v16 v20, HDeleteAtLabel r e v17 v21, HDeleteAtLabel r a v5 v1, HDeleteAtLabel r a v18 v2, HDeleteAtLabel r a v19 v3, HDeleteAtLabel r a v20 v4, HDeleteAtLabel r a v21 v'5) => r v5 -> (a, b, c, d, e) Source #
type TagUntag xs = TagUntagFD xs (TagR xs) Source #
class SameLength a ta => TagUntagFD a ta | a -> ta, ta -> a where Source #
TagR
can also be used to avoid redundancy when defining types for TIC and TIP.
type XShort = TagR [A,B,C,D]
type XLong = [Tagged A A, Tagged B B, Tagged C C, Tagged D D]
an equivalent FD version, which is slightly better with respect to simplifying types containing type variables (in ghc-7.8 and 7.6): http://stackoverflow.com/questions/24110410/
With ghc-7.10 (http://ghc.haskell.org/trac/ghc/ticket/10009) the FD version is superior to the TF version:
class (UntagR (TagR a) ~ a) => TagUntag a where type TagR a :: [*] hTagSelf :: HList a -> HList (TagR a) hUntagSelf :: HList (TagR a) -> HList a instance TagUntag '[] where type TagR '[] = '[] hTagSelf _ = HNil hUntagSelf _ = HNil instance TagUntag xs => TagUntag (x ': xs) where type TagR (x ': xs) = Tagged x x ': TagR xs hTagSelf (HCons x xs) = Tagged xHCons
hTagSelf xs hUntagSelf (HCons (Tagged x) xs) = xHCons
hUntagSelf xs type family UntagR (xs :: [*]) :: [*] type instance UntagR '[] = '[] type instance UntagR (x ': xs) = Untag1 x ': UntagR xs
Length information should flow backwards
>>>
let len2 x = x `asTypeOf` (undefined :: HList '[a,b])
>>>
let f = len2 $ hTagSelf (hReplicate Proxy ())
>>>
:t f
f :: HList '[Tagged () (), Tagged () ()]
Instances
TagUntagFD ('[] :: [Type]) ('[] :: [Type]) Source # | |
(TagUntagFD xs ys, txx ~ Tagged x x) => TagUntagFD (x ': xs) (txx ': ys) Source # | |
TIP transform
class TransTIP op db where Source #
Transforming a TIP: applying to a TIP a (polyvariadic) function that takes arguments from a TIP and updates the TIP with the result.
In more detail: we have a typed-indexed collection TIP and we would like to apply a transformation function to it, whose argument types and the result type are all in the TIP. The function should locate its arguments based on their types, and update the TIP with the result. The function may have any number of arguments, including zero; the order of arguments should not matter.
The problem was posed by Andrew U. Frank on Haskell-Cafe, Sep 10, 2009. http://www.haskell.org/pipermail/haskell-cafe/2009-September/066217.html The problem is an interesting variation of the keyword argument problem.
Examples can be found in examples/TIPTransform.hs
and examples/TIPTransformM.hs
class Monad m => TransTIPM m op db where Source #
In March 2010, Andrew Frank extended the problem for monadic operations.
This is the monadic version of TIPTransform.hs
in the present directory.
This is the TF implementation. When specifying the operation to perform over a TIP, we can leave it polymorphic over the monad. The type checker will instantiate the monad based on the context.
TIC
Public interface of Data.HList.TIC
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
.
Instances
TypeIndexed Variant TIC Source # | |
Defined in Data.HList.TIC | |
HMapAux Variant f xs ys => HMapAux TIC f xs ys Source # | |
(TICPrism s t a b, Label x ~ Label a, a ~ b, s ~ t, SameLength s t) => Labelable (x :: k) TIC s t a b Source # | hLens' :: Label a -> Prism' (TIC s) a note that a more general function Note: `x :: k` according to the instance head, but the instance body forces the kind variable to be * later on. IE. (k ~ *) |
Defined in Data.HList.Labelable type LabelableTy TIC :: LabeledOpticType Source # | |
(HasField o (TIC l) mo, mo ~ Maybe o) => HOccurs mo (TIC l) Source # | |
Defined in Data.HList.TIC | |
(me ~ Maybe e, HOccursNot (Tagged e e) l) => HExtend me (TIC l) Source # | Nothing .*. x = x Just a .*. y = mkTIC a |
Bounded (Variant l) => Bounded (TIC l) Source # | |
Enum (Variant l) => Enum (TIC l) Source # | |
Eq (Variant l) => Eq (TIC l) Source # | |
(TypeablePolyK xs, Typeable (Variant xs), Data (Variant xs)) => Data (TIC xs) Source # | |
Defined in Data.HList.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TIC xs -> c (TIC xs) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (TIC xs) # toConstr :: TIC xs -> Constr # dataTypeOf :: TIC xs -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (TIC xs)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (TIC xs)) # gmapT :: (forall b. Data b => b -> b) -> TIC xs -> TIC xs # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TIC xs -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TIC xs -> r # gmapQ :: (forall d. Data d => d -> u) -> TIC xs -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TIC xs -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TIC xs -> m (TIC xs) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TIC xs -> m (TIC xs) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TIC xs -> m (TIC xs) # | |
Ord (Variant l) => Ord (TIC l) Source # | |
(ReadVariant l, HAllTaggedEq l, HRLabelSet l) => Read (TIC l) Source # | |
ShowVariant l => Show (TIC l) Source # | TICs are not opaque |
Ix (Variant l) => Ix (TIC l) Source # | |
Semigroup (Variant l) => Semigroup (TIC l) Source # | |
Monoid (Variant l) => Monoid (TIC l) Source # | |
HasField o (Variant l) (Maybe o) => HasField (o :: Type) (TIC l) (Maybe o) Source # | Public destructor (or, open union's projection function) |
Defined in Data.HList.TIC | |
type LabelableTy TIC Source # | |
Defined in Data.HList.Labelable | |
type HExtendR me (TIC l) Source # | |
creating TIC
mkTIC :: forall i (l :: [Type]) (n :: HNat). (HFind1 i (UnLabel i (LabelsOf l)) (UnLabel i (LabelsOf l)) n, HasField i (Record l) i, KnownNat (HNat2Nat n), HAllTaggedLV l, HLabelSet (LabelsOf l), HAllTaggedEq l) => i -> TIC l Source #
make a TIC for use in contexts where the result type is fixed
mkTIC1 :: forall i. MkVariant i i '[Tagged i i] => i -> TIC '[Tagged i i] Source #
make a TIC that contains one element
:: forall i l proxy. (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)
get,set,modify
ticPrism :: (TICPrism s t a b, SameLength s t, Choice p, Applicative f) => (a `p` f b) -> TIC s `p` f (TIC t) Source #
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) Source #
Prism' (TIC s) a
Variant
Public interface of Data.HList.Variant
data Variant (vs :: [*]) Source #
Variant vs
has an implementation similar to Dynamic
, except the
contained value is one of the elements of the vs
list, rather than
being one particular instance of Typeable
.
>>>
v .!. _right
Nothing
>>>
v .!. _left
Just 'x'
In some cases the pun
quasiquote works with variants,
>>>
let f [pun| left right |] = (left,right)
>>>
f v
(Just 'x',Nothing)
>>>
f w
(Nothing,Just 5)
>>>
let add1 v = hMapV (Fun succ :: Fun '[Enum] '()) v
>>>
f (add1 v)
(Just 'y',Nothing)
>>>
f (add1 w)
(Nothing,Just 6)
Instances
Relabeled Variant Source # | |
Defined in Data.HList.Variant relabeled :: forall p f (s :: [Type]) (t :: [Type]) (a :: [Type]) (b :: [Type]). (HMapTaggedFn (RecordValuesR s) a, HMapTaggedFn (RecordValuesR b) t, SameLengths '[s, a, t, b], RecordValuesR t ~ RecordValuesR b, RecordValuesR s ~ RecordValuesR a, RecordValues b, RecordValues s, Profunctor p, Functor f) => p (Variant a) (f (Variant b)) -> p (Variant s) (f (Variant t)) Source # | |
TypeIndexed Variant TIC Source # | |
Defined in Data.HList.TIC | |
(ExtendsVariant b t, ProjectVariant s a, ProjectExtendVariant s t, HLeftUnion b s bs, HRLabelSet bs, HRearrange (LabelsOf t) bs t) => Projected Variant s t a b Source # | Prism (Variant s) (Variant t) (Variant a) (Variant b) |
Defined in Data.HList.Labelable projected :: forall (ty :: LabeledOpticType) p f. (ty ~ LabelableTy Variant, LabeledOpticP ty p, LabeledOpticF ty f) => p (Variant a) (f (Variant b)) -> p (Variant s) (f (Variant t)) Source # | |
HUpdateVariantAtLabelCxt l e v v' n _e => HUpdateAtLabel Variant (l :: k) e v v' Source # | hUpdateAtLabel x e' (mkVariant x e proxy) == mkVariant x e' proxy hUpdateAtLabel y e' (mkVariant x e proxy) == mkVariant x e proxy |
Defined in Data.HList.Variant | |
(HPrism x s t a b, to ~ ((->) :: Type -> Type -> Type)) => Labelable (x :: k) Variant s t a b Source # | make a |
Defined in Data.HList.Labelable type LabelableTy Variant :: LabeledOpticType Source # | |
(HasField x (Record vs) a, HFindLabel x vs n, HNat2Integral n) => HasField (x :: k) (Variant vs) (Maybe a) Source # | |
Defined in Data.HList.Variant | |
(ApplyAB f te te', HMapCxt Variant f (l ': ls) (l' ': ls')) => HMapAux Variant f (te ': (l ': ls)) (te' ': (l' ': ls')) Source # | |
ApplyAB f te te' => HMapAux Variant f '[te] '[te'] Source # | |
(le ~ Tagged l (Maybe e), HOccursNot (Label l) (LabelsOf v)) => HExtend le (Variant v) Source # | Extension for Variants prefers the first value (l .=. Nothing) .*. v = v (l .=. Just e) .*. _ = mkVariant l e Proxy |
(HasField l (Variant r) (Maybe u), HasFieldPath 'True ls u (Maybe v)) => HasFieldPath needJust (Label l ': ls) (Variant r) (Maybe v) Source # | |
Defined in Data.HList.Dredge | |
(Unvariant '[txy] txy, tx ~ Tagged t x, ty ~ Tagged t y, txy ~ Tagged t (x, y)) => HUnzip Variant '[tx] '[ty] '[txy] Source # | |
(HUnzip Variant (x2 ': xs) (y2 ': ys) (xy2 ': xys), SameLength xs ys, SameLength ys xys, tx ~ Tagged t x, ty ~ Tagged t y, txy ~ Tagged t (x, y)) => HUnzip Variant (tx ': (x2 ': xs)) (ty ': (y2 ': ys)) (txy ': (xy2 ': xys)) Source # | |
(Bounded x, Bounded z, HRevAppR (Tagged s x ': xs) ('[] :: [Type]) ~ (Tagged t z ': sx), MkVariant t z (Tagged s x ': xs)) => Bounded (Variant (Tagged s x ': xs)) Source # | |
Enum x => Enum (Variant '[Tagged s x]) Source # | While the instances could be written Enum (Variant '[])
Eq/Ord which cannot produce values, so they have instances for
empty variants ( |
Defined in Data.HList.Variant succ :: Variant '[Tagged s x] -> Variant '[Tagged s x] # pred :: Variant '[Tagged s x] -> Variant '[Tagged s x] # toEnum :: Int -> Variant '[Tagged s x] # fromEnum :: Variant '[Tagged s x] -> Int # enumFrom :: Variant '[Tagged s x] -> [Variant '[Tagged s x]] # enumFromThen :: Variant '[Tagged s x] -> Variant '[Tagged s x] -> [Variant '[Tagged s x]] # enumFromTo :: Variant '[Tagged s x] -> Variant '[Tagged s x] -> [Variant '[Tagged s x]] # enumFromThenTo :: Variant '[Tagged s x] -> Variant '[Tagged s x] -> Variant '[Tagged s x] -> [Variant '[Tagged s x]] # | |
(Enum x, Bounded x, Enum (Variant (y ': z))) => Enum (Variant (Tagged s x ': (y ': z))) Source # |
The last type in the Variant does not need to be Bounded. This
means that
This is a "feature" because it allows an Another difficult choice is that the lower bound is
|
Defined in Data.HList.Variant succ :: Variant (Tagged s x ': (y ': z)) -> Variant (Tagged s x ': (y ': z)) # pred :: Variant (Tagged s x ': (y ': z)) -> Variant (Tagged s x ': (y ': z)) # toEnum :: Int -> Variant (Tagged s x ': (y ': z)) # fromEnum :: Variant (Tagged s x ': (y ': z)) -> Int # enumFrom :: Variant (Tagged s x ': (y ': z)) -> [Variant (Tagged s x ': (y ': z))] # enumFromThen :: Variant (Tagged s x ': (y ': z)) -> Variant (Tagged s x ': (y ': z)) -> [Variant (Tagged s x ': (y ': z))] # enumFromTo :: Variant (Tagged s x ': (y ': z)) -> Variant (Tagged s x ': (y ': z)) -> [Variant (Tagged s x ': (y ': z))] # enumFromThenTo :: Variant (Tagged s x ': (y ': z)) -> Variant (Tagged s x ': (y ': z)) -> Variant (Tagged s x ': (y ': z)) -> [Variant (Tagged s x ': (y ': z))] # | |
(Eq (Variant xs), Eq x) => Eq (Variant (x ': xs)) Source # | |
Eq (Variant ('[] :: [Type])) Source # | |
(Typeable (Variant v), GfoldlVariant v v, GunfoldVariant v v, VariantConstrs v) => Data (Variant v) Source # | |
Defined in Data.HList.Variant gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Variant v -> c (Variant v) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Variant v) # toConstr :: Variant v -> Constr # dataTypeOf :: Variant v -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Variant v)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Variant v)) # gmapT :: (forall b. Data b => b -> b) -> Variant v -> Variant v # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Variant v -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Variant v -> r # gmapQ :: (forall d. Data d => d -> u) -> Variant v -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Variant v -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Variant v -> m (Variant v) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Variant v -> m (Variant v) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Variant v -> m (Variant v) # | |
(Ord x, Ord (Variant xs)) => Ord (Variant (x ': xs)) Source # | |
Defined in Data.HList.Variant compare :: Variant (x ': xs) -> Variant (x ': xs) -> Ordering # (<) :: Variant (x ': xs) -> Variant (x ': xs) -> Bool # (<=) :: Variant (x ': xs) -> Variant (x ': xs) -> Bool # (>) :: Variant (x ': xs) -> Variant (x ': xs) -> Bool # (>=) :: Variant (x ': xs) -> Variant (x ': xs) -> Bool # max :: Variant (x ': xs) -> Variant (x ': xs) -> Variant (x ': xs) # min :: Variant (x ': xs) -> Variant (x ': xs) -> Variant (x ': xs) # | |
Ord (Variant ('[] :: [Type])) Source # | |
Defined in Data.HList.Variant | |
ReadVariant v => Read (Variant v) Source # | A corresponding read instance |
ShowVariant vs => Show (Variant vs) Source # | Variants are not opaque |
(Semigroup x, Semigroup (Variant (a ': b))) => Semigroup (Variant (Tagged t x ': (a ': b))) Source # | |
Defined in Data.HList.Variant (<>) :: Variant (Tagged t x ': (a ': b)) -> Variant (Tagged t x ': (a ': b)) -> Variant (Tagged t x ': (a ': b)) # sconcat :: NonEmpty (Variant (Tagged t x ': (a ': b))) -> Variant (Tagged t x ': (a ': b)) # stimes :: Integral b0 => b0 -> Variant (Tagged t x ': (a ': b)) -> Variant (Tagged t x ': (a ': b)) # | |
(Unvariant '[Tagged t x] x, Semigroup x) => Semigroup (Variant '[Tagged t x]) Source # | |
(Monoid x, Monoid (Variant (a ': b))) => Monoid (Variant (Tagged t x ': (a ': b))) Source # | |
(Unvariant '[Tagged t x] x, Monoid x) => Monoid (Variant '[Tagged t x]) Source # | |
(SameLength s a, ExtendsVariant s a, SameLength b t, ExtendsVariant b t) => Rearranged Variant (s :: [Type]) (t :: [Type]) (a :: [Type]) (b :: [Type]) Source # | |
Defined in Data.HList.Variant rearranged :: (Profunctor p, Functor f) => p (Variant a) (f (Variant b)) -> p (Variant s) (f (Variant t)) Source # | |
type LabelableTy Variant Source # | |
Defined in Data.HList.Labelable | |
type HExtendR le (Variant v) Source # | |
Defined in Data.HList.Variant |
castVariant :: (RecordValuesR v ~ RecordValuesR v', SameLength v v') => Variant v -> Variant v' Source #
in ghc>=7.8, coerce
is probably a better choice
Apply a function to all possible elements of the variant
HMapV f |
hMapV :: forall f (x :: [Type]) (y :: [Type]). (HMapAux Variant (HFmap f) x y, SameLength' x y, SameLength' y x) => f -> Variant x -> Variant y Source #
shortcut for applyAB . HMapV
. hMap
is more general
hMapOutV :: forall x y z f. (SameLength x y, HMapAux Variant (HFmap f) x y, Unvariant y z, HMapOutV_gety x z ~ y) => f -> Variant x -> z Source #
hMapOutV f = unvariant . hMapV f
, except an ambiguous type
variable is resolved by HMapOutV_gety
class ZipVariant x y xy | x y -> xy, xy -> x y where Source #
Applies to variants that have the same labels in the same order. A generalization of
zipEither :: Either a b -> Either a b -> Maybe (Either (a,a) (b,b)) zipEither (Left a) (Left a') = Just (Left (a,a')) zipEither (Right a) (Right a') = Just (Right (a,a')) zipEither _ _ = Nothing
see HZip
for zipping other collections
Instances
ZipVariant ('[] :: [Type]) ('[] :: [Type]) ('[] :: [Type]) Source # | |
Defined in Data.HList.Variant | |
(tx ~ Tagged t x, ty ~ Tagged t y, txy ~ Tagged t (x, y), ZipVariant xs ys zs, MkVariant t (x, y) (txy ': zs)) => ZipVariant (tx ': xs) (ty ': ys) (txy ': zs) Source # | |
Defined in Data.HList.Variant |
class (SameLength v v', SameLabels v v') => ZipVR fs v v' | fs v -> v' where Source #
Apply a record of functions to a variant of values. The functions are selected based on those having the same label as the value.
zipVR_ :: Record fs -> Variant v -> Variant v' Source #
zipVR
is probably a better choice in most
situations, since it requires that fs
has one function for every
element of v
zipVR :: (SameLabels fs v, SameLength fs v, ZipVR fs v v', ZipVRCxt fs v v') => Record fs -> Variant v -> Variant v' Source #
>>>
let xy = x .*. y .*. emptyProxy
>>>
let p = Proxy `asLabelsOf` xy
>>>
let vs = [ mkVariant x 1.0 p, mkVariant y () p ]
>>>
zipVR (hBuild (+1) id) `map` vs
[V{x=2.0},V{y=()}]
projection
many
class (ProjectVariant x yin, ProjectVariant x yout) => SplitVariant x yin yout where Source #
Instances
(ProjectVariant x yin, ProjectVariant x yout, H2ProjectByLabels (LabelsOf yin) x xi xo, HRearrange (LabelsOf yin) xi yin, HRearrange (LabelsOf yout) xo yout, HLeftUnion xi xo xixo, HRearrange (LabelsOf x) xixo x, HAllTaggedLV x, HAllTaggedLV yin, HAllTaggedLV yout) => SplitVariant x yin yout Source # | |
Defined in Data.HList.Variant |
class ProjectVariant x y where Source #
convert a variant with more fields into one with fewer (or the same) fields.
>>>
let ty = Proxy :: Proxy [Tagged "left" Int, Tagged "right" Int]
>>>
let l = mkVariant _left 1 ty
>>>
let r = mkVariant _right 2 ty
>>>
map projectVariant [l, r] :: [Maybe (Variant '[Tagged "left" Int])]
[Just V{left=1},Nothing]
is one implementation
of rearrangeVariant
= fromJust
. projectVariant
rearrangeVariant
, since the result can have the same fields with
a different order:
>>>
let yt = Proxy :: Proxy [Tagged "right" Int, Tagged "left" Int]
>>>
map projectVariant [l, r] `asTypeOf` [Just (mkVariant _left 0 yt)]
[Just V{left=1},Just V{right=2}]
Instances
ProjectVariant x ('[] :: [Type]) Source # | |
Defined in Data.HList.Variant | |
(ProjectVariant x ys, HasField t (Variant x) (Maybe y), HOccursNot (Label t) (LabelsOf ys), ty ~ Tagged t y) => ProjectVariant x (ty ': ys) Source # | |
Defined in Data.HList.Variant |
class (HAllTaggedLV y, HAllTaggedLV x) => ExtendsVariant x y where Source #
projectVariant . extendsVariant = Just
(when the types match up)
extendVariant
is a special case
extendsVariant :: Variant x -> Variant y Source #
Instances
(HAllTaggedLV x, Unvariant '[le] e, MkVariant l e x, le ~ Tagged l e) => ExtendsVariant '[le] x Source # | |
Defined in Data.HList.Variant extendsVariant :: Variant '[le] -> Variant x Source # | |
(MkVariant l e y, le ~ Tagged l e, ExtendsVariant (b ': bs) y) => ExtendsVariant (le ': (b ': bs)) y Source # | |
Defined in Data.HList.Variant extendsVariant :: Variant (le ': (b ': bs)) -> Variant y Source # |
class HAllTaggedLV y => ProjectExtendVariant x y where Source #
projectExtendVariant = fmapextendVariant
.projectVariant
where intermediate variant is as large as possible. Used to implement
Data.HList.Labelable.projected
Note that:
>>>
let r = projectExtendVariant (mkVariant1 Label 1 :: Variant '[Tagged "x" Int])
>>>
r :: Maybe (Variant '[Tagged "x" Integer])
Nothing
Instances
HAllTaggedLV y => ProjectExtendVariant ('[] :: [Type]) y Source # | |
Defined in Data.HList.Variant | |
(lv ~ Tagged l v, HMemberM lv y inY, ProjectExtendVariant' inY lv y, ProjectExtendVariant xs y) => ProjectExtendVariant (lv ': xs) y Source # | |
Defined in Data.HList.Variant |
one
class (SameLength s t, SameLabels s t) => HPrism x s t a b | x s -> a, x t -> b, x s b -> t, x t a -> s where Source #
Make a Prism (Variant s) (Variant t) a b
out of a Label.
See Data.HList.Labelable.hLens'
is a more overloaded version.
Few type annotations are necessary because of the restriction
that s
and t
have the same labels in the same order, and to
get "t" the "a" in "s" is replaced with "b".
hPrism :: (Choice p, Applicative f) => Label x -> p a (f b) -> p (Variant s) (f (Variant t)) Source #
Instances
(MkVariant x b t, HasField x (Variant s) (Maybe a), SameLength s t, SameLabels s t, H2ProjectByLabels '[Label x] s si so, H2ProjectByLabels '[Label x] t ti to, so ~ to, HUpdateAtLabel Variant x b s t, HUpdateAtLabel Variant x a t s) => HPrism (x :: k) s t a b Source # | |
Defined in Data.HList.Variant |
unvarianted :: (Unvariant' s a, Unvariant' t b, SameLabels s t, SameLength s t, Functor f) => (a -> f b) -> Variant s -> f (Variant t) Source #
Lens (Variant s) (Variant t) a b
Analogue of Control.Lens.chosen :: Lens (Either a a) (Either b b) a b
unvarianted' :: forall (b :: Bool) (t :: [Type]) a f. (Unvariant1 b t a, HAllEqVal' (Tagged () a ': t), HAllEqVal t b, HAllEqVal (Tagged () a ': t) b, SameLabels t t, SameLength' t t, Functor f) => (a -> f a) -> Variant t -> f (Variant t) Source #
Lens' (Variant s) a
where we might have s ~ '[Tagged t1 a, Tagged t2 a]
extendVariant :: Variant l -> Variant (e ': l) Source #
implementation
class Unvariant v e | v -> e where Source #
Convert a Variant which has all possibilities having the same type
into a value of that type. Analogous to either id id
.
See also unvariant'
class Unvariant' v e | v -> e where Source #
Similar to unvariant
, except type variables in v
will be made equal to e
if possible. That allows the type
of Nothing
to be inferred as Maybe Char
.
>>>
unvariant' $ x .=. Nothing .*. mkVariant1 y 'y'
'y'
However, this difference leads to more local error messages
(Couldn't match type ‘()’ with ‘Char’
), rather than the following
with unvariant
:
Fail '("Variant", '[Tagged "left" Char, Tagged "right" ()], "must have all values equal to ", e))
unvariant' :: Variant v -> e Source #
Instances
(HAllEqVal' (Tagged () e ': v), Unvariant v e) => Unvariant' v e Source # | |
Defined in Data.HList.Variant unvariant' :: Variant v -> e Source # |
Conversions between collections
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)
Instances
TypeIndexed Record TIP Source # | |
Defined in Data.HList.TIC | |
TypeIndexed Variant TIC Source # | |
Defined in Data.HList.TIC |
typeIndexed' :: forall r tr (t :: [Type]) p f. (TypeIndexed r tr, HMapAux HList TaggedFn (RecordValuesR t) t, RecordValues t, SameLabels t t, HAllTaggedLV t, HLabelSet (LabelsOf t), TagUntagFD (RecordValuesR t) (TagR (RecordValuesR t)), Profunctor p, Functor f, SameLength' t t, SameLength' (RecordValuesR t) (RecordValuesR t), Coercible (TagR (RecordValuesR t)) t) => p (tr (TagR (RecordValuesR t))) (f (tr (TagR (RecordValuesR t)))) -> p (r t) (f (r t)) Source #
HList and Record
HList and TIP
tipHList :: forall p f (a1 :: [Type]) (ta :: [Type]) (a2 :: [Type]) (l :: [Type]). (Profunctor p, Functor f, TagUntagFD a1 ta, TagUntagFD a2 l) => p (HList a1) (f (HList a2)) -> p (TIP ta) (f (TIP l)) Source #
Iso (TIP (TagR a)) (TIP (TagR b)) (HList a) (HList b)
tipHList' :: forall p f (a :: [Type]) (l :: [Type]). (Profunctor p, Functor f, TagUntagFD a l) => p (HList a) (f (HList a)) -> p (TIP l) (f (TIP l)) Source #
Iso' (TIP (TagR s)) (HList a)
Record and RecordU
unboxed :: forall x y f p. (Profunctor p, Functor f, RecordToRecordU x, RecordUToRecord y) => (RecordU x `p` f (RecordU y)) -> Record x `p` f (Record y) Source #
Iso (Record x) (Record y) (RecordU x) (RecordU y)
unboxed' :: forall p f (y :: [Type]) (n :: HNat). (Profunctor p, Functor f, RecordValues y, HList2List (RecordValuesR y) (GetElemTy y), KnownNat (HNat2Nat n), HLengthEq1 y n, HLengthEq2 y n, IArray UArray (GetElemTy y), SameLength' (HReplicateR n ()) y, HMapAux HList TaggedFn (RecordValuesR y) y) => p (RecordU y) (f (RecordU y)) -> p (Record y) (f (Record y)) Source #
Iso' (Record x) (RecordU x)
Record and RecordUS
unboxedS :: forall (g1 :: [Type]) (u1 :: [Type]) (g2 :: [Type]) (u2 :: [Type]) (x1 :: [Type]) (x2 :: [Type]) p f. (HMapUnboxF g1 u1, HMapUnboxF g2 u2, HGroupBy EqTagValue x1 g1, HGroupBy EqTagValue x2 g2, Profunctor p, Functor f, HConcatFD g1 x1, SameLength' u2 g2, SameLength' g2 u2, SameLength' u1 g1, SameLength' g1 u1, HMapAux HList UnboxF g2 u2, HMapAux HList BoxF u1 g1) => p (RecordUS x2) (f (RecordUS x1)) -> p (Record x2) (f (Record x1)) Source #
Iso (Record x) (Record y) (RecordUS x) (RecordUS y)
unboxedS' :: forall (g :: [Type]) (u :: [Type]) (x :: [Type]) p f. (HMapUnboxF g u, HGroupBy EqTagValue x g, Profunctor p, Functor f, HConcatFD g x, SameLength' u g, SameLength' g u, HMapAux HList UnboxF g u, HMapAux HList BoxF u g) => p (RecordUS x) (f (RecordUS x)) -> p (Record x) (f (Record x)) Source #
Iso' (Record x) (RecordUS x)
Record and Variant
hMaybied :: forall (x :: [Type]) (v1 :: [Type]) (v2 :: [Type]) (r :: [Type]) p f. (HFoldr HMaybiedToVariantFs [Variant ('[] :: [Type])] x [Variant v1], VariantToHMaybied v2 r, VariantToHMaybied v1 x, SameLength' x r, SameLength' r x, HMapAux HList (HFmap HCastF) x r, Choice p, Applicative f) => p (Variant v1) (f (Variant v2)) -> p (Record x) (f (Record r)) Source #
Prism (Record tma) (Record tmb) (Variant ta) (Variant tb)
see hMaybied'
hMaybied' :: forall (x :: [Type]) (v :: [Type]) p f. (HFoldr HMaybiedToVariantFs [Variant ('[] :: [Type])] x [Variant v], VariantToHMaybied v x, SameLength' x x, HMapAux HList (HFmap HCastF) x x, Choice p, Applicative f) => p (Variant v) (f (Variant v)) -> p (Record x) (f (Record x)) Source #
Prism' (Record tma) (Variant ta)
where tma
and tmb
are lists like
tma ~ '[Tagged x (Maybe a), Tagged y (Maybe b)] ta ~ '[Tagged x a , Tagged y b ]
If one element of the record is Just, the Variant will contain that element. Otherwise, the prism fails.
Note
The types work out to define a prism:
l =prism'
variantToHMaybied
(listToMaybe
.hMaybiedToVariants
)
but the law: s^?l ≡ Just a ==> l # a ≡ s
is not followed,
because we could have:
s, s2 :: Record '[Tagged "x" (Maybe Int), Tagged "y" (Maybe Char)] s = hBuild (Just 1) (Just '2') s2 = hBuild (Just 1) Nothing v :: Variant '[Tagged "x" Int, Tagged "y" Char] v = mkVariant (Label :: Label "x") 1 Proxy
So that s^?l == Just v
. But l#v == s2 /= s
, while the law
requires l#v == s
. hMaybied avoids this problem by only
producing a value when there is only one present.
Newtype wrappers
hListRecord
hListRecord'
are exported under Data.HList.Record
ticVariant :: forall p f (l1 :: [Type]) (l2 :: [Type]). (Profunctor p, Functor f) => p (Variant l1) (f (Variant l2)) -> p (TIC l1) (f (TIC l2)) Source #
Iso (TIC s) (TIC t) (Variant s) (Variant t)
typeIndexed
may be more appropriate
ticVariant' :: forall p f (l :: [Type]). (Profunctor p, Functor f) => p (Variant l) (f (Variant l)) -> p (TIC l) (f (TIC l)) Source #
Iso' (TIC s) (Variant s)
tipRecord :: forall p f (r :: [Type]) (l :: [Type]). (Profunctor p, Functor f) => p (Record r) (f (Record l)) -> p (TIP r) (f (TIP l)) Source #
Iso (TIP s) (TIP t) (Record s) (Record t)
typeIndexed
may be more appropriate
tipRecord' :: forall p f (l :: [Type]). (Profunctor p, Functor f) => p (Record l) (f (Record l)) -> p (TIP l) (f (TIP l)) Source #
Iso' (TIP (TagR s)) (Record a)
implementation
class VariantToHMaybied v r | v -> r, r -> v where Source #
variantToHMaybied :: Variant v -> Record r Source #
Instances
VariantToHMaybied ('[] :: [Type]) ('[] :: [Type]) Source # | |
Defined in Data.HList.Variant variantToHMaybied :: Variant '[] -> Record '[] Source # | |
(VariantToHMaybied v r, HReplicateF nr ConstTaggedNothing () r, tx ~ Tagged t x, tmx ~ Tagged t (Maybe x)) => VariantToHMaybied (tx ': v) (tmx ': r) Source # | |
Defined in Data.HList.Variant variantToHMaybied :: Variant (tx ': v) -> Record (tmx ': r) Source # |
data HMaybiedToVariantFs Source #
hMaybiedToVariants :: (HFoldr HMaybiedToVariantFs [Variant '[]] r [Variant v], VariantToHMaybied v r) => Record r -> [Variant v] Source #
Every element of the record that is Just becomes one element
in the resulting list. See hMaybied'
example types that r
and v
can take.
Data.HList.Keyword
the "public" parts. More examples are in the module documentation.
class Kw (fn :: *) (arg_def :: [*]) r where Source #
kw
takes a HList
whose first element is a function, and the rest
of the elements are default values.
A useful trick is to have a final argument ()
which is not
eaten up by a label (A only takes 1 argument). That way when you supply
the () it knows there are no more arguments (?).
>>>
data A = A
>>>
instance IsKeyFN (A -> a -> b) True
>>>
let f A a () = a + 1
>>>
let f' = f .*. A .*. 1 .*. HNil
>>>
kw f' A 0 ()
1
>>>
kw f' ()
2
recToKW :: forall a b. (HMapCxt HList TaggedToKW a b, HConcat b) => Record a -> HList (HConcatR b) Source #
convert a Record
into a list that can supply
default arguments for kw
A bit of setup:
>>>
:set -XQuasiQuotes
>>>
import Data.HList.RecordPuns
>>>
let f (_ :: Label "a") a (_ :: Label "b") b () = a `div` b
>>>
let a = 2; b = 1; f' = f .*. recToKW [pun| a b |]
>>>
kw f' ()
2
>>>
kw f' (Label :: Label "a") 10 ()
10
class IsKeyFN (t :: *) (flag :: Bool) | t -> flag Source #
All our keywords must be registered
Instances
'False ~ flag => IsKeyFN t flag Source # | overlapping/fallback case |
Defined in Data.HList.TypeEqO | |
IsKeyFN (Label s -> a -> b) 'True Source # | labels that impose no restriction on the type of the (single) argument which follows
|
Defined in Data.HList.Keyword | |
r ~ (c -> b) => IsKeyFN (K s c -> r) 'True Source # | The purpose of this instance is to be able to use the same Symbol
(type-level string) at different types. If they are supposed to be the same,
then use
therefore the following options works:
But you cannot leave off all |
Defined in Data.HList.Keyword |
Instances
r ~ (c -> b) => IsKeyFN (K s c -> r) 'True Source # | The purpose of this instance is to be able to use the same Symbol
(type-level string) at different types. If they are supposed to be the same,
then use
therefore the following options works:
But you cannot leave off all |
Defined in Data.HList.Keyword |
data ErrReqdArgNotFound x Source #
data ErrUnexpectedKW x Source #
Labels
By labels, we mean either the first argument to Tagged
(in the
type-level lists that are supplied to Record
, RecordU
, TIP
, TIC
),
or the expressions used to specify those types to be able to look up
the correct value in those collections.
Nearly all types can be labels. For example:
r :: Record '[Tagged "x" Int, -- kind GHC.TypeLits.Symbol Tagged () (), -- see Data.HList.Label5 Tagged (Lbl HZero LabelUniverse LabelMember1) () -- Label3 ] r =hBuild
8 () () -- don't need to use.=.
/.==.
and.*.
-- if we have a type signature above
we could define these variables
xLabel = Label :: Label "x" --makeLabels6
["x"] would define x with the same RHS xLens = hLens' xLabel --makeLabelable
"x" would define x with the same RHS
to access the 8
given above:
r .!.
xLabel
r ^. xLens -- alternatively Control.Lens.view
r ^. `x -- with HListPP is used (not in ghci),
-- which avoids the issue of conflicting
-- definitions of x, which mean the same
-- thing
Instances from Data.HList.Label6
>>>
:set -XDataKinds
>>>
(Label :: Label "x") .=. (5::Int) .*. emptyRecord
Record{x=5}
>>>
let x = Label :: Label "x"
>>>
let r = x .=. (5::Int) .*. emptyRecord
>>>
r .!. x
5
class Projected r s t a b where Source #
Sometimes it may be more convenient to operate on a record/variant
that only contains the fields of interest. projected
can then be used
to apply that function to a record that contains additional elements.
>>>
:set -XViewPatterns
>>>
import Data.HList.RecordPuns
>>>
let f [pun| (x y) |] = case x+y of z -> [pun| z |]
>>>
:t f
f :: Num v => Record '[Tagged "x" v, Tagged "y" v] -> Record '[Tagged "z" v]
>>>
let r = (let x = 1; y = 2; z = () in [pun| x y z |])
>>>
r
Record{x=1,y=2,z=()}
>>>
r & sameLabels . projected %~ f
Record{x=1,y=2,z=3}
projected :: (ty ~ LabelableTy r, LabeledOpticP ty p, LabeledOpticF ty f) => (r a `p` f (r b)) -> r s `p` f (r t) Source #
Instances
(H2ProjectByLabels (LabelsOf a) s a_ _s_minus_a, HRLabelSet a_, HRLabelSet a, HRearrange (LabelsOf a) a_ a, HLeftUnion b s bs, HRLabelSet bs, HRearrange (LabelsOf t) bs t, HRLabelSet t) => Projected Record s t a b Source # | Lens rs rt ra rb where |
Defined in Data.HList.Labelable projected :: forall (ty :: LabeledOpticType) p f. (ty ~ LabelableTy Record, LabeledOpticP ty p, LabeledOpticF ty f) => p (Record a) (f (Record b)) -> p (Record s) (f (Record t)) Source # | |
(ExtendsVariant b t, ProjectVariant s a, ProjectExtendVariant s t, HLeftUnion b s bs, HRLabelSet bs, HRearrange (LabelsOf t) bs t) => Projected Variant s t a b Source # | Prism (Variant s) (Variant t) (Variant a) (Variant b) |
Defined in Data.HList.Labelable projected :: forall (ty :: LabeledOpticType) p f. (ty ~ LabelableTy Variant, LabeledOpticP ty p, LabeledOpticF ty f) => p (Variant a) (f (Variant b)) -> p (Variant s) (f (Variant t)) Source # |
toLabel :: EnsureLabel x y => x -> y Source #
class SameLength s t => Labelable (x :: k) (r :: [*] -> *) s t a b | x s -> a, x t -> b, x s b -> t, x t a -> s where Source #
type LabelableTy r :: LabeledOpticType Source #
hLens' :: Label x -> LabeledOptic x r s t a b Source #
Instances
LabelableTIPCxt x s t a b => Labelable (x :: k) TIP s t a b Source # | make a
|
Defined in Data.HList.Labelable type LabelableTy TIP :: LabeledOpticType Source # | |
(TICPrism s t a b, Label x ~ Label a, a ~ b, s ~ t, SameLength s t) => Labelable (x :: k) TIC s t a b Source # | hLens' :: Label a -> Prism' (TIC s) a note that a more general function Note: `x :: k` according to the instance head, but the instance body forces the kind variable to be * later on. IE. (k ~ *) |
Defined in Data.HList.Labelable type LabelableTy TIC :: LabeledOpticType Source # | |
(HPrism x s t a b, to ~ ((->) :: Type -> Type -> Type)) => Labelable (x :: k) Variant s t a b Source # | make a |
Defined in Data.HList.Labelable type LabelableTy Variant :: LabeledOpticType Source # | |
HLens x Record s t a b => Labelable (x :: k) Record s t a b Source # | make a |
Defined in Data.HList.Labelable type LabelableTy Record :: LabeledOpticType Source # | |
LabeledCxt1 s t a b => Labelable (x :: k) LabeledR s t a b Source # | |
Defined in Data.HList.Labelable type LabelableTy LabeledR :: LabeledOpticType Source # | |
(s ~ t, a ~ b, IArray UArray a, a ~ GetElemTy s, HLensCxt x RecordU s t a b) => Labelable (x :: k) RecordU s t a b Source # | make a |
Defined in Data.HList.RecordU type LabelableTy RecordU :: LabeledOpticType Source # |
type LabeledOptic (x :: k) (r :: [*] -> *) (s :: [*]) (t :: [*]) (a :: *) (b :: *) = forall ty to p f. (ty ~ LabelableTy r, LabeledOpticF ty f, LabeledOpticP ty p, LabeledOpticTo ty x to) => (a `p` f b) `to` (r s `p` f (r t)) Source #
This alias is the same as Control.Lens.Optic, except the (->) in Optic
is a type parameter to
in LabeledOptic.
Depending on the collection type (see instances of LabelableTy
),
the type variables to, p, f
are constrained such that the resulting
type is a Lens (r s) (r t) a b
, Prism (r s) (r t) a b
or a
LabeledTo x _ _
. The latter can be used to recover the label (x
) when
used as an argument to .==.
or equivalently toLabel
.
(.==.) :: forall k x (l :: k) v. EnsureLabel x (Label l) => x -> v -> Tagged l v infixr 4 Source #
modification of .=.
which works with the labels from this module,
and those from Data.HList.Label6. Note that this is not strictly a
generalization of .=.
, since it does not work with labels like
Data.HList.Label3 which have the wrong kind.
projected' :: forall r p f (t :: [Type]) (b :: [Type]). (LabeledOpticP (LabelableTy r) p, LabeledOpticF (LabelableTy r) f, Projected r t t b b) => p (r b) (f (r b)) -> p (r t) (f (r t)) Source #
Lens' (Record s) (Record a)
Prism' (Variant s) (Variant a)
Rather than having the x = Label :: Label "x"
, the labels
generated by makeLabelable
also double as lenses for Control.Lens.
Here is an example of how much better that is:
>>>
:set -XNoMonomorphismRestriction -XDataKinds -XPolyKinds
>>>
import Control.Lens
>>>
import Data.HList.Labelable
>>>
let x = hLens' (Label :: Label "x")
>>>
let y = hLens' (Label :: Label "y")
The Label6 method:
>>>
let r = (Label :: Label "x") .=. "5" .*. emptyRecord
The Labelable way:
>>>
let r2 = x .==. "5" .*. emptyRecord
>>>
r ^. x
"5"
>>>
r2 ^. x
"5"
>>>
r & x .~ ()
Record{x=()}
When a field is missing, the error names that field:
>>>
:t r^.y
... ...No instance for (Fail (FieldNotFound "y")) ...
Data.HList.Dredge
lenses
dredge :: forall k1 k2 (vs1 :: [Type]) (ns1 :: [[Type]]) (vs :: [Type]) (ns :: [[Type]]) (xs :: [Type]) p v (fb :: k1) r (rft :: k1) (l :: k2) (ns2 :: [[Type]]) x. (SameLength' vs1 ns1, SameLength' vs ns, SameLength' ns1 vs1, SameLength' ns vs, LabelablePath xs (p v fb) (p r rft), MapFieldTree (TryCollectionListTF r) ns, MapFieldTreeVal r (TryCollectionListTF r) vs, FilterLastEq (Label l) ns ns ns1, FilterLastEq (Label l) ns vs vs1, FilterVEq1 v vs1 ns1 ns2, HGuardNonNull (NamesDontMatch r ns l) ns1, HSingleton (NonUnique r v l) (TypesDontMatch r ns1 vs1 v) ns2 xs, EnsureLabel x (Label l)) => x -> p v fb -> p r rft Source #
Using HListPP syntax for short hand, dredge `foo
expands out to
something like `path . `to . `foo
, with the restriction that
there is only one possible `path . `to
which leads to the
label foo
.
For example, if we have the following definitions,
type BVal a = Record '[Tagged "x" a, Tagged "a" Char] type R a = Record [Tagged "a" Int, Tagged "b" (BVal a)] type V a = Variant [Tagged "a" Int, Tagged "b" (BVal a)] lx = Label :: Label "x"
Then we have:
dredge `x :: Lens (R a) (R b) a b dredge lx :: Lens (R a) (R b) a b
dredge `x :: Traversal (V a) (V b) a b -- there were only variants along the path we'd get a Prism dredge lx :: Traversal (V a) (V b) a b
result-type directed operations are supported
There are two ways to access a field with tag a
in the R type
defined above, but they result in fields with different types
being looked up:
`a :: Lens' (R a) Char `b . `a :: Lens' (R a) Int
so provided that the result type is disambiguated by the context, the following two types can happen
dredge `a :: Lens' (R a) Char dredge `a :: Lens' (R a) Int
TIP & TIC
type indexed collections are allowed along those paths, but
as explained in the Labelable
instances, only simple optics
(Lens' Prism' Traversal' ) are produced. dredgeTI'
works better if the target is a TIP or TIC
dredge' :: forall k2 k (vs1 :: [Type]) (ns1 :: [[Type]]) (vs :: [Type]) (ns :: [[Type]]) (xs :: [Type]) p a (f :: Type -> k2) s (l :: k) (ns2 :: [[Type]]) x. (SameLength' vs1 ns1, SameLength' vs ns, SameLength' ns1 vs1, SameLength' ns vs, LabelablePath xs (p a (f a)) (p s (f s)), MapFieldTree (TryCollectionListTF s) ns, MapFieldTreeVal s (TryCollectionListTF s) vs, FilterLastEq (Label l) ns ns ns1, FilterLastEq (Label l) ns vs vs1, FilterVEq1 a vs1 ns1 ns2, HGuardNonNull (NamesDontMatch s ns l) ns1, HSingleton (NonUnique s a l) (TypesDontMatch s ns1 vs1 a) ns2 xs, EnsureLabel x (Label l)) => x -> p a (f a) -> p s (f s) Source #
dredge
except a simple (s ~ t, a ~ b) optic is produced
dredgeND :: forall k1 k2 (xs :: [Type]) p a (fb :: k1) r (rft :: k1) (ns :: [[Type]]) (l :: k2) (ns' :: [[Type]]) x. (LabelablePath xs (p a fb) (p r rft), MapFieldTree (TryCollectionListTF r) ns, FilterLastEq (Label l) ns ns ns', HSingleton (NonUnique' r l) (NamesDontMatch r ns l) ns' xs, EnsureLabel x (Label l)) => x -> p a fb -> p r rft Source #
dredgeND (named directed only) is the same as dredge
, except the
result type (a
) is not used when the label would otherwise
be ambiguous. dredgeND might give better type errors, but otherwise
there should be no reason to pick it over dredge
dredgeND' :: forall k2 k (xs :: [Type]) p a (f :: Type -> k2) s (ns :: [[Type]]) (l :: k) (ns' :: [[Type]]) x. (LabelablePath xs (p a (f a)) (p s (f s)), MapFieldTree (TryCollectionListTF s) ns, FilterLastEq (Label l) ns ns ns', HSingleton (NonUnique' s l) (NamesDontMatch s ns l) ns' xs, EnsureLabel x (Label l)) => x -> p a (f a) -> p s (f s) Source #
dredgeND
except a simple (s ~ t, a ~ b) optic is produced
dredgeTI' :: forall k2 (xs :: [Type]) p a (f :: Type -> k2) s (ns :: [[Type]]) (ns' :: [[Type]]) q. (LabelablePath xs (p a (f a)) (p s (f s)), MapFieldTree (TryCollectionListTF s) ns, FilterLastEq (Label a) ns ns ns', HSingleton (NonUnique' s a) (NamesDontMatch s ns a) ns' xs) => q a -> p a (f a) -> p s (f s) Source #
The same as dredgeND', except intended for TIP/TICs because
the assumption is made that l ~ v
for the Tagged l v
elements.
In other words, ticPrism' and tipyLens'
could usually
be replaced by
dredgeTI' :: _ => Label a -> Lens' (TIP s) a dredgeTI' :: _ => Label a -> Prism' (TIC s) a
where we might have s ~ '[Tagged a a, Tagged b b]
plain lookup
hLookupByLabelDredge :: forall k (ls :: [Type]) r1 r2 v (ns :: [[Type]]) (l :: k) (ns' :: [[Type]]). (HasFieldPath 'False ls (r1 r2) v, MapFieldTree (TryCollectionListTF r2) ns, FilterLastEq (Label l) ns ns ns', HSingleton (NonUnique' r2 l) (NamesDontMatch r2 ns l) ns' ls) => Label l -> r1 r2 -> v Source #
class HasFieldPath (needJust :: Bool) (ls :: [*]) r v | needJust ls r -> v Source #
Instances
HasFieldPath 'False ('[] :: [Type]) v v Source # | |
Defined in Data.HList.Dredge | |
HasFieldPath 'True ('[] :: [Type]) v (Maybe v) Source # | |
Defined in Data.HList.Dredge | |
(HasField l (Record r) u, HasFieldPath needJust ls u v) => HasFieldPath needJust (Label l ': ls) (Record r) v Source # | |
Defined in Data.HList.Dredge | |
(HasField l (Variant r) (Maybe u), HasFieldPath 'True ls u (Maybe v)) => HasFieldPath needJust (Label l ': ls) (Variant r) (Maybe v) Source # | |
Defined in Data.HList.Dredge |
namespaced labels
data Lbl (x :: HNat) (ns :: *) (desc :: *) Source #
Instances
(HEqBy HLeFn n m b, ns ~ ns') => HEqBy HLeFn (Lbl n ns desc :: Type) (Lbl m ns' desc' :: Type) b Source # | Data.HList.Label3 labels can only be compared if they belong to the same namespace. |
Defined in Data.HList.HSort | |
Label t ~ Label (Lbl ix ns n) => SameLabels (Label t :: Type) (Lbl ix ns n :: Type) Source # | |
Defined in Data.HList.Label3 | |
Show desc => ShowLabel (Lbl x ns desc :: Type) Source # | Equality on labels (descriptions are ignored) Use generic instance Show label |
Show desc => Show (Label (Lbl x ns desc)) Source # | |
(to ~ LabeledTo x, ToSym (to p q) x) => HExtend (to p q) (Proxy (Lbl n ns desc ': xs)) Source # | if the proxy has Data.HList.Label3.Lbl, then everything has to be wrapped in Label to make the kinds match up. |
HExtend (Label (Lbl n ns desc)) (Proxy (x ': xs)) Source # | Mixing two label kinds means we have to include
|
HExtend (Label (Lbl n ns desc)) (Proxy (Lbl n' ns' desc' ': xs)) Source # | If possible, Label is left off:
|
type ZipTagged (Lbl ix ns n ': ts :: [Type]) (v ': vs) Source # | |
type HExtendR (to p q) (Proxy (Lbl n ns desc ': xs)) Source # | |
Defined in Data.HList.Labelable | |
type HExtendR (Label (Lbl n ns desc)) (Proxy (Lbl n' ns' desc' ': xs)) Source # | |
type HExtendR (Label (Lbl n ns desc)) (Proxy (x ': xs)) Source # | |
nextLabel :: Label (Lbl x ns desc) -> desc' -> Label (Lbl (HSucc x) ns desc') Source #
Construct the next label
labels as any instance of Typeable
template haskell
module Data.HList.MakeLabels
Data.HList.Data
This modules provide useful instances. A useful application can be
found in examples/cmdargs.hs
Overlapping instances are restricted to here
class TupleType (t :: *) (b :: Bool) | t -> b Source #
Instances
TupleType () 'True Source # | |
Defined in Data.HList.TypeEqO | |
'False ~ b => TupleType x b Source # | |
Defined in Data.HList.TypeEqO | |
TupleType (x, y) 'True Source # | |
Defined in Data.HList.TypeEqO | |
TupleType (x, y, z) 'True Source # | |
Defined in Data.HList.TypeEqO |
Internals
internals exported for type signature purposes
class HAllTaggedEq (l :: [*]) Source #
Instances
HAllTaggedEq ('[] :: [Type]) Source # | |
Defined in Data.HList.TIP | |
(HAllTaggedEq l, tee ~ Tagged e e') => HAllTaggedEq (tee ': l) Source # | |
Defined in Data.HList.TIP |