:type-at and :all-types show types for non-expressions in deriving and instances
Summary
:all-types
:type-at
show types for X in data ... deriving (X)
and instance X where ...
. They al
Steps to reproduce
Save this file:
module Ghost where
data X = A | B
deriving (Show)
instance Eq X where
A == A = True
B == B = True
_ == _ = False
And in GHCi:
ghci> :set +c
ghci> :l ghost.hs
[1 of 1] Compiling Ghost ( ghost.hs, interpreted ) [flags changed]
Ok, one module loaded.
Collecting type info for 1 module(s) ...
ghci> :all-types
ghost.hs:(4,15)-(4,19): GHC.Types.Int -> Ghost.X -> GHC.Show.ShowS
ghost.hs:(7,7)-(7,9): Ghost.X -> Ghost.X -> GHC.Types.Bool
ghost.hs:(4,15)-(4,19): GHC.Show.Show Ghost.X
ghost.hs:(4,15)-(4,19): ([Ghost.X] -> GHC.Show.ShowS) -> GHC.Show.Show Ghost.X
... (many more lines for the same range (4,15)-(4,19))
ghost.hs:(6,10)-(6,14): GHC.Classes.Eq Ghost.X
ghost.hs:(6,10)-(6,14): (Ghost.X -> Ghost.X -> GHC.Types.Bool) -> GHC.Classes.Eq Ghost.X
... (many more lines for the same range (6,10)-(6,14))
ghost.hs:(7,14)-(7,18): GHC.Types.Bool
ghost.hs:(8,14)-(8,18): GHC.Types.Bool
... (many other 'correct' types)
-- data X = A | B
-- deriving (Show)
-- ^^^^
ghci> :type-at ghost.hs 4 15 4 19
:: [X] -> ShowS
-- instance Eq X where
-- ^^^^
ghci> :type-at ghost.hs 6 10 6 14
:: X -> X -> Bool
Expected behavior
Show
in deriving (Show)
and Eq X
in instance Eq X where
should not show up in :all-types
and should not be accepted by :type-at
.
Environment
- GHC version used: 8.6.4
Optional:
- Operating System: Linux
- System Architecture: x86-64