summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2022-12-05 18:58:34 +0100
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2022-12-05 19:04:36 +0100
commit85aad2c8d82ecc392f0b6025039192923f20b248 (patch)
tree6e6dca0654752487c98104590d04af84cd6e1c48
parentd82992fd4b62a81607af1667e4ff755d58af291f (diff)
downloadhaskell-wip/typeable-list.tar.gz
Restore show (typeRep @[]) == "[]"wip/typeable-list
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: []