Safe Haskell | None |
---|---|
Language | Haskell2010 |
Operate on data types: insert/modify/delete fields and constructors.
Synopsis
- newtype OR (l :: k -> Type) (x :: k) = OR {
- unOR :: l x
- toOR :: forall a l x. (Generic a, ToORRep a l) => a -> OR l x
- fromOR' :: forall f l x. FromOR f l => OR l x -> Data f x
- toOR' :: forall f l x. ToOR f l => Data f x -> OR l x
- fromOR :: forall a l x. (Generic a, FromORRep a l) => OR l x -> a
- type OROf a = OR (Linearize (Rep a)) ()
- type ToORRep a l = ToOR (Rep a) l
- type FromORRep a l = FromOR (Rep a) l
- type ToOR f l = (GLinearize f, Linearize f ~ l, f ~ Arborify l)
- type FromOR f l = (GArborify f, Linearize f ~ l, f ~ Arborify l)
- removeCField :: forall n t lt l x. RmvCField n t lt l => OR lt x -> (t, OR l x)
- removeRField :: forall fd n t lt l x. RmvRField fd n t lt l => OR lt x -> (t, OR l x)
- insertCField :: forall n t lt l x. InsCField n t lt l => (t, OR l x) -> OR lt x
- insertCField' :: forall n t lt l x. InsCField n t lt l => t -> OR l x -> OR lt x
- insertRField :: forall fd n t lt l x. InsRField fd n t lt l => (t, OR l x) -> OR lt x
- insertRField' :: forall fd n t lt l x. InsRField fd n t lt l => t -> OR l x -> OR lt x
- 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 :: 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 :: forall c n t lc l l_t x. RmvConstr c n t lc l l_t => OR lc x -> Either t (OR l x)
- removeConstrT :: forall c n t lc l l_t x. RmvConstrT c n t lc l l_t => OR lc x -> Either t (OR l x)
- insertConstr :: forall c n t lc l l_t x. InsConstr c n t lc l l_t => Either t (OR l x) -> OR lc x
- insertConstrT :: forall c n t lc l l_t x. InsConstrT c n t lc l l_t => Either t (OR l x) -> OR lc x
- modifyConstr :: forall c n t t' lc lc' l l_t l_t' x. ModConstr c n t t' lc lc' l l_t l_t' => (t -> t') -> OR lc x -> OR lc' x
- modifyConstrT :: forall c n t t' lc lc' l l_t l_t' x. ModConstrT c n t t' lc lc' l l_t l_t' => (t -> t') -> OR lc x -> OR lc' x
- type RmvCField n t lt l = (GRemoveField n lt, CFieldSurgery n t lt l)
- type RmvRField fd n t lt l = (GRemoveField n lt, RFieldSurgery fd n t lt l)
- type InsCField n t lt l = (GInsertField n lt, CFieldSurgery n t lt l)
- type InsRField fd n t lt l = (GInsertField n lt, RFieldSurgery fd n t lt l)
- type ModCField n t t' lt lt' l = (RmvCField n t lt l, InsCField n t' lt' l)
- type ModRField fd n t t' lt lt' l = (RmvRField fd n t lt l, InsRField fd n t' lt' l)
- type RmvConstr c n t lc l l_t = (GRemoveConstr n lc, GArborify (Arborify l_t), ConstrSurgery c n t lc l l_t)
- type RmvConstrT c n t lc l l_t = (RmvConstr c n t lc l l_t, IsTuple (Arity l_t) t)
- type InsConstr c n t lc l l_t = (GInsertConstr n lc, GLinearize (Arborify l_t), ConstrSurgery c n t lc l l_t)
- type InsConstrT c n t lc l l_t = (InsConstr c n t lc l l_t, IsTuple (Arity l_t) t)
- type ModConstr c n t t' lc lc' l l_t l_t' = (RmvConstr c n t lc l l_t, InsConstr c n t' lc' l l_t')
- type ModConstrT c n t t' lc lc' l l_t l_t' = (ModConstr c n t t' lc lc' l l_t l_t', IsTuple (Arity l_t) t, IsTuple (Arity l_t') t')
- type FieldSurgery n t lt l = (t ~ Eval (FieldTypeAt n lt), l ~ Eval (RemoveField n 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 (UnM1 (Rep t)) (Arborify l_t), Coercible (Arborify l_t) (Rep t), n ~ Eval (ConstrIndex c lc), c ~ MetaConsName (MetaOf l_t), l_t ~ Linearize (Arborify l_t), l_t ~ Eval (ConstrAt n lc), lc ~ Eval (InsertConstr n l_t l), l ~ Eval (RemoveConstr n lc))
- type family Linearize (f :: k -> *) :: k -> *
- type family LinearizeSum (f :: k -> *) (tl :: k -> *) :: k -> *
- type family LinearizeProduct (f :: k -> *) (tl :: k -> *) :: k -> *
- class GLinearize f where
- gLinearize :: f x -> Linearize f x
- class GLinearizeSum f tl where
- gLinearizeSum :: Either (f x) (tl x) -> LinearizeSum f tl x
- class GLinearizeProduct f tl where
- gLinearizeProduct :: f x -> tl x -> LinearizeProduct f tl x
- class GArborify f where
- class GArborifySum f tl where
- gArborifySum :: LinearizeSum f tl x -> Either (f x) (tl x)
- class GArborifyProduct f tl where
- gArborifyProduct :: LinearizeProduct f tl x -> (f x, tl x)
- type family Arborify (f :: k -> *) :: k -> *
- data ArborifySum (n :: Nat) (f :: k -> *) :: (k -> *) -> *
- data ArborifyProduct (n :: Nat) (f :: k -> *) :: (k -> *) -> *
- type Arborify' arb op n nDiv2 f g = (Uncurry (Pure2 op) <=< (Bimap (arb nDiv2) (arb (n - nDiv2)) <=< SplitAt nDiv2)) (op f g)
- data SplitAt :: Nat -> (k -> *) -> (k -> *, k -> *) -> *
- data FieldTypeAt (n :: Nat) (f :: k -> *) :: * -> *
- type family FieldTypeOf (f :: k -> *) :: *
- data RemoveField (n :: Nat) (f :: k -> *) :: (k -> *) -> *
- type DefaultMetaSel field = MetaSel field NoSourceUnpackedness NoSourceStrictness DecidedLazy
- data InsertField (n :: Nat) (fd :: Maybe Symbol) (t :: *) (f :: k -> *) :: (k -> *) -> *
- data Succ :: Nat -> Nat -> *
- data FieldIndex (field :: Symbol) (f :: k -> *) :: Nat -> *
- type family Arity (f :: k -> *) :: Nat
- type family CoArity (f :: k -> *) :: Nat
- class GRemoveField (n :: Nat) f where
- gRemoveField :: f x -> (Eval (FieldTypeAt n f), Eval (RemoveField n f) x)
- class GInsertField (n :: Nat) f where
- gInsertField :: Eval (FieldTypeAt n f) -> Eval (RemoveField n f) x -> f x
- data ConstrAt (n :: Nat) (f :: k -> *) :: (k -> *) -> *
- data RemoveConstr (n :: Nat) (f :: k -> *) :: (k -> *) -> *
- data InsertConstr (n :: Nat) (t :: k -> *) (f :: k -> *) :: (k -> *) -> *
- data ConstrIndex (con :: Symbol) (f :: k -> *) :: Nat -> *
- class GRemoveConstr (n :: Nat) f where
- gRemoveConstr :: f x -> Either (Eval (ConstrAt n f) x) (Eval (RemoveConstr n f) x)
- class GInsertConstr (n :: Nat) f where
- gInsertConstr :: Either (Eval (ConstrAt n f) x) (Eval (RemoveConstr n f) x) -> f x
- class MatchFields (f :: k -> *) (g :: k -> *)
- class IsTuple (n :: Nat) (t :: k)
Documentation
newtype OR (l :: k -> Type) (x :: k) Source #
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
).
fromOR' :: forall f l x. FromOR f l => OR l x -> Data f x Source #
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.
Details
Type parameters
f :: k ->Type
--Generic
representation (proper) l :: k ->Type
-- Generic representation (simplified) x :: k -- Ignored
Functional dependencies
f -> l l -> f
Implementation details
The synthesized representation is made of balanced binary trees, corresponding closely to what GHC would generate for an actual data type.
That structure assumed by at least one piece of code out there (aeson
).
fromOR :: forall a l x. (Generic a, FromORRep a l) => OR l x -> a Source #
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 -> afromOR
@a -- with TypeApplications
Details
removeCField :: forall n t lt l x. RmvCField n t lt l => OR lt x -> (t, OR l x) Source #
: remove the removeCField
@n @tn
-th field, of type t
, in a
non-record single-constructor type.
Inverse of insertCField
.
Details
removeRField :: forall fd n t lt l x. RmvRField fd n t lt l => OR lt x -> (t, OR l x) Source #
: remove the field removeRField
@"fdName" @n @tfdName
at position n
of type t
in a record type.
Inverse of insertRField
.
Details
Type parameters
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
Signature
OR
lt x -- Data with field -> (t,OR
l x) -- Field value × Data without field
Functional dependencies
fd lt -> n t l n lt -> fd t l fd n t l -> lt
insertCField :: forall n t lt l x. InsCField n t lt l => (t, OR l x) -> OR lt x Source #
: insert a field of type insertCField
@n @tt
at position n
in a non-record single-constructor type.
Inverse of removeCField
.
Details
insertCField' :: forall n t lt l x. InsCField n t lt l => t -> OR l x -> OR lt x Source #
Curried insertCField
.
insertRField :: forall fd n t lt l x. InsRField fd n t lt l => (t, OR l x) -> OR lt x Source #
: insert a field
named insertRField
@"fdName" @n @tfdName
of type t
at position n
in a record type.
Inverse of removeRField
.
Details
Type parameters
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
Signature
(t,OR
l x) -- Field value × Data without field ->OR
lt x -- Data with field
Functional dependencies
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 Source #
Curried insertRField
.
modifyCField :: forall n t t' lt lt' l x. ModCField n t t' lt lt' l => (t -> t') -> OR lt x -> OR lt' x Source #
: modify the field at position modifyCField
@n @t @t'n
in a
non-record via a function f :: t -> t'
(changing the type of the field).
Details
Type parameters
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
Signature
(t -> t') -- Field modification ->OR
lt x -- Data with field t ->OR
lt' x -- Data with field t'
Functional dependencies
n lt -> t l n lt' -> t' l n t l -> lt 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 Source #
: modify the field
modifyRField
@"fdName" @n @t @t'fdName
at position n
in a record via a function f :: t -> t'
(changing the type of the field).
Details
Type parameters
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
Signature
(t -> t') -- Field modification ->OR
lt x -- Data with field t ->OR
lt' x -- Data with field t'
Functional dependencies
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'
removeConstr :: forall c n t lc l l_t x. RmvConstr c n t lc l l_t => OR lc x -> Either t (OR l x) Source #
: remove the removeConstr
@"C" @n @tn
-th constructor, named C
,
with contents isomorphic to the tuple t
.
Inverse of insertConstr
.
Details
Type parameters
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
Signature
OR
lc x -- Data with constructor -> Either t (OR
l x) -- Constructor (as a tuple) | Data without constructor
Functional dependencies
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
.
removeConstrT :: forall c n t lc l l_t x. RmvConstrT c n t lc l l_t => OR lc x -> Either t (OR l x) Source #
A variant of removeConstr
that can infer the tuple type t
to hold
the contents of the removed constructor.
See removeConstr
.
Details
Extra functional dependency
l_t -> t
insertConstr :: forall c n t lc l l_t x. InsConstr c n t lc l l_t => Either t (OR l x) -> OR lc x Source #
: insert a constructor insertConstr
@"C" @n @tC
at position n
with contents isomorphic to the tuple t
.
Inverse of removeConstr
.
Details
Type parameters
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
Signature
Either t (OR
l x) -- Constructor (as a tuple) | Data without constructor ->OR
lc x -- Data with constructor
Functional dependencies
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
.
insertConstrT :: forall c n t lc l l_t x. InsConstrT c n t lc l l_t => Either t (OR l x) -> OR lc x Source #
A variant of insertConstr
that can infer the tuple type t
to hold
the contents of the inserted constructor.
See insertConstr
.
Details
Extra functional dependency
l_t -> t
modifyConstr :: forall c n t t' lc lc' l l_t l_t' x. ModConstr c n t t' lc lc' l l_t l_t' => (t -> t') -> OR lc x -> OR lc' x Source #
: modify the modifyConstr
@"C" @n @t @t'n
-th constructor,
named C
, with contents isomorphic to the tuple t
, to another tuple t'
.
Details
Type parameters
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
Signature
(t -> t') -- Constructor modification ->OR
lc x -- Data with initial constructor ->OR
lc' x -- Data with final constructor
Functional dependencies
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'
.
modifyConstrT :: forall c n t t' lc lc' l l_t l_t' x. ModConstrT c n t t' lc lc' l l_t l_t' => (t -> t') -> OR lc x -> OR lc' x Source #
A variant of modifyConstr
that can infer the tuple types t
and t'
to
hold the contents of the inserted constructor.
See modifyConstr
.
Details
Extra functional dependencies
l_t -> t l_t' -> t'
type RmvCField n t lt l = (GRemoveField n lt, CFieldSurgery n t lt l) Source #
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 RmvRField fd n t lt l = (GRemoveField n lt, RFieldSurgery fd n t lt l) Source #
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 InsCField n t lt l = (GInsertField n lt, CFieldSurgery n t lt l) Source #
This constraint means that inserting a field t
at position n
in the
(unnamed) field row l
yields row lt
.
type InsRField fd n t lt l = (GInsertField n lt, RFieldSurgery fd n t lt l) Source #
This constraint means that inserting a field t
named fd
at position
n
in the record field row l
yields row lt
.
type ModCField n t t' lt lt' l = (RmvCField n t lt l, InsCField n t' lt' l) Source #
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 ModRField fd n t t' lt lt' l = (RmvRField fd n t lt l, InsRField fd n t' lt' l) Source #
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 RmvConstr c n t lc l l_t = (GRemoveConstr n lc, GArborify (Arborify l_t), ConstrSurgery c n t lc l l_t) Source #
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 RmvConstrT c n t lc l l_t = (RmvConstr c n t lc l l_t, IsTuple (Arity l_t) t) Source #
A variant of RmvConstr
allowing t
to be inferred.
type InsConstr c n t lc l l_t = (GInsertConstr n lc, GLinearize (Arborify l_t), ConstrSurgery c n t lc l l_t) Source #
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 InsConstrT c n t lc l l_t = (InsConstr c n t lc l l_t, IsTuple (Arity l_t) t) Source #
A variant of InsConstr
allowing t
to be inferred.
type ModConstr c n t t' lc lc' l l_t l_t' = (RmvConstr c n t lc l l_t, InsConstr c n t' lc' l l_t') Source #
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 ModConstrT c n t t' lc lc' l l_t l_t' = (ModConstr c n t t' lc lc' l l_t l_t', IsTuple (Arity l_t) t, IsTuple (Arity l_t') t') Source #
A variant of ModConstr
allowing t
and t'
to be inferred.
type FieldSurgery n t lt l = (t ~ Eval (FieldTypeAt n lt), l ~ Eval (RemoveField n lt)) Source #
type CFieldSurgery n t lt l = (lt ~ Eval (InsertField n Nothing t l), FieldSurgery n t lt l) Source #
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) Source #
type ConstrSurgery c n t lc l l_t = (Generic t, MatchFields (UnM1 (Rep t)) (Arborify l_t), Coercible (Arborify l_t) (Rep t), n ~ Eval (ConstrIndex c lc), c ~ MetaConsName (MetaOf l_t), l_t ~ Linearize (Arborify l_t), l_t ~ Eval (ConstrAt n lc), lc ~ Eval (InsertConstr n l_t l), l ~ Eval (RemoveConstr n lc)) Source #
type family LinearizeSum (f :: k -> *) (tl :: k -> *) :: k -> * Source #
Instances
type LinearizeSum (V1 :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type LinearizeSum (f :+: g :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type LinearizeSum (M1 c m f :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal type LinearizeSum (M1 c m f :: k -> Type) (tl :: k -> Type) = M1 c m (LinearizeProduct f (U1 :: k -> Type)) :+: tl |
type family LinearizeProduct (f :: k -> *) (tl :: k -> *) :: k -> * Source #
Instances
type LinearizeProduct (U1 :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type LinearizeProduct (f :*: g :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal type LinearizeProduct (f :*: g :: k -> Type) (tl :: k -> Type) = LinearizeProduct f (LinearizeProduct g tl) | |
type LinearizeProduct (M1 s m f :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
class GLinearize f where Source #
gLinearize :: f x -> Linearize f x Source #
Instances
GLinearizeSum f (V1 :: k -> Type) => GLinearize (M1 D m f :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
GLinearizeProduct f (U1 :: k -> Type) => GLinearize (M1 C m f :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
class GLinearizeSum f tl where Source #
gLinearizeSum :: Either (f x) (tl x) -> LinearizeSum f tl x Source #
Instances
GLinearizeSum (V1 :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gLinearizeSum :: Either (V1 x) (tl x) -> LinearizeSum V1 tl x Source # | |
(GLinearizeSum g tl, GLinearizeSum f (LinearizeSum g tl)) => GLinearizeSum (f :+: g :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gLinearizeSum :: Either ((f :+: g) x) (tl x) -> LinearizeSum (f :+: g) tl x Source # | |
GLinearizeProduct f (U1 :: k -> Type) => GLinearizeSum (M1 c m f :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gLinearizeSum :: Either (M1 c m f x) (tl x) -> LinearizeSum (M1 c m f) tl x Source # |
class GLinearizeProduct f tl where Source #
gLinearizeProduct :: f x -> tl x -> LinearizeProduct f tl x Source #
Instances
GLinearizeProduct (U1 :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gLinearizeProduct :: U1 x -> tl x -> LinearizeProduct U1 tl x Source # | |
(GLinearizeProduct g tl, GLinearizeProduct f (LinearizeProduct g tl)) => GLinearizeProduct (f :*: g :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gLinearizeProduct :: (f :*: g) x -> tl x -> LinearizeProduct (f :*: g) tl x Source # | |
GLinearizeProduct (M1 s m f :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gLinearizeProduct :: M1 s m f x -> tl x -> LinearizeProduct (M1 s m f) tl x Source # |
class GArborifySum f tl where Source #
gArborifySum :: LinearizeSum f tl x -> Either (f x) (tl x) Source #
Instances
GArborifySum (V1 :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gArborifySum :: LinearizeSum V1 tl x -> Either (V1 x) (tl x) Source # | |
(GArborifySum g tl, GArborifySum f (LinearizeSum g tl)) => GArborifySum (f :+: g :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gArborifySum :: LinearizeSum (f :+: g) tl x -> Either ((f :+: g) x) (tl x) Source # | |
GArborifyProduct f (U1 :: k -> Type) => GArborifySum (M1 c m f :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gArborifySum :: LinearizeSum (M1 c m f) tl x -> Either (M1 c m f x) (tl x) Source # |
class GArborifyProduct f tl where Source #
gArborifyProduct :: LinearizeProduct f tl x -> (f x, tl x) Source #
Instances
GArborifyProduct (U1 :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gArborifyProduct :: LinearizeProduct U1 tl x -> (U1 x, tl x) Source # | |
(GArborifyProduct g tl, GArborifyProduct f (LinearizeProduct g tl)) => GArborifyProduct (f :*: g :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gArborifyProduct :: LinearizeProduct (f :*: g) tl x -> ((f :*: g) x, tl x) Source # | |
GArborifyProduct (M1 s m f :: k -> Type) (tl :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gArborifyProduct :: LinearizeProduct (M1 s m f) tl x -> (M1 s m f x, tl x) Source # |
data ArborifySum (n :: Nat) (f :: k -> *) :: (k -> *) -> * Source #
data ArborifyProduct (n :: Nat) (f :: k -> *) :: (k -> *) -> * Source #
Instances
type Eval (ArborifyProduct n (U1 :: k -> Type) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (ArborifyProduct n (M1 C s f) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal type Eval (ArborifyProduct n (M1 C s f) :: (k -> Type) -> Type) = M1 C s (Eval (ArborifyProduct n f)) | |
type Eval (ArborifyProduct n (f :*: g) :: (k -> Type) -> Type) Source # | |
type Arborify' arb op n nDiv2 f g = (Uncurry (Pure2 op) <=< (Bimap (arb nDiv2) (arb (n - nDiv2)) <=< SplitAt nDiv2)) (op f g) Source #
data SplitAt :: Nat -> (k -> *) -> (k -> *, k -> *) -> * Source #
Instances
type Eval (SplitAt n (f :*: g) :: (k -> Type, k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal type Eval (SplitAt n (f :*: g) :: (k -> Type, k -> Type) -> Type) = Eval (If (n == 0) (Pure ((,) (U1 :: k -> Type) (f :*: g))) ((Bimap (Pure2 ((:*:) :: (k -> Type) -> (k -> Type) -> k -> Type) f) (Pure :: (k -> Type) -> (k -> Type) -> Type) :: (k -> Type, k -> Type) -> (k -> Type, k -> Type) -> Type) =<< SplitAt (n - 1) g)) | |
type Eval (SplitAt n (f :+: g) :: (k -> Type, k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal type Eval (SplitAt n (f :+: g) :: (k -> Type, k -> Type) -> Type) = Eval (If (n == 0) (Pure ((,) (V1 :: k -> Type) (f :+: g))) ((Bimap (Pure2 ((:+:) :: (k -> Type) -> (k -> Type) -> k -> Type) f) (Pure :: (k -> Type) -> (k -> Type) -> Type) :: (k -> Type, k -> Type) -> (k -> Type, k -> Type) -> Type) =<< SplitAt (n - 1) g)) |
data FieldTypeAt (n :: Nat) (f :: k -> *) :: * -> * Source #
Instances
type Eval (FieldTypeAt n (f :+: (V1 :: k -> Type)) :: Type -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (FieldTypeAt n (M1 i c f) :: Type -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (FieldTypeAt n (f :*: g) :: Type -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal type Eval (FieldTypeAt n (f :*: g) :: Type -> Type) = Eval (If (n == 0) (Pure (FieldTypeOf f)) (FieldTypeAt (n - 1) g)) |
type family FieldTypeOf (f :: k -> *) :: * Source #
Instances
type FieldTypeOf (M1 s m (K1 i a :: k -> Type) :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
data RemoveField (n :: Nat) (f :: k -> *) :: (k -> *) -> * Source #
Instances
type Eval (RemoveField n (f :*: g) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (RemoveField n (f :+: (V1 :: k -> Type)) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (RemoveField n (M1 i m f) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
type DefaultMetaSel field = MetaSel field NoSourceUnpackedness NoSourceStrictness DecidedLazy Source #
data InsertField (n :: Nat) (fd :: Maybe Symbol) (t :: *) (f :: k -> *) :: (k -> *) -> * Source #
Instances
type Eval (InsertField 0 fd t (U1 :: k -> Type) :: (k -> Type) -> Type) Source # | |
type Eval (InsertField n fd t (f :*: g) :: (k -> Type) -> Type) Source # | |
type Eval (InsertField n fd t (f :+: (V1 :: k -> Type)) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (InsertField n fd t (M1 C m f) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal type Eval (InsertField n fd t (M1 C m f) :: (k -> Type) -> Type) = M1 C m (Eval (InsertField n fd t f)) | |
type Eval (InsertField n fd t (M1 D m f) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal type Eval (InsertField n fd t (M1 D m f) :: (k -> Type) -> Type) = M1 D m (Eval (InsertField n fd t f)) |
data FieldIndex (field :: Symbol) (f :: k -> *) :: Nat -> * Source #
Position of a record field
Instances
type Eval (FieldIndex field (M1 S (MetaSel (Just field') su ss ds) f :*: g) :: Nat -> Type) Source # | |
type Eval (FieldIndex field (f :+: (V1 :: k -> Type)) :: Nat -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (FieldIndex field (M1 C m f) :: Nat -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (FieldIndex field (M1 D m f) :: Nat -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
type family Arity (f :: k -> *) :: Nat Source #
Number of fields of a single constructor
Instances
type Arity (U1 :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Arity (K1 i c :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Arity (f :*: g :: k -> Type) Source # | |
type Arity (f :+: (V1 :: k -> Type) :: k -> Type) Source # | |
type Arity (M1 d m f :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
type family CoArity (f :: k -> *) :: Nat Source #
Number of constructors of a data type
class GRemoveField (n :: Nat) f where Source #
gRemoveField :: f x -> (Eval (FieldTypeAt n f), Eval (RemoveField n f) x) Source #
Instances
(If (n == 0) () (GRemoveField (n - 1) g), IsBool (n == 0)) => GRemoveField n (M1 s m (K1 i t :: k -> Type) :*: g :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
GRemoveField n f => GRemoveField n (f :+: (V1 :: k -> Type) :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gRemoveField :: (f :+: V1) x -> (Eval (FieldTypeAt n (f :+: V1)), Eval (RemoveField n (f :+: V1)) x) Source # | |
GRemoveField n f => GRemoveField n (M1 i c f :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gRemoveField :: M1 i c f x -> (Eval (FieldTypeAt n (M1 i c f)), Eval (RemoveField n (M1 i c f)) x) Source # |
class GInsertField (n :: Nat) f where Source #
gInsertField :: Eval (FieldTypeAt n f) -> Eval (RemoveField n f) x -> f x Source #
Instances
(If (n == 0) () (GInsertField (n - 1) g), IsBool (n == 0)) => GInsertField n (M1 s m (K1 i t :: k -> Type) :*: g :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
GInsertField n f => GInsertField n (f :+: (V1 :: k -> Type) :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gInsertField :: Eval (FieldTypeAt n (f :+: V1)) -> Eval (RemoveField n (f :+: V1)) x -> (f :+: V1) x Source # | |
GInsertField n f => GInsertField n (M1 i c f :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal gInsertField :: Eval (FieldTypeAt n (M1 i c f)) -> Eval (RemoveField n (M1 i c f)) x -> M1 i c f x Source # |
data ConstrAt (n :: Nat) (f :: k -> *) :: (k -> *) -> * Source #
data RemoveConstr (n :: Nat) (f :: k -> *) :: (k -> *) -> * Source #
Instances
type Eval (RemoveConstr n (f :+: g) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (RemoveConstr n (M1 i m f) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
data InsertConstr (n :: Nat) (t :: k -> *) (f :: k -> *) :: (k -> *) -> * Source #
Instances
type Eval (InsertConstr 0 t (V1 :: k -> Type) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
type Eval (InsertConstr n t (f :+: g) :: (k -> Type) -> Type) Source # | |
type Eval (InsertConstr n t (M1 i m f) :: (k -> Type) -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
data ConstrIndex (con :: Symbol) (f :: k -> *) :: Nat -> * Source #
class GRemoveConstr (n :: Nat) f where Source #
gRemoveConstr :: f x -> Either (Eval (ConstrAt n f) x) (Eval (RemoveConstr n f) x) Source #
Instances
(If (n == 0) () (GRemoveConstr (n - 1) g), IsBool (n == 0)) => GRemoveConstr n (f :+: g :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
GRemoveConstr n f => GRemoveConstr n (M1 i c f :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
class GInsertConstr (n :: Nat) f where Source #
gInsertConstr :: Either (Eval (ConstrAt n f) x) (Eval (RemoveConstr n f) x) -> f x Source #
Instances
(If (n == 0) () (GInsertConstr (n - 1) g), IsBool (n == 0)) => GInsertConstr n (f :+: g :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
GInsertConstr n f => GInsertConstr n (M1 i c f :: k -> Type) Source # | |
Defined in Generic.Data.Surgery.Internal |
class MatchFields (f :: k -> *) (g :: k -> *) Source #
Generate equality constraints between fields of two matching generic representations.
Instances
class IsTuple (n :: Nat) (t :: k) Source #
Instances
t ~ () => IsTuple 0 (t :: Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
t ~ Identity a => IsTuple 1 (t :: Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
t ~ (a, b) => IsTuple 2 (t :: Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
t ~ (a, b, c) => IsTuple 3 (t :: Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
t ~ (a, b, c, d) => IsTuple 4 (t :: Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
t ~ (a, b, c, d, e) => IsTuple 5 (t :: Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
t ~ (a, b, c, d, e, f) => IsTuple 6 (t :: Type) Source # | |
Defined in Generic.Data.Surgery.Internal | |
t ~ (a, b, c, d, e, f, g) => IsTuple 7 (t :: Type) Source # | |
Defined in Generic.Data.Surgery.Internal |