-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Surgery for generic data types -- -- Transform data types before passing them to generic functions. @package generic-data-surgery @version 0.3.0.0 -- | Operate on data types: insert/modify/delete fields and constructors. module Generic.Data.Surgery.Internal -- | A sterile Operating Room, where generic data comes to be -- altered. -- -- Generic representation in a simplified shape l at the type -- level (reusing the constructors from GHC.Generics for -- convenience). This representation makes it easy to modify fields and -- constructors. -- -- We may also refer to the representation l as a "row" of -- constructors, if it represents a sum type, otherwise it is a "row" of -- unnamed fields or record fields for single-constructor types. -- -- x corresponds to the last parameter of Rep, and is -- currently ignored by this module (no support for Generic1). -- --
-- toOR surgeries fromOR' -- data MyType --------> OR (Rep MyType) ----------> OR alteredRep ---------> Data alteredRep -- | -- | myGenericFun :: Generic a => a -> a -- fromOR surgeries toOR' v -- data MyType <-------- OR (Rep MyType) <---------- OR alteredRep <--------- Data alteredRep ---- -- If instead myGenericFun is only a consumer of a -- (resp. producer), then you only need the top half of the diagram -- (resp. bottom half). For example, in aeson: genericToJSON -- (consumer), genericParseJSON (producer). newtype OR (l :: k -> Type) (x :: k) OR :: l x -> OR [unOR] :: OR -> l x -- | Move fresh data to the Operating Room, where surgeries can be -- applied. -- -- Convert a generic type to a generic representation. -- -- When inserting or removing fields, there may be a mismatch with -- strict/unpacked fields. To work around this, you can switch to -- toORLazy, if your operations don't care about dealing with a -- normalized Rep (in which all the strictness annotations have -- been replaced with lazy defaults). -- --
-- a :: Type -- Generic type -- l :: k -> Type -- Generic representation (simplified) -- x :: k -- Ignored ---- --
-- a -> l --toOR :: forall a l x. (Generic a, ToORRep a l) => a -> OR l x -- | Move normalized data to the Operating Room, where surgeries can be -- applied. -- -- Convert a generic type to a generic representation, in which all the -- strictness annotations have been normalized to lazy defaults. -- -- This variant is useful when one needs to operate on fields whose -- Rep has different strictness annotations than the ones used by -- DefaultMetaSel. -- --
-- a :: Type -- Generic type -- l :: k -> Type -- Generic representation (simplified and normalized) -- x :: k -- Ignored ---- --
-- a -> l --toORLazy :: forall a l x. (Generic a, ToORRepLazy a l) => a -> OR l x -- | Move altered data out of the Operating Room, to be consumed by -- some generic function. -- -- Convert a generic representation to a "synthetic" type that behaves -- like a generic type. -- --
-- f :: k -> Type -- Generic representation (proper) -- l :: k -> Type -- Generic representation (simplified) -- x :: k -- Ignored ---- --
-- f -> l -- l -> f ---- --
-- f :: k -> Type -- Generic representation (proper) -- l :: k -> Type -- Generic representation (simplified) -- x :: k -- Ignored ---- --
-- f -> l -- l -> f --toOR' :: forall f l x. ToOR f l => Data f x -> OR l x -- | Move restored data out of the Operating Room and back to the -- real world. -- -- The inverse of toOR. -- -- It may be useful to annotate the output type of fromOR, since -- the rest of the type depends on it and the only way to infer it -- otherwise is from the context. The following annotations are possible: -- --
-- fromOR :: OROf a -> a -- fromOR @a -- with TypeApplications ---- -- When inserting or removing fields, there may be a mismatch with -- strict/unpacked fields. To work around this, you can switch to -- fromORLazy, if your operations don't care about dealing with a -- normalized Rep (in which all the strictness annotations have -- been replaced with lazy defaults). -- --
-- a :: Type -- Generic type -- l :: k -> Type -- Generic representation (simplified) -- x :: k -- Ignored ---- --
-- a -> l --fromOR :: forall a l x. (Generic a, FromORRep a l) => OR l x -> a -- | Move normalized data out of the Operating Room and back to the -- real world. -- -- The inverse of toORLazy. -- -- It may be useful to annotate the output type of fromORLazy, -- since the rest of the type depends on it and the only way to infer it -- otherwise is from the context. The following annotations are possible: -- --
-- fromORLazy :: OROfLazy a -> a -- fromORLazy @a -- with TypeApplications ---- --
-- a :: Type -- Generic type -- l :: k -> Type -- Generic representation (simplified and normalized) -- x :: k -- Ignored ---- --
-- a -> l --fromORLazy :: forall a l x. (Generic a, FromORRepLazy a l) => OR l x -> a -- | The simplified generic representation type of type a, that -- toOR and fromOR convert to and from. type OROf a = OR (Linearize (Rep a)) () -- | The simplified and normalized generic representation type of type -- a, that toORLazy and fromORLazy convert to and -- from. type OROfLazy a = OR (Linearize (Lazify (Rep a))) () -- | This constraint means that a is convertible to its -- simplified generic representation. Implies OROf a ~ -- OR l (). type ToORRep a l = ToOR (Rep a) l -- | This constraint means that a is convertible from its -- simplified generic representation. Implies OROf a ~ -- OR l (). type FromORRep a l = FromOR (Rep a) l -- | Similar to ToORRep, but as a constraint on the standard generic -- representation of a directly, f ~ Rep a. type ToOR f l = (GLinearize f, Linearize f ~ l, f ~ Arborify l) -- | Similar to FromORRep, but as a constraint on the standard -- generic representation of a directly, f ~ Rep -- a. type FromOR f l = (GArborify f, Linearize f ~ l, f ~ Arborify l) -- | This constraint means that a is convertible to its -- simplified and normalized generic representation (i.e., with all its -- strictness annotations normalized to lazy defaults). Implies -- OROfLazy a ~ OR l (). type ToORRepLazy a l = ToORLazy (Rep a) l -- | This constraint means that a is convertible from its -- simplified and normalized generic representation (i.e., with all its -- strictness annotations normalized to lazy defaults). Implies -- OROfLazy a ~ OR l (). type FromORRepLazy a l = FromORLazy (Rep a) l -- | Similar to FromLazyORRep, but as a constraint on the standard -- generic representation of a directly, f ~ Rep -- a. type FromORLazy f l = (FromOR (Lazify f) l, Coercible (Arborify l) f) -- | Similar to ToORRepLazy, but as a constraint on the standard -- generic representation of a directly, f ~ Rep -- a. type ToORLazy f l = (ToOR (Lazify f) l, Coercible f (Arborify l)) -- | removeCField @n @t: remove the n-th field, of -- type t, in a non-record single-constructor type. -- -- Inverse of insertCField. -- --
-- n :: Nat -- Field position -- t :: Type -- Field type -- lt :: k -> Type -- Row with field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- OR lt x -- Data with field -- -> -- (t, OR l x) -- Field value × Data without field ---- --
-- n lt -> t l -- n t l -> lt --removeCField :: forall n t lt l x. RmvCField n t lt l => OR lt x -> (t, OR l x) -- | removeRField @"fdName" @n @t: remove the field -- fdName at position n of type t in a record -- type. -- -- Inverse of insertRField. -- --
-- fd :: Symbol -- Field name -- n :: Nat -- Field position -- t :: Type -- Field type -- lt :: k -> Type -- Row with field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- OR lt x -- Data with field -- -> -- (t, OR l x) -- Field value × Data without field ---- --
-- fd lt -> n t l -- n lt -> fd t l -- fd n t l -> lt --removeRField :: forall fd n t lt l x. RmvRField fd n t lt l => OR lt x -> (t, OR l x) -- | insertCField @n @t: insert a field of type t -- at position n in a non-record single-constructor type. -- -- Inverse of removeCField. -- --
-- n :: Nat -- Field position -- t :: Type -- Field type -- lt :: k -> Type -- Row with field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- (t, OR l x) -- Field value × Data without field -- -> -- OR lt x -- Data with field ---- --
-- n lt -> t l -- n t l -> lt --insertCField :: forall n t lt l x. InsCField n t lt l => (t, OR l x) -> OR lt x -- | Curried insertCField. insertCField' :: forall n t lt l x. InsCField n t lt l => t -> OR l x -> OR lt x -- | insertRField @"fdName" @n @t: insert a field named -- fdName of type t at position n in a record -- type. -- -- Inverse of removeRField. -- --
-- fd :: Symbol -- Field name -- n :: Nat -- Field position -- t :: Type -- Field type -- lt :: k -> Type -- Row with field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- (t, OR l x) -- Field value × Data without field -- -> -- OR lt x -- Data with field ---- --
-- fd lt -> n t l -- n lt -> fd t l -- fd n t l -> lt --insertRField :: forall fd n t lt l x. InsRField fd n t lt l => (t, OR l x) -> OR lt x -- | Curried insertRField. insertRField' :: forall fd n t lt l x. InsRField fd n t lt l => t -> OR l x -> OR lt x -- | modifyCField @n @t @t': modify the field at position -- n in a non-record via a function f :: t -> t' -- (changing the type of the field). -- --
-- n :: Nat -- Field position -- t :: Type -- Initial field type -- t' :: Type -- Final field type -- lt :: k -> Type -- Row with initial field -- lt' :: k -> Type -- Row with final field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- (t -> t') -- Field modification -- -> -- OR lt x -- Data with field t -- -> -- OR lt' x -- Data with field t' ---- --
-- n lt -> t l -- n lt' -> t' l -- n t l -> lt -- n t' l -> lt' --modifyCField :: forall n t t' lt lt' l x. ModCField n t t' lt lt' l => (t -> t') -> OR lt x -> OR lt' x -- | modifyRField @"fdName" @n @t @t': modify the field -- fdName at position n in a record via a function -- f :: t -> t' (changing the type of the field). -- --
-- fd :: Symbol -- Field name -- n :: Nat -- Field position -- t :: Type -- Initial field type -- t' :: Type -- Final field type -- lt :: k -> Type -- Row with initial field -- lt' :: k -> Type -- Row with final field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- (t -> t') -- Field modification -- -> -- OR lt x -- Data with field t -- -> -- OR lt' x -- Data with field t' ---- --
-- fd lt -> n t l -- fd lt' -> n t' l -- n lt -> fd t l -- n lt' -> fd t' l -- fd n t l -> lt -- fd n t' l -> lt' --modifyRField :: forall fd n t t' lt lt' l x. ModRField fd n t t' lt lt' l => (t -> t') -> OR lt x -> OR lt' x -- | removeConstr @"C" @n @t: remove the n-th -- constructor, named C, with contents isomorphic to the tuple -- t. -- -- Inverse of insertConstr. -- --
-- c :: Symbol -- Constructor name -- t :: Type -- Tuple type to hold c's contents -- n :: Nat -- Constructor position -- lc :: k -> Type -- Row with constructor -- l :: k -> Type -- Row without constructor -- l_t :: k -> Type -- Field row of constructor c -- x :: k -- Ignored ---- --
-- OR lc x -- Data with constructor -- -> -- Either t (OR l x) -- Constructor (as a tuple) | Data without constructor ---- --
-- c lc -> n l l_t -- n lc -> c l l_t -- c n l l_t -> lc ---- -- Note that there is no dependency to determine t. removeConstr :: forall c n t lc l x. RmvConstr c n t lc l => OR lc x -> Either t (OR l x) -- | A variant of removeConstr that can infer the tuple type -- t to hold the contents of the removed constructor. -- -- See removeConstr. -- --
-- l_t -> t --removeConstrT :: forall c n t lc l x. RmvConstrT c n t lc l => OR lc x -> Either t (OR l x) -- | insertConstr @"C" @n @t: insert a constructor -- C at position n with contents isomorphic to the -- tuple t. -- -- Inverse of removeConstr. -- --
-- c :: Symbol -- Constructor name -- t :: Type -- Tuple type to hold c's contents -- n :: Nat -- Constructor position -- lc :: k -> Type -- Row with constructor -- l :: k -> Type -- Row without constructor -- l_t :: k -> Type -- Field row of constructor c -- x :: k -- Ignored ---- --
-- Either t (OR l x) -- Constructor (as a tuple) | Data without constructor -- -> -- OR lc x -- Data with constructor ---- --
-- c lc -> n l l_t -- n lc -> c l l_t -- c n l l_t -> lc ---- -- Note that there is no dependency to determine t. insertConstr :: forall c n t lc l x. InsConstr c n t lc l => Either t (OR l x) -> OR lc x -- | A variant of insertConstr that can infer the tuple type -- t to hold the contents of the inserted constructor. -- -- See insertConstr. -- --
-- l_t -> t --insertConstrT :: forall c n t lc l x. InsConstrT c n t lc l => Either t (OR l x) -> OR lc x -- | modifyConstr @"C" @n @t @t': modify the n-th -- constructor, named C, with contents isomorphic to the tuple -- t, to another tuple t'. -- --
-- c :: Symbol -- Constructor name -- t :: Type -- Tuple type to hold c's initial contents -- t' :: Type -- Tuple type to hold c's final contents -- n :: Nat -- Constructor position -- lc :: k -> Type -- Row with initial constructor -- lc' :: k -> Type -- Row with final constructor -- l :: k -> Type -- Row without constructor -- l_t :: k -> Type -- Initial field row of constructor c -- l_t' :: k -> Type -- Final field row of constructor c -- x :: k -- Ignored ---- --
-- (t -> t') -- Constructor modification -- -> -- OR lc x -- Data with initial constructor -- -> -- OR lc' x -- Data with final constructor ---- --
-- c lc -> n l l_t -- c lc' -> n l l_t' -- n lc -> c l l_t -- n lc' -> c l l_t' -- c n l l_t -> lc -- c n l l_t' -> lc' ---- -- Note that there is no dependency to determine t and -- t'. modifyConstr :: forall c n t t' lc lc' l x. ModConstr c n t t' lc lc' l => (t -> t') -> OR lc x -> OR lc' x -- | A variant of modifyConstr that can infer the tuple types -- t and t' to hold the contents of the inserted -- constructor. -- -- See modifyConstr. -- --
-- l_t -> t -- l_t' -> t' --modifyConstrT :: forall c n t t' lc lc' l x. ModConstrT c n t t' lc lc' l => (t -> t') -> OR lc x -> OR lc' x -- | This constraint means that the (unnamed) field row lt -- contains a field of type t at position n, and -- removing it yields row l. type RmvCField n t lt l = (GRemoveField n t lt l, CFieldSurgery n t lt l) -- | This constraint means that the record field row lt contains a -- field of type t named fd at position n, and -- removing it yields row l. type RmvRField fd n t lt l = (GRemoveField n t lt l, RFieldSurgery fd n t lt l) -- | This constraint means that inserting a field t at position -- n in the (unnamed) field row l yields row -- lt. type InsCField n t lt l = (GInsertField n t l lt, CFieldSurgery n t lt l) -- | This constraint means that inserting a field t named -- fd at position n in the record field row l -- yields row lt. type InsRField fd n t lt l = (GInsertField n t l lt, RFieldSurgery fd n t lt l) -- | This constraint means that modifying a field t to t' -- at position n in the (unnamed) field row lt yields -- row lt'. l is the row of fields common to -- lt and lt'. type ModCField n t t' lt lt' l = (RmvCField n t lt l, InsCField n t' lt' l) -- | This constraint means that modifying a field t named -- fd at position n to t' in the record field -- row lt yields row lt'. l is the row of -- fields common to lt and lt'. type ModRField fd n t t' lt lt' l = (RmvRField fd n t lt l, InsRField fd n t' lt' l) -- | This constraint means that the constructor row lc contains a -- constructor named c at position n, and removing it -- from lc yields row l. Furthermore, constructor -- c contains a field row l_t compatible with the tuple -- type t. type RmvConstr c n t lc l = (GRemoveConstr n t lc l, ConstrSurgery c n t lc l (Eval (ConstrAt n lc))) -- | A variant of RmvConstr allowing t to be inferred. type RmvConstrT c n t lc l = (RmvConstr c n t lc l, IsTuple (Arity (Eval (ConstrAt n lc))) t) -- | This constraint means that inserting a constructor c at -- position n in the constructor row l yields row -- lc. Furthermore, constructor c contains a field row -- l_t compatible with the tuple type t. type InsConstr c n (t :: Type) lc l = (GInsertConstr n t l lc, ConstrSurgery c n t lc l (Eval (ConstrAt n lc))) -- | A variant of InsConstr allowing t to be inferred. type InsConstrT c n t lc l = (InsConstr c n t lc l, IsTuple (Arity (Eval (ConstrAt n lc))) t) -- | This constraint means that the constructor row lc contains a -- constructor named c at position n of type isomorphic -- to t, and modifying it to t' yields row -- lc'. type ModConstr c n t t' lc lc' l = (RmvConstr c n t lc l, InsConstr c n t' lc' l) -- | A variant of ModConstr allowing t and t' to -- be inferred. type ModConstrT c n t t' lc lc' l = (ModConstr c n t t' lc lc' l, IsTuple (Arity (Eval (ConstrAt n lc))) t, IsTuple (Arity (Eval (ConstrAt n lc'))) t') type FieldSurgery n t lt l = (t ~ Eval (FieldTypeAt n lt), l ~ Eval (RemoveField n t lt)) type CFieldSurgery n t lt l = (lt ~ Eval (InsertField n 'Nothing t l), FieldSurgery n t lt l) type RFieldSurgery fd n t lt l = (n ~ Eval (FieldIndex fd lt), lt ~ Eval (InsertField n ( 'Just fd) t l), FieldSurgery n t lt l) type ConstrSurgery c n t lc l l_t = (Generic t, MatchFields (Linearize (UnM1 (Rep t))) l_t, n ~ Eval (ConstrIndex c lc), c ~ MetaConsName (MetaOf l_t), lc ~ Eval (InsertUConstrAtL n l_t l), l ~ Eval (RemoveUConstrAt_ n lc)) type family Linearize (f :: k -> Type) :: k -> Type type family LinearizeSum (f :: k -> Type) (tl :: k -> Type) :: k -> Type type family LinearizeProduct (f :: k -> Type) (tl :: k -> Type) :: k -> Type class GLinearize f gLinearize :: GLinearize f => f x -> Linearize f x class GLinearizeSum f tl gLinearizeSum :: GLinearizeSum f tl => Either (f x) (tl x) -> LinearizeSum f tl x class GLinearizeProduct f tl gLinearizeProduct :: GLinearizeProduct f tl => f x -> tl x -> LinearizeProduct f tl x class GArborify f gArborify :: GArborify f => Linearize f x -> f x class GArborifySum f tl gArborifySum :: GArborifySum f tl => LinearizeSum f tl x -> Either (f x) (tl x) class GArborifyProduct f tl gArborifyProduct :: GArborifyProduct f tl => LinearizeProduct f tl x -> (f x, tl x) type family Arborify (f :: k -> Type) :: k -> Type data ArborifySum (n :: Nat) (f :: k -> Type) :: Exp (k -> Type) data ArborifyProduct (n :: Nat) (f :: k -> Type) :: Exp (k -> Type) type Arborify' arb op n nDiv2 f g = (Uncurry (Pure2 op) <=< Bimap (arb nDiv2) (arb (n - nDiv2)) <=< SplitAt nDiv2) (op f g) type family Lazify (f :: k -> Type) :: k -> Type type family LazifyMeta (m :: Meta) :: Meta data SplitAt :: Nat -> (k -> Type) -> Exp (k -> Type, k -> Type) -- | Kind of surgeries: operations on generic representations of types. -- -- Treat this as an abstract kind (don't pay attention to its -- definition). -- --
-- toOR surgeries fromOR' -- data MyType --------> OR (Rep MyType) ----------> OR alteredRep ---------> Data alteredRep -- | -- | myGenericFun :: Generic a => a -> a -- fromOR surgeries toOR' v -- data MyType <-------- OR (Rep MyType) <---------- OR alteredRep <--------- Data alteredRep ---- -- If instead myGenericFun is only a consumer of a -- (resp. producer), then you only need the top half of the diagram -- (resp. bottom half). For example, in aeson: genericToJSON -- (consumer), genericParseJSON (producer). data OR (l :: k -> Type) (x :: k) -- | Move fresh data to the Operating Room, where surgeries can be -- applied. -- -- Convert a generic type to a generic representation. -- -- When inserting or removing fields, there may be a mismatch with -- strict/unpacked fields. To work around this, you can switch to -- toORLazy, if your operations don't care about dealing with a -- normalized Rep (in which all the strictness annotations have -- been replaced with lazy defaults). -- --
-- a :: Type -- Generic type -- l :: k -> Type -- Generic representation (simplified) -- x :: k -- Ignored ---- --
-- a -> l --toOR :: forall a l x. (Generic a, ToORRep a l) => a -> OR l x -- | Move altered data out of the Operating Room, to be consumed by -- some generic function. -- -- Convert a generic representation to a "synthetic" type that behaves -- like a generic type. -- --
-- f :: k -> Type -- Generic representation (proper) -- l :: k -> Type -- Generic representation (simplified) -- x :: k -- Ignored ---- --
-- f -> l -- l -> f ---- --
-- f :: k -> Type -- Generic representation (proper) -- l :: k -> Type -- Generic representation (simplified) -- x :: k -- Ignored ---- --
-- f -> l -- l -> f --toOR' :: forall f l x. ToOR f l => Data f x -> OR l x -- | Move restored data out of the Operating Room and back to the -- real world. -- -- The inverse of toOR. -- -- It may be useful to annotate the output type of fromOR, since -- the rest of the type depends on it and the only way to infer it -- otherwise is from the context. The following annotations are possible: -- --
-- fromOR :: OROf a -> a -- fromOR @a -- with TypeApplications ---- -- When inserting or removing fields, there may be a mismatch with -- strict/unpacked fields. To work around this, you can switch to -- fromORLazy, if your operations don't care about dealing with a -- normalized Rep (in which all the strictness annotations have -- been replaced with lazy defaults). -- --
-- a :: Type -- Generic type -- l :: k -> Type -- Generic representation (simplified) -- x :: k -- Ignored ---- --
-- a -> l --fromOR :: forall a l x. (Generic a, FromORRep a l) => OR l x -> a -- | The simplified generic representation type of type a, that -- toOR and fromOR convert to and from. type OROf a = OR (Linearize (Rep a)) () -- | Move normalized data to the Operating Room, where surgeries can be -- applied. -- -- Convert a generic type to a generic representation, in which all the -- strictness annotations have been normalized to lazy defaults. -- -- This variant is useful when one needs to operate on fields whose -- Rep has different strictness annotations than the ones used by -- DefaultMetaSel. -- --
-- a :: Type -- Generic type -- l :: k -> Type -- Generic representation (simplified and normalized) -- x :: k -- Ignored ---- --
-- a -> l --toORLazy :: forall a l x. (Generic a, ToORRepLazy a l) => a -> OR l x -- | Move normalized data out of the Operating Room and back to the -- real world. -- -- The inverse of toORLazy. -- -- It may be useful to annotate the output type of fromORLazy, -- since the rest of the type depends on it and the only way to infer it -- otherwise is from the context. The following annotations are possible: -- --
-- fromORLazy :: OROfLazy a -> a -- fromORLazy @a -- with TypeApplications ---- --
-- a :: Type -- Generic type -- l :: k -> Type -- Generic representation (simplified and normalized) -- x :: k -- Ignored ---- --
-- a -> l --fromORLazy :: forall a l x. (Generic a, FromORRepLazy a l) => OR l x -> a -- | The simplified and normalized generic representation type of type -- a, that toORLazy and fromORLazy convert to and -- from. type OROfLazy a = OR (Linearize (Lazify (Rep a))) () -- | removeCField @n @t: remove the n-th field, of -- type t, in a non-record single-constructor type. -- -- Inverse of insertCField. -- --
-- n :: Nat -- Field position -- t :: Type -- Field type -- lt :: k -> Type -- Row with field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- OR lt x -- Data with field -- -> -- (t, OR l x) -- Field value × Data without field ---- --
-- n lt -> t l -- n t l -> lt --removeCField :: forall n t lt l x. RmvCField n t lt l => OR lt x -> (t, OR l x) -- | insertCField @n @t: insert a field of type t -- at position n in a non-record single-constructor type. -- -- Inverse of removeCField. -- --
-- n :: Nat -- Field position -- t :: Type -- Field type -- lt :: k -> Type -- Row with field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- (t, OR l x) -- Field value × Data without field -- -> -- OR lt x -- Data with field ---- --
-- n lt -> t l -- n t l -> lt --insertCField :: forall n t lt l x. InsCField n t lt l => (t, OR l x) -> OR lt x -- | Curried insertCField. insertCField' :: forall n t lt l x. InsCField n t lt l => t -> OR l x -> OR lt x -- | modifyCField @n @t @t': modify the field at position -- n in a non-record via a function f :: t -> t' -- (changing the type of the field). -- --
-- n :: Nat -- Field position -- t :: Type -- Initial field type -- t' :: Type -- Final field type -- lt :: k -> Type -- Row with initial field -- lt' :: k -> Type -- Row with final field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- (t -> t') -- Field modification -- -> -- OR lt x -- Data with field t -- -> -- OR lt' x -- Data with field t' ---- --
-- n lt -> t l -- n lt' -> t' l -- n t l -> lt -- n t' l -> lt' --modifyCField :: forall n t t' lt lt' l x. ModCField n t t' lt lt' l => (t -> t') -> OR lt x -> OR lt' x -- | removeRField @"fdName" @n @t: remove the field -- fdName at position n of type t in a record -- type. -- -- Inverse of insertRField. -- --
-- fd :: Symbol -- Field name -- n :: Nat -- Field position -- t :: Type -- Field type -- lt :: k -> Type -- Row with field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- OR lt x -- Data with field -- -> -- (t, OR l x) -- Field value × Data without field ---- --
-- fd lt -> n t l -- n lt -> fd t l -- fd n t l -> lt --removeRField :: forall fd n t lt l x. RmvRField fd n t lt l => OR lt x -> (t, OR l x) -- | insertRField @"fdName" @n @t: insert a field named -- fdName of type t at position n in a record -- type. -- -- Inverse of removeRField. -- --
-- fd :: Symbol -- Field name -- n :: Nat -- Field position -- t :: Type -- Field type -- lt :: k -> Type -- Row with field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- (t, OR l x) -- Field value × Data without field -- -> -- OR lt x -- Data with field ---- --
-- fd lt -> n t l -- n lt -> fd t l -- fd n t l -> lt --insertRField :: forall fd n t lt l x. InsRField fd n t lt l => (t, OR l x) -> OR lt x -- | Curried insertRField. insertRField' :: forall fd n t lt l x. InsRField fd n t lt l => t -> OR l x -> OR lt x -- | modifyRField @"fdName" @n @t @t': modify the field -- fdName at position n in a record via a function -- f :: t -> t' (changing the type of the field). -- --
-- fd :: Symbol -- Field name -- n :: Nat -- Field position -- t :: Type -- Initial field type -- t' :: Type -- Final field type -- lt :: k -> Type -- Row with initial field -- lt' :: k -> Type -- Row with final field -- l :: k -> Type -- Row without field -- x :: k -- Ignored ---- --
-- (t -> t') -- Field modification -- -> -- OR lt x -- Data with field t -- -> -- OR lt' x -- Data with field t' ---- --
-- fd lt -> n t l -- fd lt' -> n t' l -- n lt -> fd t l -- n lt' -> fd t' l -- fd n t l -> lt -- fd n t' l -> lt' --modifyRField :: forall fd n t t' lt lt' l x. ModRField fd n t t' lt lt' l => (t -> t') -> OR lt x -> OR lt' x -- | removeConstr @"C" @n @t: remove the n-th -- constructor, named C, with contents isomorphic to the tuple -- t. -- -- Inverse of insertConstr. -- --
-- c :: Symbol -- Constructor name -- t :: Type -- Tuple type to hold c's contents -- n :: Nat -- Constructor position -- lc :: k -> Type -- Row with constructor -- l :: k -> Type -- Row without constructor -- l_t :: k -> Type -- Field row of constructor c -- x :: k -- Ignored ---- --
-- OR lc x -- Data with constructor -- -> -- Either t (OR l x) -- Constructor (as a tuple) | Data without constructor ---- --
-- c lc -> n l l_t -- n lc -> c l l_t -- c n l l_t -> lc ---- -- Note that there is no dependency to determine t. removeConstr :: forall c n t lc l x. RmvConstr c n t lc l => OR lc x -> Either t (OR l x) -- | insertConstr @"C" @n @t: insert a constructor -- C at position n with contents isomorphic to the -- tuple t. -- -- Inverse of removeConstr. -- --
-- c :: Symbol -- Constructor name -- t :: Type -- Tuple type to hold c's contents -- n :: Nat -- Constructor position -- lc :: k -> Type -- Row with constructor -- l :: k -> Type -- Row without constructor -- l_t :: k -> Type -- Field row of constructor c -- x :: k -- Ignored ---- --
-- Either t (OR l x) -- Constructor (as a tuple) | Data without constructor -- -> -- OR lc x -- Data with constructor ---- --
-- c lc -> n l l_t -- n lc -> c l l_t -- c n l l_t -> lc ---- -- Note that there is no dependency to determine t. insertConstr :: forall c n t lc l x. InsConstr c n t lc l => Either t (OR l x) -> OR lc x -- | modifyConstr @"C" @n @t @t': modify the n-th -- constructor, named C, with contents isomorphic to the tuple -- t, to another tuple t'. -- --
-- c :: Symbol -- Constructor name -- t :: Type -- Tuple type to hold c's initial contents -- t' :: Type -- Tuple type to hold c's final contents -- n :: Nat -- Constructor position -- lc :: k -> Type -- Row with initial constructor -- lc' :: k -> Type -- Row with final constructor -- l :: k -> Type -- Row without constructor -- l_t :: k -> Type -- Initial field row of constructor c -- l_t' :: k -> Type -- Final field row of constructor c -- x :: k -- Ignored ---- --
-- (t -> t') -- Constructor modification -- -> -- OR lc x -- Data with initial constructor -- -> -- OR lc' x -- Data with final constructor ---- --
-- c lc -> n l l_t -- c lc' -> n l l_t' -- n lc -> c l l_t -- n lc' -> c l l_t' -- c n l l_t -> lc -- c n l l_t' -> lc' ---- -- Note that there is no dependency to determine t and -- t'. modifyConstr :: forall c n t t' lc lc' l x. ModConstr c n t t' lc lc' l => (t -> t') -> OR lc x -> OR lc' x -- | A variant of removeConstr that can infer the tuple type -- t to hold the contents of the removed constructor. -- -- See removeConstr. -- --
-- l_t -> t --removeConstrT :: forall c n t lc l x. RmvConstrT c n t lc l => OR lc x -> Either t (OR l x) -- | A variant of insertConstr that can infer the tuple type -- t to hold the contents of the inserted constructor. -- -- See insertConstr. -- --
-- l_t -> t --insertConstrT :: forall c n t lc l x. InsConstrT c n t lc l => Either t (OR l x) -> OR lc x -- | A variant of modifyConstr that can infer the tuple types -- t and t' to hold the contents of the inserted -- constructor. -- -- See modifyConstr. -- --
-- l_t -> t -- l_t' -> t' --modifyConstrT :: forall c n t t' lc lc' l x. ModConstrT c n t t' lc lc' l => (t -> t') -> OR lc x -> OR lc' x -- | Kind of surgeries: operations on generic representations of types. -- -- Treat this as an abstract kind (don't pay attention to its -- definition). -- --