Display the derived instances while hovering on type constructors and data constructors
Is your enhancement request related to a problem? Please describe.
No
Describe the solution you'd like
Display the derived instances while hovering on type constructors and data constructors.
For example, for data A = A deriving Show; a = A, it would be great to display it derived the Show while hovering over all As
Describe alternatives you've considered
Not sure if there is a better way to show these instances
Additional context
Is there a reason for only derived instances rather than all instances, like :instances
ghci> :instances Int
instance Foreign.Storable.Storable Int
-- Defined in `Foreign.Storable'
instance GHC.Bits.Bits Int -- Defined in `GHC.Bits'
instance GHC.Bits.FiniteBits Int -- Defined in `GHC.Bits'
instance Integral Int -- Defined in `GHC.Real'
instance GHC.Ix.Ix Int -- Defined in `GHC.Ix'
instance Num Int -- Defined in `GHC.Num'
instance Real Int -- Defined in `GHC.Real'
instance Bounded Int -- Defined in `GHC.Enum'
instance Enum Int -- Defined in `GHC.Enum'
instance Eq Int -- Defined in `GHC.Classes'
instance Ord Int -- Defined in `GHC.Classes'
instance Read Int -- Defined in `GHC.Read'
instance Show Int -- Defined in `GHC.Show'
Also, class constraints on local type variables?
Is there a reason for only derived instances rather than all instances, like :instances in GHCi?
When I said derived, it also includes these instances you mentioned.
Also, class constraints on local type variables?
Not sure about that, an example here?
Also, class constraints on local type variables?
Not sure about that, an example here?
Like a in these examples though I guess it isn't necessarily restricted to type variables
eg1 :: forall a . Show a => a -> String
eg1 = show @a
data Eg2 a where
MkEg2 :: Show a => Eg2 a
eg2 :: forall a . Eg2 a -> a -> String
eg2 MkEg2 = show @a
It has a lower priority in this thread I think, because of these variables are not far from the class name.
Showing all the instances might be a lot. Some types have a lot of instances. But perhaps that's fine, so long as it goes at the bottom or something, like in Haddock.
I took a look yesterday but didn't find an entrance about deriving info from typechecked source, glad to hear some hints.
I took a look yesterday but didn't find an entrance about deriving info from typechecked source, glad to hear some hints.
This might help, GHCi has a :instances <type> command
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/720
https://downloads.haskell.org/ghc/9.0.1/docs/html/libraries/ghc-9.0.1/GHC-Runtime-Eval.html#v:getInstancesForType