Commit 65b810bd authored by Ryan Scott's avatar Ryan Scott Committed by Ben Gamari

Show TYPE 'Lifted/TYPE 'Unlifted as */# in Show TypeRep instance

Kind equalities changed how `*`/`#` are represented internally, which
means that showing a `TypeRep` that contains either of those kinds
produces a rather gross-looking result, e.g.,

```
> typeOf (Proxy :: Proxy 'Just)
Proxy (TYPE 'Lifted -> Maybe (TYPE 'Lifted)) 'Just
```

We can at least special-case the `Show` instance for `TypeRep` so that
it prints `*` to represent `TYPE 'Lifted` and `#` to represent `TYPE
'Unlifted`.

Addresses one of the issues uncovered in #11334.

Test Plan: ./validate

Reviewers: simonpj, hvr, austin, goldfire, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1757

GHC Trac Issues: #11334
parent b3eb8fad
......@@ -357,7 +357,10 @@ instance Show TypeRep where
showsPrec p (TypeRep _ tycon kinds tys) =
case tys of
[] -> showsPrec p tycon
[x] | tycon == tcList -> showChar '[' . shows x . showChar ']'
[x@(TypeRep _ argCon _ _)]
| tycon == tcList -> showChar '[' . shows x . showChar ']'
| tycon == tcTYPE && argCon == tc'Lifted -> showChar '*'
| tycon == tcTYPE && argCon == tc'Unlifted -> showChar '#'
[a,r] | tycon == tcFun -> showParen (p > 8) $
showsPrec 9 a .
showString " -> " .
......
{-# LANGUAGE DataKinds #-}
module Main (main) where
import Data.Typeable
import GHC.Types
main :: IO ()
main = do
print (typeOf (Proxy :: Proxy 'Just))
print (typeOf (Proxy :: Proxy (TYPE 'Lifted)))
print (typeOf (Proxy :: Proxy (TYPE 'Unlifted)))
Proxy (* -> Maybe *) 'Just
Proxy * *
Proxy * #
......@@ -210,4 +210,5 @@ test('T9848',
, only_ways(['normal'])],
compile_and_run,
['-O'])
test('T10149',normal, compile_and_run,[''])
test('T10149', normal, compile_and_run, [''])
test('T11334', normal, compile_and_run, [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment