A label
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
- Packagerow-types-1.0.1.2
- Exports42
- LanguageHaskell2010
- LicenceMIT
- SourceRow.hs
Types and constraints
23 declarationsThis class gives the string associated with a type-level symbol. There are instances of the class for every concrete literal: "hello", etc.
Are all of the labels in this Row unique?
Equations
AllUniqueLabels ('R r) = AllUniqueLabelsR r
A convenient way to provide common, easy constraints
The variant type.
Instances8AsConstructor', AsConstructor, Eq, Ord, Show, Generic, …
(AllUniqueLabels r, KnownSymbol name, (r .! name) ≈ a, r ≈ ((r .- name) .\/ (name .== a))) => AsConstructor' name (Var r) aDefined in row-types-1.0.1.2 · Data.Row.Variants(AllUniqueLabels r, AllUniqueLabels r', KnownSymbol name, (r .! name) ≈ a, (r' .! name) ≈ b, r' ≈ ((r .- name) .\/ (name .== b))) => AsConstructor name (Var r) (Var r') a bDefined in row-types-1.0.1.2 · Data.Row.VariantsEvery possibility of a row-types based variant has an AsConstructor instance.
Forall r Eq => Eq (Var r)Defined in row-types-1.0.1.2 · Data.Row.Variants(Forall r Eq, Forall r Ord) => Ord (Var r)Defined in row-types-1.0.1.2 · Data.Row.VariantsForall r Show => Show (Var r)Defined in row-types-1.0.1.2 · Data.Row.VariantsGenericVar r => Generic (Var r)Defined in row-types-1.0.1.2 · Data.Row.VariantsForall r NFData => NFData (Var r)Defined in row-types-1.0.1.2 · Data.Row.Variantstype Rep (Var r) = D1 ('MetaDataDefined in row-types-1.0.1.2 · Data.Row.Variants"Var"
"Data.Row.Variants"
"row-types"
'False) (RepVar r)
A record with row r.
Instances9HasField', HasField, Bounded, Eq, Ord, Show, …
(KnownSymbol name, (r .! name) ≈ a, r ~ Modify name a r) => HasField' name (Rec r) aDefined in row-types-1.0.1.2 · Data.Row.Records(KnownSymbol name, (r' .! name) ≈ b, (r .! name) ≈ a, r' ~ Modify name b r, r ~ Modify name a r') => HasField name (Rec r) (Rec r') a bDefined in row-types-1.0.1.2 · Data.Row.RecordsEvery field in a row-types based record has a HasField instance.
(Forall r Bounded, AllUniqueLabels r) => Bounded (Rec r)Defined in row-types-1.0.1.2 · Data.Row.RecordsForall r Eq => Eq (Rec r)Defined in row-types-1.0.1.2 · Data.Row.Records(Forall r Eq, Forall r Ord) => Ord (Rec r)Defined in row-types-1.0.1.2 · Data.Row.RecordsForall r Show => Show (Rec r)Defined in row-types-1.0.1.2 · Data.Row.RecordsGenericRec r => Generic (Rec r)Defined in row-types-1.0.1.2 · Data.Row.RecordsForall r NFData => NFData (Rec r)Defined in row-types-1.0.1.2 · Data.Row.Recordstype Rep (Rec r) = D1 ('MetaDataDefined in row-types-1.0.1.2 · Data.Row.Records"Rec"
"Data.Row.Records"
"row-types"
'False) (C1 ('MetaCons"Rec"
'PrefixI 'True) (RepRec r))
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.
Type level version of empty
A lower fixity operator for type equality
Alias for (r .! l) ≈ a. It is a class rather than an alias, so that
it can be partially applied.
Alias for .\. It is a class rather than an alias, so that it can be partially applied.
Does the row lack (i.e. it does not have) the specified label?
Equations
(.\) ('R '[]) l = Unconstrained(.\) ('R r) l = LacksR l r r
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
BiForall ('R '[]) ('R '[]) c1Defined in row-types-1.0.1.2 · Data.Row.Internal(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)) ('R ((ℓ ':-> τ2) ': ρ2)) cDefined in row-types-1.0.1.2 · Data.Row.Internal
Any structure over a row in which every element is similarly constrained can be metamorphized into another structure over the same row.
Instances2Forall
Forall ('R '[]) cDefined in row-types-1.0.1.2 · Data.Row.Internal(KnownSymbol ℓ, c τ, Forall ('R ρ) c, FrontExtends ℓ τ ('R ρ), AllUniqueLabels (Extend ℓ τ ('R ρ))) => Forall ('R ((ℓ ':-> τ) ': ρ)) cDefined in row-types-1.0.1.2 · Data.Row.Internal
FreeForall can be used when a Forall constraint is necessary but there is no particular constraint we care about.
FreeForall can be used when a BiForall constraint is necessary but there is no particular constraint we care about.
The same as switch but with the argument order reversed
Record Construction
4 declarationsThe empty record
A type level way to create a singleton Row.
The singleton record
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
Record restriction. Remove the label l from the record.
Query
Record selection
Union
Record disjoint union (commutative)
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.
A pattern version of record union, for use in pattern matching.
Record overwrite.
The operation r .// r' creates a new record such that:
Any label that is in both
randr'is in the resulting record with the type and value given by the fields inr,Any label that is only found in
ris 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 declarationA pattern for variants; can be used to both destruct a variant when in a pattern position or construct one in an expression position.
Expansion
Make the variant arbitrarily more diverse.
Destruction
A Variant with no options is uninhabited.
Convert a variant into either the value at the given label or a variant without that label. This is the basic variant destructor.
A version of trial that ignores the leftover variant.
A trial over multiple types
Labels
1 declarationReturn a list of the labels in a row type.