[Haskell-cafe] \_ -> not equivalent to const $

Felipe Lessa felipe.lessa at gmail.com
Thu Jan 10 18:11:46 EST 2008

On Jan 10, 2008 8:54 PM, Luke Palmer <lrpalmer at gmail.com> wrote:
> Can someone explain what the heck is going on here?

AFAICT, nothing is wrong. You see, both returned the very same values.
What you saw was in fact the problem with unsafePerformIO and friends,
as they may be executed lots of times *or not*. The compiler is free
to behave in those two ways for the code with const or with the
lambda. But referential transparency wasn't broken at all =).

It seems const retained the value, while the lambda didn't. An
optimization might transform one into the other if the compiler sees


More information about the Haskell-Cafe mailing list