Map preserves uniqueness of labels.
Modulerow-types-1.0.1.2Haskell2010
Data.Row.Dictionaries
This module exports various dictionaries that help the type-checker when dealing with row-types.
For the various axioms, type variables are consistently in the following order:
Any types that do not belong later.
Labels
Row-types
If applicable, the type in the row-type at the given label goes after each row-type
Constraints
- 6 types
- 6 classes
- 25 values
- Packagerow-types-1.0.1.2
- Exports37
- LanguageHaskell2010
- LicenceMIT
- SourceDictionaries.hs
Axioms
25 declarationsAp preserves uniqueness of labels.
ApSingle preserves uniqueness of labels.
Zip preserves uniqueness of labels.
If we know that r has been extended with l .== t, then we know that this
extension at the label l must be t.
This allows us to derive Map f r .! l ≈ f t from r .! l ≈ t
apHas :: ((ϕ .! l) ≈ f, (ρ .! l) ≈ t) :- ((Ap ϕ ρ .! l) ≈ f t, (Ap ϕ ρ .- l) ≈ Ap (ϕ .- l) (ρ .- l))This allows us to derive Ap ϕ ρ .! l ≈ f t from ϕ .! l ≈ f and ρ .! l ≈ t
apSingleHas :: ((r .! l) ≈ f) :- ((ApSingle r x .! l) ≈ f x, (ApSingle r x .- l) ≈ ApSingle (r .- l) x)This allows us to derive ApSingle r x .! l ≈ f x from r .! l ≈ f
Proof that the Map type family preserves labels and their ordering.
Proof that the Ap type family preserves labels and their ordering.
Proof that the ApSingle type family preserves labels and their ordering.
Proof that the Ap type family preserves labels and their ordering.
Map distributes over MinJoin
ApSingle distributes over MinJoin
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.
Allow any Forall over a row-type, be usable for Unconstrained1.
This allows us to derive a Forall (Map f r) .. from a Forall r ...
This allows us to derive a Forall (ApSingle f r) .. from a Forall f ...
Two rows are subsets of a third if and only if their disjoint union is a subset of that third.
If two rows are each subsets of a third, their join is a subset of the third
If a row is a subset of another, then its restriction is also a subset of the other
Subset is transitive
Map distributes over Difference
ApSingle distributes over Difference
Helper Types
A class to capture the idea of As so that it can be partially applied in a context.
Instances1IsA
c a => IsA c f (f a)Defined in row-types-1.0.1.2 · Data.Row.Dictionaries
A class to capture the idea of As' so that it can be partially applied in a context.
Instances1ActsOn
c f => ActsOn c t (f t)Defined in row-types-1.0.1.2 · Data.Row.Dictionaries
Re-exports
8 declarationsInstances20:=>, HasDict, Bounded, Enum, Eq, Data, …
() :=> Semigroup (Dict a)Defined in constraints-0.14.2 · Data.Constraint() :=> Show (Dict a)Defined in constraints-0.14.2 · Data.Constraint() :=> Eq (Dict a)Defined in constraints-0.14.2 · Data.Constraint() :=> Ord (Dict a)Defined in constraints-0.14.2 · Data.Constrainta :=> Monoid (Dict a)Defined in constraints-0.14.2 · Data.Constrainta :=> Bounded (Dict a)Defined in constraints-0.14.2 · Data.Constrainta :=> Enum (Dict a)Defined in constraints-0.14.2 · Data.Constrainta :=> Read (Dict a)Defined in constraints-0.14.2 · Data.ConstraintHasDict a (Dict a)Defined in constraints-0.14.2 · Data.Constrainta => Bounded (Dict a)Defined in constraints-0.14.2 · Data.Constrainta => Enum (Dict a)Defined in constraints-0.14.2 · Data.ConstraintEq (Dict a)Defined in constraints-0.14.2 · Data.Constraint(Typeable p, p) => Data (Dict p)Defined in constraints-0.14.2 · Data.ConstraintOrd (Dict a)Defined in constraints-0.14.2 · Data.Constrainta => Read (Dict a)Defined in constraints-0.14.2 · Data.ConstraintShow (Dict a)Defined in constraints-0.14.2 · Data.ConstraintSemigroup (Dict a)Defined in constraints-0.14.2 · Data.Constrainta => Monoid (Dict a)Defined in constraints-0.14.2 · Data.ConstraintNFData (Dict c)Defined in constraints-0.14.2 · Data.Constraintc => Boring (Dict c)Defined in constraints-0.14.2 · Data.Constraint
This is the type of entailment.
a :- b is read as a "entails" b.
With this we can actually build a category for Constraint resolution.
e.g.
Because Eq a is a superclass of Ord a, we can show that Ord a
entails Eq a.
Because instance Ord a => Ord [a] exists, we can show that Ord a
entails Ord [a] as well.
This relationship is captured in the :- entailment type here.
Since p :- p and entailment composes, :- forms the arrows of a
Category of constraints. However, Category only became sufficiently
general to support this instance in GHC 7.8, so prior to 7.8 this instance
is unavailable.
But due to the coherence of instance resolution in Haskell, this Category
has some very interesting properties. Notably, in the absence of
IncoherentInstances, this category is "thin", which is to say that
between any two objects (constraints) there is at most one distinguishable
arrow.
This means that for instance, even though there are two ways to derive
Ord a :- Eq [a], the answers from these two paths _must_ by
construction be equal. This is a property that Haskell offers that is
pretty much unique in the space of languages with things they call "type
classes".
What are the two ways?
Well, we can go from Ord a :- Eq a via the
superclass relationship, and then from Eq a :- Eq [a] via the
instance, or we can go from Ord a :- Ord [a] via the instance
then from Ord [a] :- Eq [a] through the superclass relationship
and this diagram by definition must "commute".
Diagrammatically,
Ord a
ins / \ cls
v v
Ord [a] Eq a
cls \ / ins
v v
Eq [a]This safety net ensures that pretty much anything you can write with this library is sensible and can't break any assumptions on the behalf of library authors.
Instances10Category, :=>, HasDict, Eq, Data, Ord, …
Category (:-)Defined in constraints-0.14.2 · Data.ConstraintPossible since GHC 7.8, when Category was made polykinded.
() :=> Show (a :- b)Defined in constraints-0.14.2 · Data.Constraint() :=> Eq (a :- b)Defined in constraints-0.14.2 · Data.Constraint() :=> Ord (a :- b)Defined in constraints-0.14.2 · Data.Constrainta => HasDict b (a :- b)Defined in constraints-0.14.2 · Data.ConstraintEq (a :- b)Defined in constraints-0.14.2 · Data.ConstraintAssumes
IncoherentInstancesdoesn't exist.(Typeable p, Typeable q, p => q) => Data (p :- q)Defined in constraints-0.14.2 · Data.ConstraintOrd (a :- b)Defined in constraints-0.14.2 · Data.ConstraintAssumes
IncoherentInstancesdoesn't exist.Show (a :- b)Defined in constraints-0.14.2 · Data.Constrainta => NFData (a :- b)Defined in constraints-0.14.2 · Data.Constraint
Witnesses that a value of type e contains evidence of the constraint c.
Mainly intended to allow (\\) to be overloaded, since it's a useful operator.
Instances6HasDict
HasDict a (Dict a)Defined in constraints-0.14.2 · Data.Constrainta => HasDict b (a :- b)Defined in constraints-0.14.2 · Data.ConstraintHasDict (Typeable k, Typeable a) (TypeRep a)Defined in constraints-0.14.2 · Data.ConstraintHasDict (Coercible a b) (Coercion a b)Defined in constraints-0.14.2 · Data.ConstraintHasDict (a ~ b) (a :~: b)Defined in constraints-0.14.2 · Data.ConstraintHasDict (a ~~ b) (a :~~: b)Defined in constraints-0.14.2 · Data.Constraint
Operator version of withDict, with the arguments flipped
From a Dict, takes a value in an environment where the instance witnessed by the Dict is in scope, and evaluates it.
Essentially a deconstruction of a Dict into its continuation-style form.
Can also be used to deconstruct an entailment, a :- b, using a context a.
withDict :: Dict c -> (c => r) -> r
withDict :: a => (a :- c) -> (c => r) -> r
A null constraint
Instances1Unconstrained
UnconstrainedDefined in row-types-1.0.1.2 · Data.Row.Internal
A null constraint of one argument
Instances1Unconstrained1
Unconstrained1 aDefined in row-types-1.0.1.2 · Data.Row.Internal
A null constraint of two arguments
Instances1Unconstrained2
Unconstrained2 a bDefined in row-types-1.0.1.2 · Data.Row.Internal