diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2023-03-22 18:28:32 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2023-03-24 07:33:37 -0400 |
commit | c5a28889a0a20a72c38e8e3f4bbbe75854d8390f (patch) | |
tree | 8aa9f8349736eb81a07685d0c8ff8f9c67701486 | |
parent | b8d783d24b9a617ad1e3038abeb75d322703ef65 (diff) | |
download | haskell-wip/clc-148.tar.gz |
Add Eq/Ord instances for SSymbol, SChar, and SNatwip/clc-148
This implements [CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148).
-rw-r--r-- | libraries/base/GHC/TypeLits.hs | 18 | ||||
-rw-r--r-- | libraries/base/GHC/TypeNats.hs | 8 | ||||
-rw-r--r-- | libraries/base/changelog.md | 2 |
3 files changed, 27 insertions, 1 deletions
diff --git a/libraries/base/GHC/TypeLits.hs b/libraries/base/GHC/TypeLits.hs index 288ec39fc2..ee88741a12 100644 --- a/libraries/base/GHC/TypeLits.hs +++ b/libraries/base/GHC/TypeLits.hs @@ -68,7 +68,7 @@ module GHC.TypeLits ) where -import GHC.Base ( Eq(..), Functor(..), Ord(..), Ordering(..), String +import GHC.Base ( Bool(..), Eq(..), Functor(..), Ord(..), Ordering(..), String , (.), otherwise, withDict, Void, (++) , errorWithoutStackTrace) import GHC.Types(Symbol, Char, TYPE) @@ -374,6 +374,14 @@ data KnownSymbolInstance (s :: Symbol) where knownSymbolInstance :: SSymbol s -> KnownSymbolInstance s knownSymbolInstance ss = withKnownSymbol ss KnownSymbolInstance +-- | @since 4.19.0.0 +instance Eq (SSymbol s) where + _ == _ = True + +-- | @since 4.19.0.0 +instance Ord (SSymbol s) where + compare _ _ = EQ + -- | @since 4.18.0.0 instance Show (SSymbol s) where showsPrec p (UnsafeSSymbol s) @@ -467,6 +475,14 @@ data KnownCharInstance (n :: Char) where knownCharInstance :: SChar c -> KnownCharInstance c knownCharInstance sc = withKnownChar sc KnownCharInstance +-- | @since 4.19.0.0 +instance Eq (SChar c) where + _ == _ = True + +-- | @since 4.19.0.0 +instance Ord (SChar c) where + compare _ _ = EQ + -- | @since 4.18.0.0 instance Show (SChar c) where showsPrec p (UnsafeSChar c) diff --git a/libraries/base/GHC/TypeNats.hs b/libraries/base/GHC/TypeNats.hs index 66361d66db..668df1e032 100644 --- a/libraries/base/GHC/TypeNats.hs +++ b/libraries/base/GHC/TypeNats.hs @@ -378,6 +378,14 @@ data KnownNatInstance (n :: Nat) where knownNatInstance :: SNat n -> KnownNatInstance n knownNatInstance sn = withKnownNat sn KnownNatInstance +-- | @since 4.19.0.0 +instance Eq (SNat n) where + _ == _ = True + +-- | @since 4.19.0.0 +instance Ord (SNat n) where + compare _ _ = EQ + -- | @since 4.18.0.0 instance Show (SNat n) where showsPrec p (UnsafeSNat n) diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index ed9be1093d..3e1a49bbb0 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -14,6 +14,8 @@ * Add `Data.Functor.unzip` ([CLC proposal #88](https://github.com/haskell/core-libraries-committee/issues/88)) * Implement more members of `instance Foldable (Compose f g)` explicitly. ([CLC proposal #57](https://github.com/haskell/core-libraries-committee/issues/57)) + * Add `Eq` and `Ord` instances for `SSymbol`, `SChar`, and `SNat`. + ([CLC proposal #148](https://github.com/haskell/core-libraries-committee/issues/148)) ## 4.18.0.0 *TBA* |