base-4.9.0.0: Basic libraries

Data.Type.Coercion

Description

Definition of representational equality (Coercion).

Since: 4.7.0.0

Synopsis

# Documentation

data Coercion a b where Source #

Representational equality. If Coercion a b is inhabited by some terminating value, then the type a has the same underlying representation as the type b.

To use this equality in practice, pattern-match on the Coercion a b to get out the Coercible a b instance, and then use coerce to apply it.

Since: 4.7.0.0

Constructors

 Coercion :: Coercible a b => Coercion a b

Instances

coerceWith :: Coercion a b -> a -> b Source #

Type-safe cast, using representational equality

sym :: Coercion a b -> Coercion b a Source #

Symmetry of representational equality

trans :: Coercion a b -> Coercion b c -> Coercion a c Source #

Transitivity of representational equality

repr :: (a :~: b) -> Coercion a b Source #

Convert propositional (nominal) equality to representational equality

class TestCoercion f where Source #

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.

Minimal complete definition

testCoercion

Methods

testCoercion :: f a -> f b -> Maybe (Coercion a b) Source #

Conditionally prove the representational equality of a and b.

Instances

 TestCoercion k (Coercion k a) Source # MethodstestCoercion :: f a -> f b -> Maybe (Coercion (Coercion k a) a b) Source # TestCoercion k ((:~:) k a) Source # MethodstestCoercion :: f a -> f b -> Maybe (Coercion (k :~: a) a b) Source #