HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulerow-types-1.0.1.2Haskell2010

Data.Row.Internal

This module implements the internals of open records and variants.

  • 10 types
  • 10 classes
  • 4 values

Rows

6 declarations
newtypenewtype 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.

classclass KnownSymbol (n :: Symbol) where
#

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

datadata LT a
#

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

Constructors

Instances16BiForall, Forall, GenericRec, GenericVar, RepRec, RepVar, …
typetype Empty = 'R '[]
#

Type level version of empty

Row Operations

10 declarations
familytype family Modify (l :: Symbol) (a :: k) (r :: Row k) :: Row k where
#

Type level Row modification

Equations

  • Modify l a2 ('R ρ) = 'R (ModifyR l a2 ρ)
typetype (.==) (l :: Symbol) (a :: k) = Extend l a Empty
#

A type level way to create a singleton Row.

familytype family (.!) (r :: Row k) (t :: Symbol) :: k where
#

Type level label fetching

Equations

  • (.!) ('R r) l = Get l r
familytype family (.-) (r :: Row k) (s :: Symbol) :: Row k where
#

Type level Row element removal

Equations

  • (.-) ('R r) l = 'R (Remove l r)
familytype family (.\\) (l :: Row k) (r :: Row k) :: Row k where
#

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

Equations

  • (.\\) ('R l) ('R r) = '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.

familytype family (.+) (l :: Row k) (r :: Row k) :: Row k where
#

Type level Row append

Equations

familytype family (.\/) (l :: Row k) (r :: Row k) :: Row k where
#

The minimum join of the two rows.

Equations

  • (.\/) x ('R '[]) = x
  • (.\/) ('R '[]) y = y
  • (.\/) ('R l) ('R r) = 'R (MinJoinR l r)
familytype family (.//) (l :: Row k) (r :: Row k) :: Row k where
#

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

Equations

  • (.//) x ('R '[]) = x
  • (.//) ('R '[]) y = y
  • (.//) ('R l) ('R r) = 'R (ConstUnionR l r)

Row Constraints

19 declarations
classclass Lacks (l :: Symbol) (r :: Row Type)
#

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

Instances1Lacks
  • r .\ l => Lacks l rDefined in row-types-1.0.1.2 · Data.Row.Internal
familytype family (.\) (r :: Row k) (l :: Symbol) :: Constraint where
#

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

Equations

classclass (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.

Instances1HasType
  • (r .! l) ≈ a => HasType l a rDefined in row-types-1.0.1.2 · Data.Row.Internal
classclass 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 :: Bifunctor p => Proxy (Proxy h, Proxy p) -> (f Empty -> g Empty) -> (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

    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.

Instances2Forall
classclass 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

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

A pair of constraints

Instances1BiConstraint
  • (c1 x, c2 y) => BiConstraint c1 c2 x yDefined in row-types-1.0.1.2 · Data.Row.Internal
classclass Unconstrained1 (a :: k)
#

A null constraint of one argument

Instances1Unconstrained1
classclass Unconstrained2 (a :: k) (b :: k1)
#

A null constraint of two arguments

Instances1Unconstrained2
datadata 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

familytype 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) ('R r) = 'R (ApR fs r)
familytype 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

familytype 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)
familytype family Map (f :: a -> b) (r :: Row a) :: Row b where
#

Map a type level function over a Row.

Equations

  • Map f ('R r) = 'R (MapR f r)

Helper functions

6 declarations
typetype (≈) (a :: k) (b :: k) = a ~ b
#

A lower fixity operator for type equality