HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulerow-types-1.0.1.2Haskell2010

Data.Row

This module includes a set of common functions for Records and Variants. It includes:

  • Common constructors, destructors, and querying functions

It specifically excludes:

  • Functions that have the same name for Records and Variants (e.g. focus, update, fromLabels, etc.)

  • Common clashes with the standard Prelude or other modules (e.g. map, sequence, zip, Map, etc.)

If these particular functions are needed, they should be brought in qualified from one of the Data.Row.*** modules directly.

  • 11 types
  • 5 classes
  • 14 values

Types and constraints

23 declarations
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 Var (r :: Row Type) where
#

The variant type.

Instances8AsConstructor', AsConstructor, Eq, Ord, Show, Generic, …
newtypenewtype Rec (r :: Row Type) where
#

A record with row r.

Instances9HasField', HasField, Bounded, Eq, Ord, Show, …
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.

typetype Empty = 'R '[]
#

Type level version of empty

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

A lower fixity operator for type equality

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

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
#

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

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

Instances2Forall
valueswitch :: BiForall r v (AppliesTo x) => Var v -> Rec r -> x
#

A Var and a Rec can combine if their rows line up properly. Given a Variant along with a Record of functions from each possible value of the variant to a single output type, apply the correct function to the value in the variant.

Record Construction

4 declarations
typetype (.==) (l :: Symbol) (a :: k) = Extend l a Empty
#

A type level way to create a singleton Row.

patternpattern (:==) :: KnownSymbol l => Label l -> a -> Rec (l .== a)
#

A pattern for the singleton record; can be used to both destruct a record when in a pattern position or construct one in an expression position.

Restriction

familytype family (.-) (r :: Row k) (s :: Symbol) :: Row k where
#

Type level Row element removal

Equations

  • (.-) ('R r) l = 'R (Remove l r)

Query

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

Type level label fetching

Equations

  • (.!) ('R r) l = Get l r

Union

patternpattern (:+) :: Disjoint l r => Rec l -> Rec r -> Rec (l .+ r)
#

A pattern version of record union, for use in pattern matching.

value(.//) :: Rec r -> Rec r' -> Rec (r .// r')
#

Record overwrite.

The operation r .// r' creates a new record such that:

  • Any label that is in both r and r' is in the resulting record with the type and value given by the fields in r,

  • Any label that is only found in r is in the resulting record.

  • Any label that is only found in r' is in the resulting record.

This can be thought of as r "overwriting" r'.

Variant construction

1 declaration
patternpattern IsJust :: (AllUniqueLabels r, KnownSymbol l) => Label l -> r .! l -> Var r
#

A pattern for variants; can be used to both destruct a variant when in a pattern position or construct one in an expression position.

Expansion

Destruction

valuetrial :: KnownSymbol l => Var r -> Label l -> Either (Var (r .- l)) (r .! l)
#

Convert a variant into either the value at the given label or a variant without that label. This is the basic variant destructor.

Labels

1 declaration