Lifted, homogeneous equality. By lifted, we mean that it
can be bogus (deferred type error). By homogeneous, the two
types a and b must have the same kinds.
Moduleghc-internal-9.1003.0Haskell2010
GHC.Internal.Data.Type.Equality
Definition of propositional equality (:~:). Pattern-matching on a variable
of type (a :~: b) produces a proof that a ~ b.
- 2 types
- 3 classes
- 7 values
- Packageghc-internal-9.1003.0
- Exports13
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceEquality.hs
The equality types
4 declarationsLifted, heterogeneous equality. By lifted, we mean that it
can be bogus (deferred type error). By heterogeneous, the two
types a and b might have different kinds. Because ~~ can
appear unexpectedly in error messages to users who do not care
about the difference between heterogeneous equality ~~ and
homogeneous equality ~, this is printed as ~ unless
-fprint-equality-relations is set.
In 0.7.0, the fixity was set to infix 4 to match the fixity of Data.Type.Equality.:~~:.
Propositional equality. If a :~: b is inhabited by some terminating
value, then the type a is the same as the type b. To use this equality
in practice, pattern-match on the a :~: b to get out the Refl constructor;
in the body of the pattern-match, the compiler knows that a ~ b.
Instances10Category, TestCoercion, TestEquality, Bounded, Enum, Eq, …
Category (:~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.CategoryTestCoercion ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.CoercionTestEquality ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~ b => Bounded (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~ b => Enum (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityEq (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality(a ~ b, Data a) => Data (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.DataOrd (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityShow (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
Kind heterogeneous propositional equality. Like :~:, a :~~: b is
inhabited by a terminating value if and only if a is the same type as b.
Instances10Category, TestCoercion, TestEquality, Bounded, Enum, Eq, …
Category (:~~:)Defined in ghc-internal-9.1003.0 · GHC.Internal.Control.CategoryTestCoercion ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.CoercionTestEquality ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~~ b => Bounded (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~~ b => Enum (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityEq (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality(Typeable i, Typeable j, Typeable a, Typeable b, a ~~ b) => Data (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.DataOrd (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equalitya ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityShow (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality
Working with equality
7 declarationsSymmetry of equality
Transitivity of equality
Type-safe cast, using propositional equality
Generalized form of type-safe cast using propositional equality
Apply one equality to another, respectively
Extract equality of the arguments from an equality of applied types
Extract equality of type constructors from an equality of applied types
Inferring equality from other types
1 declarationThis class contains types where you can learn the equality of two types from information contained in terms.
The result should be Just Refl if and only if the types applied to f are
equal:
testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = bTypically, only singleton types should inhabit this class. In that case type argument equality coincides with term equality:
testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = yisJust (testEquality x y) = x == ySingleton types are not required, however, and so the latter two would-be laws are not in fact valid in general.
Methods
testEquality :: f a -> f b -> Maybe (a :~: b)Conditionally prove the equality of
aandb.
Instances6TestEquality
TestEquality SCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLitsTestEquality SSymbolDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLitsTestEquality SNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNatsTestEquality TypeRepDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Typeable.InternalTestEquality ((:~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityTestEquality ((:~~:) a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Equality