GHCi uses the Show instance too eagerly

Hi, I’ve been noticing that recent GHCis don’t pretty print type signatures like they used to (pre - 9?).

λ> readIORef

<interactive>:125:1-9: error: [GHC-39999]
    • No instance for ‘Show (IORef a0 -> IO a0)’

The old behaviour (which I prefer) is to instead call the :t macro for you:

λ> :t readIORef
readIORef :: IORef a -> IO a

In the GHC Error Index, GHC-39999 is “No instance arising”.

It also tries to specialize type parameters to () when no better alternative is in scope, which is debatable but a different matter I guess.

e.g. with functions:

λ> M.lookup

<interactive>:127:1-8: error: [GHC-39999]
    • No instance for ‘Show (() -> M.Map () a0 -> Maybe a0)’

8.10 seems to be doing exactly the same for readIORef at least. Not sure it was ever smart enough to do what you say (interpret it as if you had :t): it’s a Haskell value and by default GHCi will try to print it… It may be a little surprising if it inserted :t on the fly I think, so I’m not sure it’s a good idea to add this feature.

2 Likes