Skip to content

Standalone deriving Show at GHCi prompt causes divergence when printing

Deriving a show instance for a data type (defined either with the standard Haskell 98 syntax or with GADT syntax) within GHCi using the command:

instance Show <typename>

causes divergence/stack overflow when printing values of that type. The issue does not manifest itself when you use the standard deriving mechanism within a Haskell source file.

Minimum example necessary to replicate:

module Main (
  main
)
where

  -- At GHCi prompt type
  --   instance Show Bool'
  -- then
  --   True'
  -- to get a stack overflow
  data Bool'
    = True'
    | False'

  main = return ()
Trac metadata
Trac field Value
Version 7.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information