Skip to content

deriving Read leads to "no parse"

The program

------ Start Offending Program -----
module Main
where

data T = C (Maybe Int) Int
       deriving (Show, Read, Eq)

main = 
  do
    let v = C Nothing 1
    print v
    print $ read (show v) == v
------ End Offending Program -----

leads to

AttitudeAdjuster chak 5 (~/haskell): ghc Main.hs
AttitudeAdjuster chak 6 (~/haskell): ./a.out 
C Nothing 1

Fail: Prelude.read: no parse
AttitudeAdjuster chak 7 (~/haskell): 

Experimentation suggests that it is the `Maybe' type
appearing in the type for which Read is derived that
causes the problem.  This problem does *not* occur with
GHC 5.04; ie, has been introduced with patchlevel 1. 
(I am not sure whether it is a problem in the Prelude
or the deriving mechanism.)

This bug is pretty serious for me, as it utterly breaks
C->Haskell.

/me waits for GHC 5.04.2...
Trac metadata
Trac field Value
Version 5.04.1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution ResolvedFixed
Component Compiler
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