bb7486159e459dc6e19318f892a5b619faf2359a
[ghc-hetmet.git] / ghc / tests / deriving / should_run / drvrun003.hs
1 -- !!! Deriving Show/Read for nullary constructors.
2 module Main(main) where
3
4 data A = B | C deriving ( Show, Read )
5
6 data Opt = N | Y A deriving (Show, Read)
7
8 x = Y B
9
10 {-
11  If the Haskell report's specification of how Show instances
12  are to be derived is followed to the letter, the code for
13  a nullary constructor would put parens around the constructor
14  when (showsPrec 10) is used. This would cause
15
16       Y A
17
18  to be showed as
19  
20       Y (A)
21
22  Overkill, so ghc's derived Show code treats nullary
23  constructors specially.
24 -}
25
26 main = do
27   print x
28   print ((read (show x))::Opt)
29   print ((read "Y (B)")::Opt)
30