Skip to content
Snippets Groups Projects
Commit 43f20ce4 authored by sof's avatar sof
Browse files

[project @ 1999-02-06 16:00:43 by sof]

Added two new (read.show) regression tests for derived Read&Show instances.
parent 690185e0
No related merge requests found
-- !!! Deriving Show/Read for type with labelled fields.
-- (based on a Hugs bug report.)
module Main(main) where
data Options =
Options { s :: OptionKind }
deriving (Show, Read)
data OptionKind =
SpecialOptions { test :: Int }
deriving (Show, Read)
x = Options{s=SpecialOptions{test=42}}
main = do
print x
print ((read (show x))::Options)
Options{s=(SpecialOptions{test=42})}
Options{s=(SpecialOptions{test=42})}
-- !!! Deriving Show/Read for nullary constructors.
module Main(main) where
data A = B | C deriving ( Show, Read )
data Opt = N | Y A deriving (Show, Read)
x = Y B
{-
If the Haskell report's specification of how Show instances
are to be derived is followed to the letter, the code for
a nullary constructor would put parens around the constructor
when (showsPrec 10) is used. This would cause
Y A
to be showed as
Y (A)
Overkill, so ghc's derived Show code treats nullary
constructors specially.
-}
main = do
print x
print ((read (show x))::Opt)
print ((read "Y (B)")::Opt)
Y B
Y B
Y B
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment