Add context to output of GHCi :doc command
Currently the GHCi :doc
command simply prints the haddocks for all objects matching the argument string. This means that there is no indication of which object a given block of text belongs to when multiple results are printed.
As was briefly discussed in !4562 (closed), it would be useful to include some additional output showing what the object is and where it is defined. For example,
-- | haddock for type con
newtype Foo =
-- | haddock for data con
Foo
{ bar :: Int -- ^ haddock for field
}
>>> :doc Foo
-- defined at Docs.hs:7:3
pattern Foo :: Int -> Foo
haddock for data con
-- defined at Docs.hs:5:1
data Foo :: Type
haddock for type con
Note the additional output clearly identifying the subject of each doc.