[Haskell-beginners] Errors and the compiler

Christopher Howard christopher.howard at frigidcode.com
Thu Oct 11 22:48:56 CEST 2012

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:

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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121011/76e2eb12/attachment.pgp>

More information about the Beginners mailing list