>> Actually, GHC does finally discard type information right at the
>> end, so we could do an extra bit of CSE there, but frankly I doubt
>> it would buy very much.  But I'm willing to stand corrected.
>
>I don't think you can say this. Granted in this trivial example
>we are only talking about wasting constructor record per
>'demo expression'. But in other more complex examples we could be
>talking several. Also the total heap space that gets wasted this way
>is not an intrinsic property of the demo function. It depends on
>the number of 'demo expressions' (or similar) which get reduced.
>I don't think you can predict how many this will be with any generality.
>In some programs it could conceivably be huge Nos. Couldn't it?.
>It would be nice to re-use the existing constructors, even if the
>type checker says thats illegal.


I'm experiencing a little bout of deja vu here, so excuse me if it turns out
that I'm repeating myself.  (I could swear I already posted this, but it's
not in my "Messages Sent" folder...)

With regard to merging Either instances, I agree with Simon that for most
programs this will not buy you much, but there are two common kinds of
programs where one could expect a significant effect on performance, just
because of sheer scale.  The first is any program which uses an
error/exception monad on a program-wide scale.  The second is a program that
uses Chalmers' fudgets library since, as I recall, the type Either plays a
prominent role in the "messaging" system.

--FC



Reply via email to