generic-data-surgery-0.2.0.0: Surgery for generic data types

Safe HaskellNone
LanguageHaskell2010

Generic.Data.Surgery.Internal

Description

Operate on data types: insert/modify/delete fields and constructors.

Synopsis

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).

Constructors

OR 

Fields

toOR :: forall a l x. (Generic a, ToORRep a l) => a -> OR l x Source #

Move fresh data to the Operating Room, where surgeries can be applied.

Convert a generic type to a generic representation.

Details

Expand

Type parameters

a :: Type       -- Generic type
l :: k -> Type  -- Generic representation (simplified)
x :: k          -- Ignored

Functional dependencies

a -> l

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

Expand

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).

toOR' :: forall f l x. ToOR f l => Data f x -> OR l x Source #

Move altered data, produced by some generic function, to the operating room.

The inverse of fromOR'.

Details

Expand

Type parameters

f :: k -> Type  -- Generic representation (proper)
l :: k -> Type  -- Generic representation (simplified)
x :: k          -- Ignored

Functional dependencies

f -> l
l -> f

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 -> a
fromOR @a  -- with TypeApplications

Details

Expand

Type parameters

a :: Type       -- Generic type
l :: k -> Type  -- Generic representation (simplified)
x :: k          -- Ignored

Functional dependencies

a -> l

type OROf a = OR (Linearize (Rep a)) () Source #

The simplified generic representation type of type a, that toOR and fromOR convert to and from.

type ToORRep a l = ToOR (Rep a) l Source #

This constraint means that a is convertible to its simplified generic representation. Implies OROf a ~ OR l ().

type FromORRep a l = FromOR (Rep a) l Source #

This constraint means that a is convertible from its simplified generic representation. Implies OROf a ~ OR l ().

type ToOR f l = (GLinearize f, Linearize f ~ l, f ~ Arborify l) Source #

Similar to ToORRep, 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) Source #

Similar to FromORRep, but as a constraint on the standard generic representation of a directly, f ~ Rep a.

removeCField :: forall n t lt l x. RmvCField n t lt l => OR lt x -> (t, OR l x) Source #

removeCField @n @t: remove the n-th field, of type t, in a non-record single-constructor type.

Inverse of insertCField.

Details

Expand

Type parameters

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

n lt  -> t l
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) Source #

removeRField @"fdName" @n @t: remove the field fdName at position n of type t in a record type.

Inverse of insertRField.

Details

Expand

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 #

insertCField @n @t: insert a field of type t at position n in a non-record single-constructor type.

Inverse of removeCField.

Details

Expand

Type parameters

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

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 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 #

insertRField @"fdName" @n @t: insert a field named fdName of type t at position n in a record type.

Inverse of removeRField.

Details

Expand

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 #

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).

Details

Expand

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 #

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).

Details

Expand

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 #

removeConstr @"C" @n @t: remove the n-th constructor, named C, with contents isomorphic to the tuple t.

Inverse of insertConstr.

Details

Expand

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

Expand

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 #

insertConstr @"C" @n @t: insert a constructor C at position n with contents isomorphic to the tuple t.

Inverse of removeConstr.

Details

Expand

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

Expand

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 #

modifyConstr @"C" @n @t @t': modify the n-th constructor, named C, with contents isomorphic to the tuple t, to another tuple t'.

Details

Expand

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

Expand

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 Linearize (f :: k -> *) :: k -> * Source #

Instances
type Linearize (M1 D m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Linearize (M1 D m f :: k -> Type) = M1 D m (LinearizeSum f (V1 :: k -> Type))
type Linearize (M1 C m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Linearize (M1 C m f :: k -> Type) = M1 C m (LinearizeProduct f (U1 :: k -> Type))

type family LinearizeSum (f :: k -> *) (tl :: k -> *) :: k -> * Source #

Instances
type LinearizeSum (V1 :: k -> Type) (tl :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type LinearizeSum (V1 :: k -> Type) (tl :: k -> Type) = tl
type LinearizeSum (f :+: g :: k -> Type) (tl :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type LinearizeSum (f :+: g :: k -> Type) (tl :: k -> Type) = LinearizeSum f (LinearizeSum g tl)
type LinearizeSum (M1 c m f :: k -> Type) (tl :: k -> Type) Source # 
Instance details

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

type LinearizeProduct (U1 :: k -> Type) (tl :: k -> Type) = tl
type LinearizeProduct (f :*: g :: k -> Type) (tl :: k -> Type) Source # 
Instance details

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

type LinearizeProduct (M1 s m f :: k -> Type) (tl :: k -> Type) = M1 s m f :*: tl

class GLinearize f where Source #

Methods

gLinearize :: f x -> Linearize f x Source #

Instances
GLinearizeSum f (V1 :: k -> Type) => GLinearize (M1 D m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gLinearize :: M1 D m f x -> Linearize (M1 D m f) x Source #

GLinearizeProduct f (U1 :: k -> Type) => GLinearize (M1 C m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gLinearize :: M1 C m f x -> Linearize (M1 C m f) x Source #

class GLinearizeSum f tl where Source #

Methods

gLinearizeSum :: Either (f x) (tl x) -> LinearizeSum f tl x Source #

Instances
GLinearizeSum (V1 :: k -> Type) (tl :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gLinearizeSum :: Either (M1 c m f x) (tl x) -> LinearizeSum (M1 c m f) tl x Source #

class GLinearizeProduct f tl where Source #

Methods

gLinearizeProduct :: f x -> tl x -> LinearizeProduct f tl x Source #

Instances
GLinearizeProduct (U1 :: k -> Type) (tl :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gLinearizeProduct :: (f :*: g) x -> tl x -> LinearizeProduct (f :*: g) tl x Source #

GLinearizeProduct (M1 s m f :: k -> Type) (tl :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gLinearizeProduct :: M1 s m f x -> tl x -> LinearizeProduct (M1 s m f) tl x Source #

class GArborify f where Source #

Methods

gArborify :: Linearize f x -> f x Source #

Instances
GArborifySum f (V1 :: k -> Type) => GArborify (M1 D m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gArborify :: Linearize (M1 D m f) x -> M1 D m f x Source #

GArborifyProduct f (U1 :: k -> Type) => GArborify (M1 C m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gArborify :: Linearize (M1 C m f) x -> M1 C m f x Source #

class GArborifySum f tl where Source #

Methods

gArborifySum :: LinearizeSum f tl x -> Either (f x) (tl x) Source #

Instances
GArborifySum (V1 :: k -> Type) (tl :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gArborifySum :: LinearizeSum (M1 c m f) tl x -> Either (M1 c m f x) (tl x) Source #

class GArborifyProduct f tl where Source #

Methods

gArborifyProduct :: LinearizeProduct f tl x -> (f x, tl x) Source #

Instances
GArborifyProduct (U1 :: k -> Type) (tl :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gArborifyProduct :: LinearizeProduct (f :*: g) tl x -> ((f :*: g) x, tl x) Source #

GArborifyProduct (M1 s m f :: k -> Type) (tl :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gArborifyProduct :: LinearizeProduct (M1 s m f) tl x -> (M1 s m f x, tl x) Source #

type family Arborify (f :: k -> *) :: k -> * Source #

Instances
type Arborify (M1 C m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Arborify (M1 C m f :: k -> Type) = M1 C m (Eval (ArborifyProduct (Arity f) f))
type Arborify (M1 D m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Arborify (M1 D m f :: k -> Type) = M1 D m (Eval (ArborifySum (CoArity f) f))

data ArborifySum (n :: Nat) (f :: k -> *) :: (k -> *) -> * Source #

Instances
type Eval (ArborifySum n (V1 :: k -> Type) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (ArborifySum n (V1 :: k -> Type) :: (k -> Type) -> Type) = (V1 :: k -> Type)
type Eval (ArborifySum n (f :+: g) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (ArborifySum n (f :+: g) :: (k -> Type) -> Type) = Eval (If (n == 1) (ArborifyProduct (Arity f) f) (Arborify' (ArborifySum :: Nat -> (k -> Type) -> (k -> Type) -> Type) ((:+:) :: (k -> Type) -> (k -> Type) -> k -> Type) n (Div n 2) f g))

data ArborifyProduct (n :: Nat) (f :: k -> *) :: (k -> *) -> * Source #

Instances
type Eval (ArborifyProduct n (U1 :: k -> Type) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (ArborifyProduct n (U1 :: k -> Type) :: (k -> Type) -> Type) = (U1 :: k -> Type)
type Eval (ArborifyProduct n (M1 C s f) :: (k -> Type) -> Type) Source # 
Instance details

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (ArborifyProduct n (f :*: g) :: (k -> Type) -> Type) = Eval (If (n == 1) (Pure f) (Arborify' (ArborifyProduct :: Nat -> (k -> Type) -> (k -> Type) -> Type) ((:*:) :: (k -> Type) -> (k -> Type) -> k -> Type) n (Div n 2) f g))

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (FieldTypeAt n (f :+: (V1 :: k -> Type)) :: Type -> Type) = Eval (FieldTypeAt n f)
type Eval (FieldTypeAt n (M1 i c f) :: Type -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (FieldTypeAt n (M1 i c f) :: Type -> Type) = Eval (FieldTypeAt n f)
type Eval (FieldTypeAt n (f :*: g) :: Type -> Type) Source # 
Instance details

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

type FieldTypeOf (M1 s m (K1 i a :: k -> Type) :: k -> Type) = a

data RemoveField (n :: Nat) (f :: k -> *) :: (k -> *) -> * Source #

Instances
type Eval (RemoveField n (f :*: g) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (RemoveField n (f :*: g) :: (k -> Type) -> Type) = Eval (If (n == 0) (Pure g) ((:*:) f <$> RemoveField (n - 1) g))
type Eval (RemoveField n (f :+: (V1 :: k -> Type)) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (RemoveField n (f :+: (V1 :: k -> Type)) :: (k -> Type) -> Type) = Eval (RemoveField n f) :+: (V1 :: k -> Type)
type Eval (RemoveField n (M1 i m f) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (RemoveField n (M1 i m f) :: (k -> Type) -> Type) = M1 i m (Eval (RemoveField n f))

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (InsertField 0 fd t (U1 :: k -> Type) :: (k -> Type) -> Type) = M1 S (DefaultMetaSel fd) (K1 R t :: k -> Type) :*: (U1 :: k -> Type)
type Eval (InsertField n fd t (f :*: g) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (InsertField n fd t (f :*: g) :: (k -> Type) -> Type) = Eval (If (n == 0) (Pure (M1 S (DefaultMetaSel fd) (K1 R t :: k -> Type) :*: (f :*: g))) ((:*:) f <$> InsertField (n - 1) fd t g))
type Eval (InsertField n fd t (f :+: (V1 :: k -> Type)) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (InsertField n fd t (f :+: (V1 :: k -> Type)) :: (k -> Type) -> Type) = Eval (InsertField n fd t f) :+: (V1 :: k -> Type)
type Eval (InsertField n fd t (M1 C m f) :: (k -> Type) -> Type) Source # 
Instance details

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 # 
Instance details

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 Succ :: Nat -> Nat -> * Source #

Instances
type Eval (Succ n :: Nat -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (Succ n :: Nat -> Type) = 1 + n

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (FieldIndex field (M1 S (MetaSel (Just field') su ss ds) f :*: g) :: Nat -> Type) = Eval (If (field == field') (Pure 0) (Succ =<< FieldIndex field g))
type Eval (FieldIndex field (f :+: (V1 :: k -> Type)) :: Nat -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (FieldIndex field (f :+: (V1 :: k -> Type)) :: Nat -> Type) = Eval (FieldIndex field f)
type Eval (FieldIndex field (M1 C m f) :: Nat -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (FieldIndex field (M1 C m f) :: Nat -> Type) = Eval (FieldIndex field f)
type Eval (FieldIndex field (M1 D m f) :: Nat -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (FieldIndex field (M1 D m f) :: Nat -> Type) = Eval (FieldIndex field f)

type family Arity (f :: k -> *) :: Nat Source #

Number of fields of a single constructor

Instances
type Arity (U1 :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Arity (U1 :: k -> Type) = 0
type Arity (K1 i c :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Arity (K1 i c :: k -> Type) = 1
type Arity (f :*: g :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Arity (f :*: g :: k -> Type) = Arity f + Arity g
type Arity (f :+: (V1 :: k -> Type) :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Arity (f :+: (V1 :: k -> Type) :: k -> Type) = Arity f
type Arity (M1 d m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Arity (M1 d m f :: k -> Type) = Arity f

type family CoArity (f :: k -> *) :: Nat Source #

Number of constructors of a data type

Instances
type CoArity (V1 :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type CoArity (V1 :: k -> Type) = 0
type CoArity (f :+: g :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type CoArity (f :+: g :: k -> Type) = CoArity f + CoArity g
type CoArity (M1 C m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type CoArity (M1 C m f :: k -> Type) = 1
type CoArity (M1 D m f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type CoArity (M1 D m f :: k -> Type) = CoArity f

class GRemoveField (n :: Nat) f where Source #

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gRemoveField :: (M1 s m (K1 i t) :*: g) x -> (Eval (FieldTypeAt n (M1 s m (K1 i t) :*: g)), Eval (RemoveField n (M1 s m (K1 i t) :*: g)) x) Source #

GRemoveField n f => GRemoveField n (f :+: (V1 :: k -> Type) :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 #

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gInsertField :: Eval (FieldTypeAt n (M1 s m (K1 i t) :*: g)) -> Eval (RemoveField n (M1 s m (K1 i t) :*: g)) x -> (M1 s m (K1 i t) :*: g) x Source #

GInsertField n f => GInsertField n (f :+: (V1 :: k -> Type) :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

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 #

Instances
type Eval (ConstrAt n (f :+: g) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (ConstrAt n (f :+: g) :: (k -> Type) -> Type) = Eval (If (n == 0) (Pure f) (ConstrAt (n - 1) g))
type Eval (ConstrAt n (M1 i m f) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (ConstrAt n (M1 i m f) :: (k -> Type) -> Type) = Eval (ConstrAt n f)

data RemoveConstr (n :: Nat) (f :: k -> *) :: (k -> *) -> * Source #

Instances
type Eval (RemoveConstr n (f :+: g) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (RemoveConstr n (f :+: g) :: (k -> Type) -> Type) = Eval (If (n == 0) (Pure g) ((:+:) f <$> RemoveConstr (n - 1) g))
type Eval (RemoveConstr n (M1 i m f) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (RemoveConstr n (M1 i m f) :: (k -> Type) -> Type) = M1 i m (Eval (RemoveConstr n f))

data InsertConstr (n :: Nat) (t :: k -> *) (f :: k -> *) :: (k -> *) -> * Source #

Instances
type Eval (InsertConstr 0 t (V1 :: k -> Type) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (InsertConstr 0 t (V1 :: k -> Type) :: (k -> Type) -> Type) = t :+: (V1 :: k -> Type)
type Eval (InsertConstr n t (f :+: g) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (InsertConstr n t (f :+: g) :: (k -> Type) -> Type) = Eval (If (n == 0) (Pure (t :+: (f :+: g))) ((:+:) f <$> InsertConstr (n - 1) t g))
type Eval (InsertConstr n t (M1 i m f) :: (k -> Type) -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (InsertConstr n t (M1 i m f) :: (k -> Type) -> Type) = M1 i m (Eval (InsertConstr n t f))

data ConstrIndex (con :: Symbol) (f :: k -> *) :: Nat -> * Source #

Instances
type Eval (ConstrIndex con (M1 C (MetaCons con' fx s) f :+: g) :: Nat -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (ConstrIndex con (M1 C (MetaCons con' fx s) f :+: g) :: Nat -> Type) = Eval (If (con == con') (Pure 0) (Succ =<< ConstrIndex con g))
type Eval (ConstrIndex con (M1 D m f) :: Nat -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

type Eval (ConstrIndex con (M1 D m f) :: Nat -> Type) = Eval (ConstrIndex con f)

class GRemoveConstr (n :: Nat) f where Source #

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gRemoveConstr :: (f :+: g) x -> Either (Eval (ConstrAt n (f :+: g)) x) (Eval (RemoveConstr n (f :+: g)) x) Source #

GRemoveConstr n f => GRemoveConstr n (M1 i c f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gRemoveConstr :: M1 i c f x -> Either (Eval (ConstrAt n (M1 i c f)) x) (Eval (RemoveConstr n (M1 i c f)) x) Source #

class GInsertConstr (n :: Nat) f where Source #

Methods

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 # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gInsertConstr :: Either (Eval (ConstrAt n (f :+: g)) x) (Eval (RemoveConstr n (f :+: g)) x) -> (f :+: g) x Source #

GInsertConstr n f => GInsertConstr n (M1 i c f :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

Methods

gInsertConstr :: Either (Eval (ConstrAt n (M1 i c f)) x) (Eval (RemoveConstr n (M1 i c f)) x) -> M1 i c f x Source #

class MatchFields (f :: k -> *) (g :: k -> *) Source #

Generate equality constraints between fields of two matching generic representations.

Instances
g' ~ (V1 :: k -> Type) => MatchFields (V1 :: k -> Type) (g' :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

g' ~ (U1 :: k -> Type) => MatchFields (U1 :: k -> Type) (g' :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

g' ~ (K1 j a :: k -> Type) => MatchFields (K1 i a :: k -> Type) (g' :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

(g' ~ (g1 :*: g2), MatchFields f1 g1, MatchFields f2 g2) => MatchFields (f1 :*: f2 :: k -> Type) (g' :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

(g' ~ (g1 :+: g2), MatchFields f1 g1, MatchFields f2 g2) => MatchFields (f1 :+: f2 :: k -> Type) (g' :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

(g' ~ M1 S d g, MatchFields f g) => MatchFields (M1 S c f :: k -> Type) (g' :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

(g' ~ M1 C (MetaCons _cn _s _t) g, MatchFields f g) => MatchFields (M1 C c f :: k -> Type) (g' :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

(g' ~ M1 D d g, MatchFields f g) => MatchFields (M1 D c f :: k -> Type) (g' :: k -> Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

class IsTuple (n :: Nat) (t :: k) Source #

Instances
t ~ () => IsTuple 0 (t :: Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

t ~ Identity a => IsTuple 1 (t :: Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

t ~ (a, b) => IsTuple 2 (t :: Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

t ~ (a, b, c) => IsTuple 3 (t :: Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

t ~ (a, b, c, d) => IsTuple 4 (t :: Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

t ~ (a, b, c, d, e) => IsTuple 5 (t :: Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

t ~ (a, b, c, d, e, f) => IsTuple 6 (t :: Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal

t ~ (a, b, c, d, e, f, g) => IsTuple 7 (t :: Type) Source # 
Instance details

Defined in Generic.Data.Surgery.Internal