HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

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.

Contents
  1. Types and constraints
  2. Record Construction
  3. Restriction
  4. Query
  5. Union
  6. Variant construction
  7. Expansion
  8. Destruction
  9. Labels
Synopsis

Types and constraints

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 (≈) (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 (.\/) (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

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

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