[Haskell-cafe] Problem with JHC
Thomas DuBuisson
thomas.dubuisson at gmail.com
Wed Nov 11 17:50:21 EST 2009
Like paolino, I did a couple tests and found:
> data TreeX = Leaf Int | NotLeaf Int deriving (Show, Read)
[tommd at Mavlo Test]$ ./jtree
Give me a tree:
Leaf 5
jtree_code.c:2572: case fell off
Aborted
[tommd at Mavlo Test]$ ./jtree
Give me a tree:
NotLeaf
jtree_code.c:2572: case fell off
Aborted
So the read for that does not work... but surprisingly...
> data TreeX = Leaf Int | NotLeaf deriving (Show, Read)
Dropping the Int from the second constructor works (ignore the
constructor names, they are just place-holders).
[tommd at Mavlo Test]$ ./jtree
Give me a tree:
Leaf 43
Leaf 43
[tommd at Mavlo Test]$ ./jtree
Give me a tree:
NotLeaf
NotLeaf
--- OTHER TESTS ---
1) data TreeX = Leaf | NotLeaf 5 deriving (Show, Read)
Another unfortunate bug is that reversing the constructors (having
Leaf as a nullary constructor and NotLeaf taking an Int) causes
compilation to fail (using jhc-0.7.2-0).
2) data TreeX = Leaf Int | NotLeaf Int | OoopsLeaf deriving (Show, Read)
Works fine - notice it ends with a nullary constructor...
Hypothesis 1: All working Read derivations have data declarations with
a nullary constructor at the end.
3) data TreeX = Leaf Int | NotLeaf | OoopsLeaf Int deriving (Show, Read)
Fails in with 'case fell off', so H1 seems good
4) data TreeX = Leaf Int | NotLeaf | OoopsLeaf deriving (Show, Read)
Works.
5) data TreeX = Leaf | NotLeaf | OoopsLeaf Int deriving (Show, Read)
Fails to compile. Hypothesis 2: All working Read derivations that
don't cause compile issues have data declarations with non-nullary
first constructors.
Cheers,
Thomas
More information about the Haskell-Cafe
mailing list