Moduledependent-sum-0.6.2.0Haskell98
Data.GADT.Compare
- 3 types
- 2 classes
- 4 values
- Packagedependent-sum-0.6.2.0
- Exports9
- LanguageHaskell98
- LicenceLicenseRef-PublicDomain
- SourceCompare.hs
If f has a GEq instance, this function makes a suitable default
implementation of (==).
If f has a GEq instance, this function makes a suitable default
implementation of (/=).
TODO: Think of a better name
This operation forgets the phantom types of a GOrdering value.
Deprecated. use (:~:) from 'Data.Type,Equality'.
Backwards compatibility alias; as of GHC 7.8, this is the same as (:~:).
Type class for comparable GADT-like structures. When 2 things are equal, must return a witness that their parameter types are equal as well (GEQ).
Instances4GCompare
GCompare TypeRepDefined in dependent-sum-0.6.2.0 · Data.GADT.CompareGCompare ((:~:) a)Defined in dependent-sum-0.6.2.0 · Data.GADT.Compare(GCompare a, GCompare b) => GCompare (Product a b)Defined in dependent-sum-0.6.2.0 · Data.GADT.Compare(GCompare a, GCompare b) => GCompare (Sum a b)Defined in dependent-sum-0.6.2.0 · Data.GADT.Compare
A class for type-contexts which contain enough information to (at least in some cases) decide the equality of types occurring within them.
Methods
geq :: f a -> f b -> Maybe (a :~: b)Produce a witness of type-equality, if one exists.
A handy idiom for using this would be to pattern-bind in the Maybe monad, eg.:
extract :: GEq tag => tag a -> DSum tag -> Maybe a extract t1 (t2 :=> x) = do Refl <- geq t1 t2 return xOr in a list comprehension:
extractMany :: GEq tag => tag a -> [DSum tag] -> [a] extractMany t1 things = [ x | (t2 :=> x) <- things, Refl <- maybeToList (geq t1 t2)](Making use of the
DSumtype from Data.Dependent.Sum in both examples)
Instances4GEq
A type for the result of comparing GADT constructors; the type parameters of the GADT values being compared are included so that in the case where they are equal their parameter types can be unified.
Instances5GRead, GShow, Eq, Ord, Show
GRead (GOrdering a)Defined in dependent-sum-0.6.2.0 · Data.GADT.CompareGShow (GOrdering a)Defined in dependent-sum-0.6.2.0 · Data.GADT.CompareEq (GOrdering a b)Defined in dependent-sum-0.6.2.0 · Data.GADT.CompareOrd (GOrdering a b)Defined in dependent-sum-0.6.2.0 · Data.GADT.CompareShow (GOrdering a b)Defined in dependent-sum-0.6.2.0 · Data.GADT.Compare
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.
Instances19Category, TestCoercion, TestEquality, GEq, GCompare, GRead, …
Category (:~:)Defined in ghc-internal-9.1401.0 · GHC.Internal.Control.CategoryTestCoercion ((:~:) a)Defined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.CoercionTestEquality ((:~:) a)Defined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.EqualityGEq ((:~:) a)Defined in dependent-sum-0.6.2.0 · Data.GADT.CompareGCompare ((:~:) a)Defined in dependent-sum-0.6.2.0 · Data.GADT.CompareGRead ((:~:) a)Defined in dependent-sum-0.6.2.0 · Data.GADT.ShowGShow ((:~:) a)Defined in dependent-sum-0.6.2.0 · Data.GADT.ShowNFData2 (:~:)Defined in deepseq-1.5.1.0 · Control.DeepSeqNFData1 ((:~:) a)Defined in deepseq-1.5.1.0 · Control.DeepSeqa ~ b => Bounded (a :~: b)Defined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.Equalitya ~ b => Enum (a :~: b)Defined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.EqualityEq (a :~: b)Defined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.Equality(a ~ b, Data a) => Data (a :~: b)Defined in ghc-internal-9.1401.0 · GHC.Internal.Data.DataOrd (a :~: b)Defined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.Equalitya ~ b => Read (a :~: b)Defined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.EqualityShow (a :~: b)Defined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.EqualityNFData (a :~: b)Defined in deepseq-1.5.1.0 · Control.DeepSeqa ~ b => Boring (a :~: b)Defined in boring-0.2.2.1 · Data.BoringHomogeneous type equality is Boring too.
HasDict (a ~ b) (a :~: b)Defined in constraints-0.14.4 · Data.Constraint