Skip to content

Bizarre pretty-printing of closed type families in GHCi

Load this code:

{-# LANGUAGE TypeFamilies #-}
module Bug where

type family F a where
  F [Int] = Bool
  F [a]   = Double
  F (a b) = Char

into GHCi 8.0.1, 8.0.2, or HEAD, and run :i F. You'll see this:

$ /opt/ghc/8.0.2/bin/ghci Bug.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Ok, modules loaded: Bug.
λ> :i F
type family F a :: *
  where
      F [Int] = Bool
    [a] F [a] = Double
    [b, (a :: * -> *)] F (a b) = Char
        -- Defined at Bug.hs:4:1

Compare this with GHCi 7.10.3, where the pretty-printing is far more sane:

$ /opt/ghc/7.10.3/bin/ghci Bug.hs
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
Ok, modules loaded: Bug.
λ> :i F
type family F a :: * where
    F [Int] = Bool
    F [a] = Double
    F (a b) = Char
        -- Defined at Bug.hs:4:1
Trac metadata
Trac field Value
Version 8.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
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