[jhc] "case fell off" for trivial program

Mario Alvarez Picallo mario.alvarez739 at gmail.com
Tue May 19 21:41:59 UTC 2015


You can find a patched version of the compiler at
http://github.com/m-alvarez/jhc (as long as you don't mind using an
experimental branch of jhc), but I'm not sure how to go about merging this
patch into the official repository. We could try telling John directly, but
if he's not paying attention to the mailing list my guess is he's too busy
to worry much about JHC.

I'm pretty sure the optimization could be made safe, although I'm not sure
how easily, and right now I don't have the time or energy to devote to
that. If anyone else volunteers, I'll be glad to accept pull requests to
the github repo.

Cheers!

On Tue, May 19, 2015 at 10:24 PM, Travis Athougies <travis at athougies.net>
wrote:

> 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
>



-- 
Now I do not know whether I was then a lambda expression emulating a Turing
machine, or whether I am a Turing machine emulating a lambda expression.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/jhc/attachments/20150519/404eff4a/attachment.html>


More information about the jhc mailing list