Skip to content

Non-ASCII type names get garbled when their `TypeRep` is shown

Typeable allows easily showing the name of a type by, well, using show on it. However, this does not work right for types with Unicode symbols in their name:

GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
Prelude> :m +Data.Typeable
Prelude Data.Typeable> data W = W
Prelude Data.Typeable> typeOf W
W
Prelude Data.Typeable> data Ω = Ω
Prelude Data.Typeable> typeOf Ω
Ω

This did not yet happen in GHC-7:

GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
Prelude> :m +Data.Typeable
Prelude Data.Typeable> data W = W
Prelude Data.Typeable> typeOf W
W
Prelude Data.Typeable> data Ω = Ω
Prelude Data.Typeable> typeOf Ω
Ω

N.b.:

Prelude> import Data.ByteString.Char8 as BC8
Prelude BC8> BC8.putStrLn $ pack "Ω"
Ω

So, this appears to be a UTF-8 problem – something interprets bytestring-stored type-representation names as a different character encoding.

Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information