summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2022-12-05 18:58:34 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-08 08:33:36 -0500
commit7658cdd47198512b699492688f51fc8682d194cd (patch)
tree90712444d737b5d892578619f4c2db485c9bc411
parent9ec76f61c880539114314fc3e4f96a4694f38ebe (diff)
downloadhaskell-7658cdd47198512b699492688f51fc8682d194cd.tar.gz
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).
-rw-r--r--libraries/base/Data/Typeable/Internal.hs2
-rw-r--r--testsuite/tests/typecheck/should_run/TestTypeableBinary.hs1
-rw-r--r--testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout1
3 files changed, 4 insertions, 0 deletions
diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs
index 209324d585..51ee0f745e 100644
--- a/libraries/base/Data/Typeable/Internal.hs
+++ b/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 ']'
diff --git a/testsuite/tests/typecheck/should_run/TestTypeableBinary.hs b/testsuite/tests/typecheck/should_run/TestTypeableBinary.hs
index e427c13725..e09893d169 100644
--- a/testsuite/tests/typecheck/should_run/TestTypeableBinary.hs
+++ b/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 [])
diff --git a/testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout b/testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout
index 6ef72dfb83..159367efd8 100644
--- a/testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout
+++ b/testsuite/tests/typecheck/should_run/TestTypeableBinary.stdout
@@ -13,3 +13,4 @@ good: Int -> Int
good: 5
good: "hello world"
good: 'Just Natural 5
+good: []