Skip to content

GHCi support for type/data families should match that of related features

Currently, GHCi queries are not as helpful with type and data families as they are with type synonyms or class instances. Consider this module:

{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}

type family TF a
type instance TF Bool = Char
type instance TF Int  = Bool

data family DF a
data instance DF Bool = DFC Char
data instance DF Int  = DFB Bool

class FD a b | a -> b
instance FD Bool Char
instance FD Int  Bool

type TS a = (a,a)

and compare the output of :info for these items:

*Main> :i TS
type TS a = (a, a)
        -- Defined at C:\Users\claus\Desktop\tmp\fd-tf\tf-df-info.hs:17:5-6
*Main> :i TF
type family TF a :: *
        -- Defined at C:\Users\claus\Desktop\tmp\fd-tf\tf-df-info.hs:5:12-13
*Main> :i FD
class FD a b | a -> b
        -- Defined at C:\Users\claus\Desktop\tmp\fd-tf\tf-df-info.hs:13:6-7
instance FD Bool Char
  -- Defined at C:\Users\claus\Desktop\tmp\fd-tf\tf-df-info.hs:14:9-20
instance FD Int Bool
  -- Defined at C:\Users\claus\Desktop\tmp\fd-tf\tf-df-info.hs:15:9-20
*Main> :i DF
data family DF a
        -- Defined at C:\Users\claus\Desktop\tmp\fd-tf\tf-df-info.hs:9:12-13

Neither the type family definition nor the data family instances are listed. If we try :browse instead

*Main> :browse
type family TF a :: *
data family DF a
data instance Main.R:DFBool Bool = DFC Char
data instance Main.R:DFInt Int = DFB Bool
class FD a b | a -> b
type TS a = (a, a)

we get some form of info about the data family instances, though no instances are listed for the plain old class, and the data family instance info shows internal encoding details.

Trac metadata
Trac field Value
Version 6.12.3
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