[Haskell-beginners] How to avoid evaluating the second (undefined) argument of a Boolean AND operation?

Felipe Almeida Lessa felipe.lessa at gmail.com
Thu Jun 23 01:21:55 CEST 2011

On Wed, Jun 22, 2011 at 8:07 PM, Jack Henahan <jhenahan at uvm.edu> wrote:
> Use
>    myAND F _ = F
> instead of using x.

Actually that doesn't change anything and both definitions are the
same thing.  The problem here is that "type checking is not lazy" =).
The second argument of myAND in "myAND F (1/0)" isn't being evaluated
at all; actually your code isn't running at all.  What is being
reported is a type error, not a runtime error.  Try one of these

  myAND F undefined
  myAND F (error "foo")
  myAND F (let x = x in x)
  myAND F (unsafePerformIO $ launchMissiles)

Cheers! =)


More information about the Beginners mailing list