[EMAIL PROTECTED] reports the following problem.
Version: Hugs 1.4June 1998, Hugs 981111 BETA
OS: SunOS Release 5.6 Version Generic_105181-08
compiler: gcc version 2.7.2.3
configuration:
Expected behaviour:
Output:
"Options{s=SpecialOptions{test=42}}" or something similar
NOTES:
I didn't find it on the known bugs list, excuse if I
was missing something.
The problem seems to be the show function or show and
read does not go well together. This problem appears
if you have nested data structures.
In this case the show function produces
Options{s=SpecialOptions{test=42}}
which can't be parsed by read. The show function of
ghc produces
Options{s=(SpecialOptions{test=42})}
This can be read again also with hugs.
Observed behaviour:
Output:
Program error: PreludeText.read: no parse
Transcript:
Prelude> :l test
Reading file "test.hs":
Hugs session for:
/public/languages/hugs-981111-beta/share/hugs/lib/Prelude.hs
test.hs
Main> main
Program error: PreludeText.read: no parse
Code:
initOptions = Options { s = initSpecialOptions }
saveOptions :: Options -> IO ()
saveOptions opt
= writeFile "default.opt" (show opt)
loadOptions :: IO Options
loadOptions
= do optfile <- readFile "default.opt"
let opt = read optfile
return opt
main = do saveOptions initOptions
o2 <- loadOptions
print o2