[Git][ghc/ghc][master] Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Mar 28 12:12:29 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
76bb4c58 by Ryan Scott at 2023-03-28T08:12:08-04:00
Add COMPLETE pragmas to TypeRep, SSymbol, SChar, and SNat

This implements
[CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149).

- - - - -


6 changed files:

- libraries/base/Data/Typeable/Internal.hs
- libraries/base/GHC/TypeLits.hs
- libraries/base/GHC/TypeNats.hs
- libraries/base/changelog.md
- + libraries/base/tests/CLC149.hs
- libraries/base/tests/all.T


Changes:

=====================================
libraries/base/Data/Typeable/Internal.hs
=====================================
@@ -272,6 +272,7 @@ typeableInstance rep = withTypeable rep TypeableInstance
 pattern TypeRep :: forall {k :: Type} (a :: k). () => Typeable @k a => TypeRep @k a
 pattern TypeRep <- (typeableInstance -> TypeableInstance)
   where TypeRep = typeRep
+{-# COMPLETE TypeRep #-}
 
 {- Note [TypeRep fingerprints]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~


=====================================
libraries/base/GHC/TypeLits.hs
=====================================
@@ -363,6 +363,7 @@ newtype SSymbol (s :: Symbol) = UnsafeSSymbol String
 pattern SSymbol :: forall s. () => KnownSymbol s => SSymbol s
 pattern SSymbol <- (knownSymbolInstance -> KnownSymbolInstance)
   where SSymbol = symbolSing
+{-# COMPLETE SSymbol #-}
 
 -- An internal data type that is only used for defining the SSymbol pattern
 -- synonym.
@@ -464,6 +465,7 @@ newtype SChar (s :: Char) = UnsafeSChar Char
 pattern SChar :: forall c. () => KnownChar c => SChar c
 pattern SChar <- (knownCharInstance -> KnownCharInstance)
   where SChar = charSing
+{-# COMPLETE SChar #-}
 
 -- An internal data type that is only used for defining the SChar pattern
 -- synonym.


=====================================
libraries/base/GHC/TypeNats.hs
=====================================
@@ -367,6 +367,7 @@ newtype SNat (n :: Nat) = UnsafeSNat Natural
 pattern SNat :: forall n. () => KnownNat n => SNat n
 pattern SNat <- (knownNatInstance -> KnownNatInstance)
   where SNat = natSing
+{-# COMPLETE SNat #-}
 
 -- An internal data type that is only used for defining the SNat pattern
 -- synonym.


=====================================
libraries/base/changelog.md
=====================================
@@ -16,6 +16,8 @@
       ([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))
+  * Add `COMPLETE` pragmas to the `TypeRep`, `SSymbol`, `SChar`, and `SNat` pattern synonyms.
+      ([CLC proposal #149](https://github.com/haskell/core-libraries-committee/issues/149))
 
 ## 4.18.0.0 *TBA*
   * Shipped with GHC 9.6.1


=====================================
libraries/base/tests/CLC149.hs
=====================================
@@ -0,0 +1,23 @@
+-- Test the COMPLETE pragmas for SChar, SNat, SSymbol, and TypeRep.
+{-# OPTIONS_GHC -Wincomplete-patterns #-}
+module CLC149 where
+
+import Data.Kind
+import GHC.TypeLits
+import Type.Reflection
+
+type Dict :: Constraint -> Type
+data Dict c where
+  Dict :: c => Dict c
+
+sc :: SChar c -> Dict (KnownChar c)
+sc SChar = Dict
+
+sn :: SNat n -> Dict (KnownNat n)
+sn SNat = Dict
+
+ss :: SSymbol s -> Dict (KnownSymbol s)
+ss SSymbol = Dict
+
+tr :: TypeRep a -> Dict (Typeable a)
+tr TypeRep = Dict


=====================================
libraries/base/tests/all.T
=====================================
@@ -296,3 +296,4 @@ test('T22816', normal, compile_and_run, [''])
 test('trace', normal, compile_and_run, [''])
 test('listThreads', js_broken(22261), compile_and_run, [''])
 test('inits1tails1', normal, compile_and_run, [''])
+test('CLC149', normal, compile, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76bb4c586084d7fdcf0e5ce52623abbfca527c55

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/76bb4c586084d7fdcf0e5ce52623abbfca527c55
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230328/53217a9a/attachment-0001.html>


More information about the ghc-commits mailing list