[jhc] "case fell off" for trivial program

Travis Athougies travis at athougies.net
Tue May 19 21:24:14 UTC 2015


disclaimer: I found this e-mail thread through the jhc archives while I was
not subscribed to jhc@ because I was having the same problems as Mario and
Herbert. I subscribed afterwards, so I could join in on the discussion. I'm
not sure how this will affect the mailing list's thread handling.

I am having the same problem with JHC, and like Mario says, it's due to a
pre-mature optimization.

Basically, when JHC encounters a type where only one constructor has
arguments, it erroneously thinks that it can store it as untagged. This is
true only for types with two constructors, but not for types with more than
two. I have the feeling this was written as a quick way to optimize list
storage without realizing that the optimization would break types with more
than two constructors.

The optimization works for types with two constructors because JHC
specifically handles the case of scrutinizing a two-constructor type when
it generates C.

Anyway, this can be fixed by disabling this optimization for types with
more than two constructors.

Change the line

    tyRep k tyty | Just xs <- tySiblings tyty, all triv [ x | x <- xs, x /=
k] = Just TyRepUntagged where

to

    tyRep k tyty | Just xs <- tySiblings tyty, length xs < 3 && all triv [
x | x <- xs, x /= k] = Just TyRepUntagged where

Any ideas on how to get this bug changed in the official version?

Travis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/jhc/attachments/20150519/76a401fa/attachment.html>


More information about the jhc mailing list