Dictionaries without dynamic superclasses do not get IPE source information
Consider:
{-# LANGUAGE AllowAmbiguousTypes #-}
module Main where
import GHC.InfoProv
import Unsafe.Coerce
-- Boilerplate to help us access the literal dictionaries
data Dict c where
Dict :: forall c. c => Dict c
data Box where
Box :: forall a. a -> Box
mkBox :: forall a. a => Box
mkBox = unsafeCoerce (Dict @a)
-- Interesting bit
data A = A
data B a = B a
-- Will not get IPE
instance Show A where
show = undefined
-- Will get IPE
instance Show a => Show (B a) where
show = undefined
main :: IO ()
main = do
(\(Box d) -> print =<< whereFrom d) $ mkBox @(Show A)
(\(Box d) -> print =<< whereFrom d) $ mkBox @(Show (B A))
The Show A
dictionary does not get a source location in its IPE data, but the Show (B a)
dictionary does. This is because in GHC.Stg.Debug
, when debug information is collected, StgRhsCon
s are not given initial estimates for source locations based on their Name
, but StgRhsClosure
s are.