[Git][ghc/ghc][master] Restore show (typeRep @[]) == "[]"

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Dec 8 13:33:54 UTC 2022



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


Commits:
7658cdd4 by Krzysztof Gogolewski at 2022-12-08T08:33:36-05:00
Restore show (typeRep @[]) == "[]"

The Show instance for TypeRep [] has changed in 9.5 to output "List"
because the name of the type constructor changed.
This seems to be accidental and is inconsistent with TypeReps of saturated
lists, which are printed as e.g. "[Int]".
For now, I'm restoring the old behavior; in the future,
maybe we should show TypeReps without puns (List, Tuple, Type).

- - - - -


3 changed files:

- libraries/base/Data/Typeable/Internal.hs
- testsuite/tests/typecheck/should_run/TestTypeableBinary.hs
- testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout


Changes:

=====================================
libraries/base/Data/Typeable/Internal.hs
=====================================
@@ -836,6 +836,8 @@ instance Show (TypeRep (a :: k)) where
 showTypeable :: Int -> TypeRep (a :: k) -> ShowS
 showTypeable _ TrType = showChar '*'
 showTypeable _ rep
+  | isListTyCon tc, [] <- tys =
+    showString "[]"
   | isListTyCon tc, [ty] <- tys =
     showChar '[' . shows ty . showChar ']'
 


=====================================
testsuite/tests/typecheck/should_run/TestTypeableBinary.hs
=====================================
@@ -35,3 +35,4 @@ main = do
     testRoundtrip (typeRep :: TypeRep 5)
     testRoundtrip (typeRep :: TypeRep "hello world")
     testRoundtrip (typeRep :: TypeRep ('Just 5))
+    testRoundtrip (typeRep :: TypeRep [])


=====================================
testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout
=====================================
@@ -13,3 +13,4 @@ good: Int -> Int
 good: 5
 good: "hello world"
 good: 'Just Natural 5
+good: []



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7658cdd47198512b699492688f51fc8682d194cd

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7658cdd47198512b699492688f51fc8682d194cd
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/20221208/e3d3f33a/attachment-0001.html>


More information about the ghc-commits mailing list