base-4.7.0.0: Basic libraries

LicenseBSD-style (see the LICENSE file in the distribution)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilitynot portable
Safe HaskellNone
LanguageHaskell2010

Data.Type.Equality

Contents

Description

Definition of propositional equality (:~:). Pattern-matching on a variable of type (a :~: b) produces a proof that a ~ b.

Since: 4.7.0.0

Synopsis

The equality type

data a :~: b whereSource

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.

Since: 4.7.0.0

Constructors

Refl :: a :~: a 

Instances

Category k ((:~:) k) 
TestEquality k ((:~:) k a) 
TestCoercion k ((:~:) k a) 
Typeable (k -> k -> *) ((:~:) k) 
(~) k a b => Bounded ((:~:) k a b) 
(~) k a b => Enum ((:~:) k a b) 
Eq ((:~:) k a b) 
((~) * a b, Data a) => Data ((:~:) * a b) 
Ord ((:~:) k a b) 
(~) k a b => Read ((:~:) k a b) 
Show ((:~:) k a b) 

Working with equality

sym :: (a :~: b) -> b :~: aSource

Symmetry of equality

trans :: (a :~: b) -> (b :~: c) -> a :~: cSource

Transitivity of equality

castWith :: (a :~: b) -> a -> bSource

Type-safe cast, using propositional equality

gcastWith :: (a :~: b) -> (a ~ b => r) -> rSource

Generalized form of type-safe cast using propositional equality

apply :: (f :~: g) -> (a :~: b) -> f a :~: g bSource

Apply one equality to another, respectively

inner :: (f a :~: g b) -> a :~: bSource

Extract equality of the arguments from an equality of a applied types

outer :: (f a :~: g b) -> f :~: gSource

Extract equality of type constructors from an equality of applied types

Inferring equality from other types

class TestEquality f whereSource

This class contains types where you can learn the equality of two types from information contained in terms. Typically, only singleton types should inhabit this class.

Methods

testEquality :: f a -> f b -> Maybe (a :~: b)Source

Conditionally prove the equality of a and b.

Instances

Boolean type-level equality

type family a == b :: BoolSource

A type family to compute Boolean equality. Instances are provided only for open kinds, such as * and function kinds. Instances are also provided for datatypes exported from base. A poly-kinded instance is not provided, as a recursive definition for algebraic kinds is generally more useful.