GHCi shows no output for expression of type `IO A` if `A` has no Show instance
Summary
I'm not sure if this is a bug or intended behavior, but it was pretty confusing to me when I encountered it. I was running an IO action that produces a list, so when I saw empty output in GHCi, it took me a while to realize that what I'm seeing is not an empty list, but no output at all.
GHCi has worked this way since at least 8.4.4.
Steps to reproduce
in GHCi:
ghci> data A = MkA
ghci> return MkA -- no output!
ghci> :set -XStandaloneDeriving
ghci> deriving instance Show A
ghci> return MkA -- now we do get an output
MkA
Expected behavior
I expected to see
<interactive>:3:1: error:
• No instance for (Show A) arising from a use of ‘print’
• In a stmt of an interactive GHCi command: print it
Environment
- GHC version used: 9.4.2
Optional:
- Operating System: Ubuntu on WSL2 on Windows 11
- System Architecture: x86_64