diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-02-23 18:09:58 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-02-23 18:57:17 -0500 |
commit | c88b7c9a06e387c3b9bdb359b9e1e4f3a9fba696 (patch) | |
tree | d0291e43a1506c10385a4b3e29b5d7cdae3d0b77 /libraries/base/Data/Type/Equality.hs | |
parent | 8d64395b43cb73d110767cab512a368b3db018de (diff) | |
download | haskell-c88b7c9a06e387c3b9bdb359b9e1e4f3a9fba696.tar.gz |
Add instances for (:~~:) mirroring those for (:~:)
`(:~~:)`, the hetergeneous version of `(:~:)`, should have class
instances similar to those of `(:~:)`, especially since their
implementations aren't particularly tricky or surprising. This adds
them.
Reviewers: bgamari, austin, hvr, goldfire
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3181
Diffstat (limited to 'libraries/base/Data/Type/Equality.hs')
-rw-r--r-- | libraries/base/Data/Type/Equality.hs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libraries/base/Data/Type/Equality.hs b/libraries/base/Data/Type/Equality.hs index 73f8407cb0..69da70b78c 100644 --- a/libraries/base/Data/Type/Equality.hs +++ b/libraries/base/Data/Type/Equality.hs @@ -145,6 +145,27 @@ deriving instance a ~ b => Bounded (a :~: b) data (a :: k1) :~~: (b :: k2) where HRefl :: a :~~: a +-- | @since 4.10.0.0 +deriving instance Eq (a :~~: b) +-- | @since 4.10.0.0 +deriving instance Show (a :~~: b) +-- | @since 4.10.0.0 +deriving instance Ord (a :~~: b) + +-- | @since 4.10.0.0 +instance a ~~ b => Read (a :~~: b) where + readsPrec d = readParen (d > 10) (\r -> [(HRefl, s) | ("HRefl",s) <- lex r ]) + +-- | @since 4.10.0.0 +instance a ~~ b => Enum (a :~~: b) where + toEnum 0 = HRefl + toEnum _ = errorWithoutStackTrace "Data.Type.Equality.toEnum: bad argument" + + fromEnum HRefl = 0 + +-- | @since 4.10.0.0 +deriving instance a ~~ b => Bounded (a :~~: b) + -- | 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. @@ -156,6 +177,10 @@ class TestEquality f where instance TestEquality ((:~:) a) where testEquality Refl Refl = Just Refl +-- | @since 4.10.0.0 +instance TestEquality ((:~~:) a) where + testEquality HRefl HRefl = Just Refl + -- | 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 |