As for optimality issues, a naive compiler would wastefully examine the tag twice in the else clause of:
if isNothing mExp
then expr
else f (fromJust mExp)
-- Kim-Ee
On Fri, Oct 12, 2012 at 3:48 AM, Christopher Howard
<christopher.howard@frigidcode.com> wrote:
Point of curiosity: Does an error in a Haskell program have a negative
impact on the compilers reasoning about or optimization of the code,
even if said error is never reached in the control flow? For example,
both of the following would have the same result:
code:
--------
case mExp of
Nothing -> expr
Just x -> f x
-- or...
if isNothing mExp
then expr
else f (fromJust mExp)
--------
In my naive reasoning, I would think that in the latter case the use of
fromJust introduces, from the compilers perspective, an additional
possible outcome (an error being thrown). This presumably would
complicate the compilers reasoning about the code, unless of course the
compiler is smart enough to figure out that the error will never be reached.
--
frigidcode.com
indicium.us
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners