Copyright | (C) 2011-2014 Edward Kmett 2018 Ryan Scott |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Leibnizian equality à la Data.Eq.Type, generalized to be heterogeneous using higher-rank kinds.
This module is only exposed on GHC 8.2 and later.
Synopsis
- newtype (a :: j) :== (b :: k) = HRefl {}
- refl :: a :== a
- trans :: (a :== b) -> (b :== c) -> a :== c
- symm :: (a :== b) -> b :== a
- coerce :: (a :== b) -> a -> b
- apply :: (f :== g) -> (a :== b) -> f a :== g b
- lift :: (a :== b) -> f a :== f b
- lift2 :: (a :== b) -> f a c :== f b c
- lift2' :: (a :== b) -> (c :== d) -> f a c :== f b d
- lift3 :: (a :== b) -> f a c d :== f b c d
- lift3' :: (a :== b) -> (c :== d) -> (e :== f) -> g a c e :== g b d f
- lower :: forall a b f g. (f a :== g b) -> a :== b
- lower2 :: forall a b f g c c'. (f a c :== g b c') -> a :== b
- lower3 :: forall a b f g c c' d d'. (f a c d :== g b c' d') -> a :== b
- toHomogeneous :: (a :== b) -> a := b
- fromHomogeneous :: (a := b) -> a :== b
- fromLeibniz :: forall a b. (a :== b) -> a :~: b
- toLeibniz :: (a :~: b) -> a :== b
- heteroFromLeibniz :: (a :== b) -> a :~~: b
- heteroToLeibniz :: (a :~~: b) -> a :== b
- reprLeibniz :: (a :== b) -> Coercion a b
Heterogeneous Leibnizian equality
newtype (a :: j) :== (b :: k) infixl 4 Source #
Heterogeneous Leibnizian equality.
Leibnizian equality states that two things are equal if you can substitute one for the other in all contexts.
Instances
Category ((:==) :: k -> k -> Type) Source # | Equality forms a category. |
Groupoid ((:==) :: k -> k -> Type) Source # | |
Defined in Data.Eq.Type.Hetero | |
Semigroupoid ((:==) :: k -> k -> Type) Source # | |
TestCoercion ((:==) a :: k -> Type) Source # | |
Defined in Data.Eq.Type.Hetero | |
TestEquality ((:==) a :: k -> Type) Source # | |
Defined in Data.Eq.Type.Hetero |
Equality as an equivalence relation
Lifting equality
Lowering equality
lower :: forall a b f g. (f a :== g b) -> a :== b Source #
Type constructors are generative and injective, so you can lower equality through any type constructors.
:=
equivalence
:=
is equivalent in power
toHomogeneous :: (a :== b) -> a := b Source #
Convert an appropriately kinded heterogeneous Leibnizian equality into
a homogeneous Leibnizian equality (:=)
.
fromHomogeneous :: (a := b) -> a :== b Source #
Convert a homogeneous Leibnizian equality (:=)
to an appropriately kinded
heterogeneous Leibizian equality.
:~:
equivalence
:~:
is equivalent in power
fromLeibniz :: forall a b. (a :== b) -> a :~: b Source #
:~~:
equivalence
:~~:
is equivalent in power
heteroFromLeibniz :: (a :== b) -> a :~~: b Source #
heteroToLeibniz :: (a :~~: b) -> a :== b Source #
Coercion
conversion
Leibnizian equality can be converted to representational equality
reprLeibniz :: (a :== b) -> Coercion a b Source #