row-types-1.0.1.2: Open Records and Variants

Safe Haskell | None
Language | Haskell2010

Data.Row.Internal

Contents

- Rows
- Row Operations
- Row Constraints
- Helper functions

Description

This module implements the internals of open records and variants.

Synopsis

- newtype Row a = R [LT a]
- data Label (s :: Symbol) = Label
- class KnownSymbol (n :: Symbol)
- data LT a = Symbol :-> a
- type Empty = 'R ('[] :: [LT a])
- data HideType where
  - HideType :: forall a. a -> HideType
- type family Extend (l :: Symbol) (a :: k) (r :: Row k) :: Row k where ...
- type family Modify (l :: Symbol) (a :: k) (r :: Row k) :: Row k where ...
- type family Rename (l :: Symbol) (l' :: Symbol) (r :: Row k) :: Row k where ...
- type (.==) (l :: Symbol) (a :: k) = Extend l a (Empty :: Row k)
- type family (r :: Row k) .! (t :: Symbol) :: k where ...
- type family (r :: Row k) .- (s :: Symbol) :: Row k where ...
- type family (l :: Row k) .\\ (r :: Row k) :: Row k where ...
- type family (l :: Row k) .+ (r :: Row k) :: Row k where ...
- type family (l :: Row k) .\/ (r :: Row k) :: Row k where ...
- type family (l :: Row k) .// (r :: Row k) :: Row k where ...
- class Lacks (l :: Symbol) (r :: Row Type)
- type family (r :: Row k) .\ (l :: Symbol) where ...
- class (r .! l) ≈ a => HasType (l :: Symbol) (a :: k) (r :: Row k)
- class Forall (r :: Row k) (c :: k -> Constraint) where
  - metamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k) -> g (Empty :: Row k)) -> (forall (ℓ :: Symbol) (τ :: k) (ρ :: Row k). (KnownSymbol ℓ, c τ, HasType ℓ τ ρ) => Label ℓ -> f ρ -> p (f (ρ .- ℓ)) (h τ)) -> (forall (ℓ :: Symbol) (τ :: k) (ρ :: Row k). (KnownSymbol ℓ, c τ, FrontExtends ℓ τ ρ, AllUniqueLabels (Extend ℓ τ ρ)) => Label ℓ -> p (g ρ) (h τ) -> g (Extend ℓ τ ρ)) -> f r -> g r
- class BiForall (r1 :: Row k1) (r2 :: Row k2) (c :: k1 -> k2 -> Constraint) where
  - biMetamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k1) (Empty :: Row k2) -> g (Empty :: Row k1) (Empty :: Row k2)) -> (forall (ℓ :: Symbol) (τ1 :: k1) (τ2 :: k2) (ρ1 :: Row k1) (ρ2 :: Row k2). (KnownSymbol ℓ, c τ1 τ2, HasType ℓ τ1 ρ1, HasType ℓ τ2 ρ2) => Label ℓ -> f ρ1 ρ2 -> p (f (ρ1 .- ℓ) (ρ2 .- ℓ)) (h τ1 τ2)) -> (forall (ℓ :: Symbol) (τ1 :: k1) (τ2 :: k2) (ρ1 :: Row k1) (ρ2 :: Row k2). (KnownSymbol ℓ, c τ1 τ2, FrontExtends ℓ τ1 ρ1, FrontExtends ℓ τ2 ρ2, AllUniqueLabels (Extend ℓ τ1 ρ1), AllUniqueLabels (Extend ℓ τ2 ρ2)) => Label ℓ -> p (g ρ1 ρ2) (h τ1 τ2) -> g (Extend ℓ τ1 ρ1) (Extend ℓ τ2 ρ2)) -> f r1 r2 -> g r1 r2
- class (c1 x, c2 y) => BiConstraint (c1 :: k -> Constraint) (c2 :: k1 -> Constraint) (x :: k) (y :: k1)
- class Unconstrained
- class Unconstrained1 (a :: k)
- class Unconstrained2 (a :: k) (b :: k1)
- class FrontExtends (l :: Symbol) (t :: k) (r :: Row k) where
  - frontExtendsDict :: FrontExtendsDict l t r
- data FrontExtendsDict (l :: Symbol) (t :: k) (r :: Row k) = FrontExtendsDict (Dict (r ~ 'R ρ, 'R ((l ':-> t) ': ρ) ≈ Extend l t ('R ρ), AllUniqueLabelsR ((l ':-> t) ': ρ)))
- type WellBehaved (ρ :: Row k) = (Forall ρ (Unconstrained1 :: k -> Constraint), AllUniqueLabels ρ)
- type family AllUniqueLabels (r :: Row k) where ...
- type family Ap (fs :: Row (a -> b)) (r :: Row a) :: Row b where ...
- type family ApSingle (fs :: Row (a -> b)) (x :: a) :: Row b where ...
- type family Zip (r1 :: Row Type) (r2 :: Row Type) :: Row Type where ...
- type family Map (f :: a -> b) (r :: Row a) :: Row b where ...
- type family Subset (r1 :: Row k) (r2 :: Row k) where ...
- type Disjoint (l :: Row k) (r :: Row k) = (WellBehaved l, WellBehaved r, Subset l (l .+ r), Subset r (l .+ r), ((l .+ r) .\\ l) ≈ r, ((l .+ r) .\\ r) ≈ l)
- type family Labels (r :: Row a) :: [Symbol] where ...
- labels :: forall {k} (ρ :: Row k) (c :: k -> Constraint) s. (IsString s, Forall ρ c) => [s]
- labels' :: forall {k} (ρ :: Row k) s. (IsString s, Forall ρ (Unconstrained1 :: k -> Constraint)) => [s]
- show' :: (IsString s, Show a) => a -> s
- toKey :: forall (s :: Symbol). KnownSymbol s => Label s -> Text
- type (≈) (a :: k) (b :: k) = a ~ b

# Rows

newtype Row a #

The kind of rows. This type is only used as a datakind. A row is a typelevel entity telling us which symbols are associated with which types.

Constructors

R [LT a] | A row is a list of symbol-to-type pairs that should always be sorted lexically by the symbol. The constructor is exported here (because this is an internal module) but should not be exported elsewhere.

data Label (s :: Symbol) #

A label

Constructors

Label |

#### Instances

Instances details

x ≈ y => IsLabel x (Label y) # |
Instance details Defined in Data.Row.Internal Methods fromLabel :: Label y #
KnownSymbol s => Show (Label s) # |
Instance details Defined in Data.Row.Internal Methods showsPrec :: Int -> Label s -> ShowS # show :: Label s -> String # showList :: [Label s] -> ShowS #
Eq (Label s) # |
Instance details Defined in Data.Row.Internal Methods (==) :: Label s -> Label s -> Bool # (/=) :: Label s -> Label s -> Bool #

class KnownSymbol (n :: Symbol) #

This class gives the string associated with a type-level symbol. There are instances of the class for every concrete literal: "hello", etc.

@since base-4.7.0.0

Minimal complete definition

symbolSing

data LT a #

The kind of elements of rows. Each element is a label and its associated type.

Constructors

Symbol :-> a |

#### Instances

Instances details

(KnownSymbol ℓ, c τ1 τ2, BiForall ('R ρ1) ('R ρ2) c, FrontExtends ℓ τ1 ('R ρ1), FrontExtends ℓ τ2 ('R ρ2), AllUniqueLabels (Extend ℓ τ1 ('R ρ1)), AllUniqueLabels (Extend ℓ τ2 ('R ρ2))) => BiForall ('R ((ℓ ':-> τ1) ': ρ1) :: Row k1) ('R ((ℓ ':-> τ2) ': ρ2) :: Row k2) (c :: k1 -> k2 -> Constraint) # |
Instance details Defined in Data.Row.Internal Methods biMetamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k1) (Empty :: Row k2) -> g (Empty :: Row k1) (Empty :: Row k2)) -> (forall (ℓ0 :: Symbol) (τ10 :: k1) (τ20 :: k2) (ρ10 :: Row k1) (ρ20 :: Row k2). (KnownSymbol ℓ0, c τ10 τ20, HasType ℓ0 τ10 ρ10, HasType ℓ0 τ20 ρ20) => Label ℓ0 -> f ρ10 ρ20 -> p (f (ρ10 .- ℓ0) (ρ20 .- ℓ0)) (h τ10 τ20)) -> (forall (ℓ1 :: Symbol) (τ11 :: k1) (τ21 :: k2) (ρ11 :: Row k1) (ρ21 :: Row k2). (KnownSymbol ℓ1, c τ11 τ21, FrontExtends ℓ1 τ11 ρ11, FrontExtends ℓ1 τ21 ρ21, AllUniqueLabels (Extend ℓ1 τ11 ρ11), AllUniqueLabels (Extend ℓ1 τ21 ρ21)) => Label ℓ1 -> p (g ρ11 ρ21) (h τ11 τ21) -> g (Extend ℓ1 τ11 ρ11) (Extend ℓ1 τ21 ρ21)) -> f ('R ((ℓ ':-> τ1) ': ρ1)) ('R ((ℓ ':-> τ2) ': ρ2)) -> g ('R ((ℓ ':-> τ1) ': ρ1)) ('R ((ℓ ':-> τ2) ': ρ2)) #
BiForall ('R ('[] :: [LT k1]) :: Row k1) ('R ('[] :: [LT k2]) :: Row k2) (c1 :: k1 -> k2 -> Constraint) # |
Instance details Defined in Data.Row.Internal Methods biMetamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k1) (Empty :: Row k2) -> g (Empty :: Row k1) (Empty :: Row k2)) -> (forall (ℓ :: Symbol) (τ1 :: k1) (τ2 :: k2) (ρ1 :: Row k1) (ρ2 :: Row k2). (KnownSymbol ℓ, c1 τ1 τ2, HasType ℓ τ1 ρ1, HasType ℓ τ2 ρ2) => Label ℓ -> f ρ1 ρ2 -> p (f (ρ1 .- ℓ) (ρ2 .- ℓ)) (h τ1 τ2)) -> (forall (ℓ :: Symbol) (τ1 :: k1) (τ2 :: k2) (ρ1 :: Row k1) (ρ2 :: Row k2). (KnownSymbol ℓ, c1 τ1 τ2, FrontExtends ℓ τ1 ρ1, FrontExtends ℓ τ2 ρ2, AllUniqueLabels (Extend ℓ τ1 ρ1), AllUniqueLabels (Extend ℓ τ2 ρ2)) => Label ℓ -> p (g ρ1 ρ2) (h τ1 τ2) -> g (Extend ℓ τ1 ρ1) (Extend ℓ τ2 ρ2)) -> f ('R ('[] :: [LT k1])) ('R ('[] :: [LT k2])) -> g ('R ('[] :: [LT k1])) ('R ('[] :: [LT k2])) #
(KnownSymbol ℓ, c τ, Forall ('R ρ) c, FrontExtends ℓ τ ('R ρ), AllUniqueLabels (Extend ℓ τ ('R ρ))) => Forall ('R ((ℓ ':-> τ) ': ρ) :: Row k) (c :: k -> Constraint) # |
Instance details Defined in Data.Row.Internal Methods metamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k) -> g (Empty :: Row k)) -> (forall (ℓ0 :: Symbol) (τ0 :: k) (ρ0 :: Row k). (KnownSymbol ℓ0, c τ0, HasType ℓ0 τ0 ρ0) => Label ℓ0 -> f ρ0 -> p (f (ρ0 .- ℓ0)) (h τ0)) -> (forall (ℓ1 :: Symbol) (τ1 :: k) (ρ1 :: Row k). (KnownSymbol ℓ1, c τ1, FrontExtends ℓ1 τ1 ρ1, AllUniqueLabels (Extend ℓ1 τ1 ρ1)) => Label ℓ1 -> p (g ρ1) (h τ1) -> g (Extend ℓ1 τ1 ρ1)) -> f ('R ((ℓ ':-> τ) ': ρ)) -> g ('R ((ℓ ':-> τ) ': ρ)) #
Forall ('R ('[] :: [LT k]) :: Row k) (c :: k -> Constraint) # |
Instance details Defined in Data.Row.Internal Methods metamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k) -> g (Empty :: Row k)) -> (forall (ℓ :: Symbol) (τ :: k) (ρ :: Row k). (KnownSymbol ℓ, c τ, HasType ℓ τ ρ) => Label ℓ -> f ρ -> p (f (ρ .- ℓ)) (h τ)) -> (forall (ℓ :: Symbol) (τ :: k) (ρ :: Row k). (KnownSymbol ℓ, c τ, FrontExtends ℓ τ ρ, AllUniqueLabels (Extend ℓ τ ρ)) => Label ℓ -> p (g ρ) (h τ) -> g (Extend ℓ τ ρ)) -> f ('R ('[] :: [LT k])) -> g ('R ('[] :: [LT k])) #

type Empty = 'R ('[] :: [LT a]) #

Type level version of `empty`

data HideType where #

Elements stored in a Row type are usually hidden.

Constructors

HideType :: forall a. a -> HideType |

# Row Operations

type family Extend (l :: Symbol) (a :: k) (r :: Row k) :: Row k where ... #

Type level Row extension

Equations

Extend l (a2 :: a1) ('R ('[] :: [LT a1]) :: Row a1) = 'R '[l ':-> a2] |
Extend l (a2 :: a1) ('R x :: Row a1) = 'R (Inject (l ':-> a2) x) |

type family Modify (l :: Symbol) (a :: k) (r :: Row k) :: Row k where ... #

Type level Row modification

Equations

Modify l (a2 :: a1) ('R ρ :: Row a1) = 'R (ModifyR l a2 ρ) |

type family Rename (l :: Symbol) (l' :: Symbol) (r :: Row k) :: Row k where ... #

Type level row renaming

Equations

Rename l l' (r :: Row k) = Extend l' (r .! l) (r .- l) |

type (.==) (l :: Symbol) (a :: k) = Extend l a (Empty :: Row k) infix 7 #

A type level way to create a singleton Row.

type family (r :: Row k) .! (t :: Symbol) :: k where ... infixl 5 #

Type level label fetching

Equations

('R r :: Row k) .! l = Get l r |

type family (r :: Row k) .- (s :: Symbol) :: Row k where ... infixl 6 #

Type level Row element removal

Equations

('R r :: Row a) .- l = 'R (Remove l r) |

type family (l :: Row k) .\\ (r :: Row k) :: Row k where ... infixl 6 #

Type level Row difference. That is, `l `.\\` r` is the row remaining after removing any matching elements of `r` from `l`.

Equations

('R l :: Row a) .\\ ('R r :: Row a) = 'R (Diff l r) |

## Various row-type merges

The difference between `.+` (read "append"), `.\/` (read "min-join"), and `.\\` (read "const-union") comes down to how duplicates are handled. In `.+`, the two given row-types must be entirely unique. Even the same entry in both row-types is forbidden. In `.\/`, this final restriction is relaxed, allowing two row-types that have no conflicts to be merged in the logical way. The `.\\` operator is the most liberal, allowing any two row-types to be merged together, and whenever there is a conflict, favoring the left argument.

As examples of use:

- `.+` is used when appending two records, assuring that those two records are entirely disjoint.
- `.\/` is used when diversifying a variant, allowing some extension to the row-type so long as no original types have changed.
- `.//` is used when doing record overwrite, allowing data in a record to totally overwrite what was previously there.

type family (l :: Row k) .+ (r :: Row k) :: Row k where ... infixl 6 #

Type level Row append

Equations

(x :: Row k) .+ ('R ('[] :: [LT k]) :: Row k) = x |
('R ('[] :: [LT k]) :: Row k) .+ (y :: Row k) = y |
(x :: Row k) .+ ('R '[l ':-> a] :: Row k) = Extend l a x |
('R '[l ':-> a] :: Row k) .+ (y :: Row k) = Extend l a y |
('R l :: Row a) .+ ('R r :: Row a) = 'R (Merge l r) |

type family (l :: Row k) .\/ (r :: Row k) :: Row k where ... infixl 6 #

The minimum join of the two rows.

Equations

(x :: Row k) .\/ ('R ('[] :: [LT k]) :: Row k) = x |
('R ('[] :: [LT k]) :: Row k) .\/ (y :: Row k) = y |
('R l :: Row a) .\/ ('R r :: Row a) = 'R (MinJoinR l r) |

type family (l :: Row k) .// (r :: Row k) :: Row k where ... infixl 6 #

The overwriting union, where the left row overwrites the types of the right row where the labels overlap.

Equations

(x :: Row k) .// ('R ('[] :: [LT k]) :: Row k) = x |
('R ('[] :: [LT k]) :: Row k) .// (y :: Row k) = y |
('R l :: Row a) .// ('R r :: Row a) = 'R (ConstUnionR l r) |

# Row Constraints

class Lacks (l :: Symbol) (r :: Row Type) #

Alias for `.\`. It is a class rather than an alias, so that it can be partially applied.

#### Instances

Instances details

r .\ l => Lacks l r # |
Instance details Defined in Data.Row.Internal

type family (r :: Row k) .\ (l :: Symbol) where ... infixl 4 #

Does the row lack (i.e. it does not have) the specified label?

Equations

('R ('[] :: [LT k]) :: Row k) .\ l = Unconstrained |
('R r :: Row k) .\ l = LacksR l r r |

class (r .! l) ≈ a => HasType (l :: Symbol) (a :: k) (r :: Row k) #

Alias for `(r .! l) ≈ a`. It is a class rather than an alias, so that it can be partially applied.

#### Instances

Instances details

(r .! l) ≈ a => HasType l (a :: k) (r :: Row k) # |
Instance details Defined in Data.Row.Internal

class Forall (r :: Row k) (c :: k -> Constraint) where #

Any structure over a row in which every element is similarly constrained can be metamorphized into another structure over the same row.

Methods

metamorph #

Arguments

:: forall p f g h. Bifunctor p |
=> Proxy (Proxy h, Proxy p) |
-> (f (Empty :: Row k) -> g (Empty :: Row k)) | The way to transform the empty element
-> (forall (ℓ :: Symbol) (τ :: k) (ρ :: Row k). (KnownSymbol ℓ, c τ, HasType ℓ τ ρ) => Label ℓ -> f ρ -> p (f (ρ .- ℓ)) (h τ)) | The unfold
-> (forall (ℓ :: Symbol) (τ :: k) (ρ :: Row k). (KnownSymbol ℓ, c τ, FrontExtends ℓ τ ρ, AllUniqueLabels (Extend ℓ τ ρ)) => Label ℓ -> p (g ρ) (h τ) -> g (Extend ℓ τ ρ)) | The fold
-> f r | The input structure
-> g r |

A metamorphism is an anamorphism (an unfold) followed by a catamorphism (a fold). The parameter `p` describes the output of the unfold and the input of the fold. For records, `p = (,)`, because every entry in the row will unfold to a value paired with the rest of the record. For variants, `p = Either`, because there will either be a value or future types to explore. `Const` can be useful when the types in the row are unnecessary.

#### Instances

Instances details

(KnownSymbol ℓ, c τ, Forall ('R ρ) c, FrontExtends ℓ τ ('R ρ), AllUniqueLabels (Extend ℓ τ ('R ρ))) => Forall ('R ((ℓ ':-> τ) ': ρ) :: Row k) (c :: k -> Constraint) # |
Instance details Defined in Data.Row.Internal Methods metamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k) -> g (Empty :: Row k)) -> (forall (ℓ0 :: Symbol) (τ0 :: k) (ρ0 :: Row k). (KnownSymbol ℓ0, c τ0, HasType ℓ0 τ0 ρ0) => Label ℓ0 -> f ρ0 -> p (f (ρ0 .- ℓ0)) (h τ0)) -> (forall (ℓ1 :: Symbol) (τ1 :: k) (ρ1 :: Row k). (KnownSymbol ℓ1, c τ1, FrontExtends ℓ1 τ1 ρ1, AllUniqueLabels (Extend ℓ1 τ1 ρ1)) => Label ℓ1 -> p (g ρ1) (h τ1) -> g (Extend ℓ1 τ1 ρ1)) -> f ('R ((ℓ ':-> τ) ': ρ)) -> g ('R ((ℓ ':-> τ) ': ρ)) #
Forall ('R ('[] :: [LT k]) :: Row k) (c :: k -> Constraint) # |
Instance details Defined in Data.Row.Internal Methods metamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k) -> g (Empty :: Row k)) -> (forall (ℓ :: Symbol) (τ :: k) (ρ :: Row k). (KnownSymbol ℓ, c τ, HasType ℓ τ ρ) => Label ℓ -> f ρ -> p (f (ρ .- ℓ)) (h τ)) -> (forall (ℓ :: Symbol) (τ :: k) (ρ :: Row k). (KnownSymbol ℓ, c τ, FrontExtends ℓ τ ρ, AllUniqueLabels (Extend ℓ τ ρ)) => Label ℓ -> p (g ρ) (h τ) -> g (Extend ℓ τ ρ)) -> f ('R ('[] :: [LT k])) -> g ('R ('[] :: [LT k])) #

class BiForall (r1 :: Row k1) (r2 :: Row k2) (c :: k1 -> k2 -> Constraint) where #

Any structure over two rows in which the elements of each row satisfy some constraints can be metamorphized into another structure over both of the rows.

Methods

biMetamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k1) (Empty :: Row k2) -> g (Empty :: Row k1) (Empty :: Row k2)) -> (forall (ℓ :: Symbol) (τ1 :: k1) (τ2 :: k2) (ρ1 :: Row k1) (ρ2 :: Row k2). (KnownSymbol ℓ, c τ1 τ2, HasType ℓ τ1 ρ1, HasType ℓ τ2 ρ2) => Label ℓ -> f ρ1 ρ2 -> p (f (ρ1 .- ℓ) (ρ2 .- ℓ)) (h τ1 τ2)) -> (forall (ℓ :: Symbol) (τ1 :: k1) (τ2 :: k2) (ρ1 :: Row k1) (ρ2 :: Row k2). (KnownSymbol ℓ, c τ1 τ2, FrontExtends ℓ τ1 ρ1, FrontExtends ℓ τ2 ρ2, AllUniqueLabels (Extend ℓ τ1 ρ1), AllUniqueLabels (Extend ℓ τ2 ρ2)) => Label ℓ -> p (g ρ1 ρ2) (h τ1 τ2) -> g (Extend ℓ τ1 ρ1) (Extend ℓ τ2 ρ2)) -> f r1 r2 -> g r1 r2 #

A metamorphism is an anamorphism (an unfold) followed by a catamorphism (a fold).

#### Instances

Instances details

(KnownSymbol ℓ, c τ1 τ2, BiForall ('R ρ1) ('R ρ2) c, FrontExtends ℓ τ1 ('R ρ1), FrontExtends ℓ τ2 ('R ρ2), AllUniqueLabels (Extend ℓ τ1 ('R ρ1)), AllUniqueLabels (Extend ℓ τ2 ('R ρ2))) => BiForall ('R ((ℓ ':-> τ1) ': ρ1) :: Row k1) ('R ((ℓ ':-> τ2) ': ρ2) :: Row k2) (c :: k1 -> k2 -> Constraint) # |
Instance details Defined in Data.Row.Internal Methods biMetamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k1) (Empty :: Row k2) -> g (Empty :: Row k1) (Empty :: Row k2)) -> (forall (ℓ0 :: Symbol) (τ10 :: k1) (τ20 :: k2) (ρ10 :: Row k1) (ρ20 :: Row k2). (KnownSymbol ℓ0, c τ10 τ20, HasType ℓ0 τ10 ρ10, HasType ℓ0 τ20 ρ20) => Label ℓ0 -> f ρ10 ρ20 -> p (f (ρ10 .- ℓ0) (ρ20 .- ℓ0)) (h τ10 τ20)) -> (forall (ℓ1 :: Symbol) (τ11 :: k1) (τ21 :: k2) (ρ11 :: Row k1) (ρ21 :: Row k2). (KnownSymbol ℓ1, c τ11 τ21, FrontExtends ℓ1 τ11 ρ11, FrontExtends ℓ1 τ21 ρ21, AllUniqueLabels (Extend ℓ1 τ11 ρ11), AllUniqueLabels (Extend ℓ1 τ21 ρ21)) => Label ℓ1 -> p (g ρ11 ρ21) (h τ11 τ21) -> g (Extend ℓ1 τ11 ρ11) (Extend ℓ1 τ21 ρ21)) -> f ('R ((ℓ ':-> τ1) ': ρ1)) ('R ((ℓ ':-> τ2) ': ρ2)) -> g ('R ((ℓ ':-> τ1) ': ρ1)) ('R ((ℓ ':-> τ2) ': ρ2)) #
BiForall ('R ('[] :: [LT k1]) :: Row k1) ('R ('[] :: [LT k2]) :: Row k2) (c1 :: k1 -> k2 -> Constraint) # |
Instance details Defined in Data.Row.Internal Methods biMetamorph :: forall p f g h. Bifunctor p => Proxy (Proxy h, Proxy p) -> (f (Empty :: Row k1) (Empty :: Row k2) -> g (Empty :: Row k1) (Empty :: Row k2)) -> (forall (ℓ :: Symbol) (τ1 :: k1) (τ2 :: k2) (ρ1 :: Row k1) (ρ2 :: Row k2). (KnownSymbol ℓ, c1 τ1 τ2, HasType ℓ τ1 ρ1, HasType ℓ τ2 ρ2) => Label ℓ -> f ρ1 ρ2 -> p (f (ρ1 .- ℓ) (ρ2 .- ℓ)) (h τ1 τ2)) -> (forall (ℓ :: Symbol) (τ1 :: k1) (τ2 :: k2) (ρ1 :: Row k1) (ρ2 :: Row k2). (KnownSymbol ℓ, c1 τ1 τ2, FrontExtends ℓ τ1 ρ1, FrontExtends ℓ τ2 ρ2, AllUniqueLabels (Extend ℓ τ1 ρ1), AllUniqueLabels (Extend ℓ τ2 ρ2)) => Label ℓ -> p (g ρ1 ρ2) (h τ1 τ2) -> g (Extend ℓ τ1 ρ1) (Extend ℓ τ2 ρ2)) -> f ('R ('[] :: [LT k1])) ('R ('[] :: [LT k2])) -> g ('R ('[] :: [LT k1])) ('R ('[] :: [LT k2])) #

class (c1 x, c2 y) => BiConstraint (c1 :: k -> Constraint) (c2 :: k1 -> Constraint) (x :: k) (y :: k1) #

A pair of constraints

#### Instances

Instances details

(c1 x, c2 y) => BiConstraint (c1 :: k1 -> Constraint) (c2 :: k2 -> Constraint) (x :: k1) (y :: k2) # |
Instance details Defined in Data.Row.Internal

class Unconstrained #

A null constraint

#### Instances

Instances details

Unconstrained # |
Instance details Defined in Data.Row.Internal

class Unconstrained1 (a :: k) #

A null constraint of one argument

#### Instances

Instances details

Unconstrained1 (a :: k) # |
Instance details Defined in Data.Row.Internal

class Unconstrained2 (a :: k) (b :: k1) #

A null constraint of two arguments

#### Instances

Instances details

Unconstrained2 (a :: k1) (b :: k2) # |
Instance details Defined in Data.Row.Internal

class FrontExtends (l :: Symbol) (t :: k) (r :: Row k) where #

A class wrapper for `FrontExtendsDict`.

Methods

frontExtendsDict :: FrontExtendsDict l t r #

#### Instances

Instances details

(r ~ 'R ρ, 'R ((l ':-> t) ': ρ) ≈ Extend l t ('R ρ), AllUniqueLabelsR ((l ':-> t) ': ρ)) => FrontExtends l (t :: k) (r :: Row k) # |
Instance details Defined in Data.Row.Internal Methods frontExtendsDict :: FrontExtendsDict l t r #

data FrontExtendsDict (l :: Symbol) (t :: k) (r :: Row k) #

A dictionary of information that proves that extending a row-type `r` with a label `l` will necessarily put it to the front of the underlying row-type list. This is quite internal and should not generally be necessary.

Constructors

FrontExtendsDict (Dict (r ~ 'R ρ, 'R ((l ':-> t) ': ρ) ≈ Extend l t ('R ρ), AllUniqueLabelsR ((l ':-> t) ': ρ))) |

type WellBehaved (ρ :: Row k) = (Forall ρ (Unconstrained1 :: k -> Constraint), AllUniqueLabels ρ) #

A convenient way to provide common, easy constraints

type family AllUniqueLabels (r :: Row k) where ... #

Are all of the labels in this Row unique?

Equations

AllUniqueLabels ('R r :: Row k) = AllUniqueLabelsR r |

type family Ap (fs :: Row (a -> b)) (r :: Row a) :: Row b where ... #

Take two rows with the same labels, and apply the type operator from the first row to the type of the second.

Equations

Ap ('R fs :: Row (a1 -> a2)) ('R r :: Row a1) = 'R (ApR fs r) |

type family ApSingle (fs :: Row (a -> b)) (x :: a) :: Row b where ... #

Take a row of type operators and apply each to the second argument.

Equations

ApSingle ('R fs :: Row (a1 -> a2)) (x :: a1) = 'R (ApSingleR fs x) |

type family Zip (r1 :: Row Type) (r2 :: Row Type) :: Row Type where ... #

Zips two rows together to create a Row of the pairs. The two rows must have the same set of labels.

Equations

Zip ('R r1) ('R r2) = 'R (ZipR r1 r2) |

type family Map (f :: a -> b) (r :: Row a) :: Row b where ... #

Map a type level function over a Row.

Equations

Map (f :: a1 -> a2) ('R r :: Row a1) = 'R (MapR f r) |

type family Subset (r1 :: Row k) (r2 :: Row k) where ... #

Is the first row a subset of the second? Or, does the second row contain every binding that the first one does?

Equations

Subset ('R ('[] :: [LT k]) :: Row k) (r :: Row k) = Unconstrained |
Subset ('R ((l ':-> a) ': x) :: Row k) (r :: Row k) = ((r .! l) ≈ a, Subset ('R x) r) |

type Disjoint (l :: Row k) (r :: Row k) = (WellBehaved l, WellBehaved r, Subset l (l .+ r), Subset r (l .+ r), ((l .+ r) .\\ l) ≈ r, ((l .+ r) .\\ r) ≈ l) #

A type synonym for disjointness.

# Helper functions

type family Labels (r :: Row a) :: [Symbol] where ... #

The labels in a Row.

Equations

Labels ('R ('[] :: [LT a]) :: Row a) = '[] :: [Symbol] |
Labels ('R ((l ':-> a2) ': xs) :: Row a1) = l ': Labels ('R xs) |

labels :: forall {k} (ρ :: Row k) (c :: k -> Constraint) s. (IsString s, Forall ρ c) => [s] #

Return a list of the labels in a row type.

labels' :: forall {k} (ρ :: Row k) s. (IsString s, Forall ρ (Unconstrained1 :: k -> Constraint)) => [s] #

Return a list of the labels in a row type and is specialized to the `Unconstrained1` constraint.

show' :: (IsString s, Show a) => a -> s #

A helper function for showing labels

toKey :: forall (s :: Symbol). KnownSymbol s => Label s -> Text #

A helper function to turn a Label directly into `Text`.

type (≈) (a :: k) (b :: k) = a ~ b infix 4 #

A lower fixity operator for type equality