[Haskell-beginners] How to avoid evaluating the second (undefined) argument of a Boolean AND operation?
Jack Henahan
jhenahan at uvm.edu
Thu Jun 23 01:26:35 CEST 2011
You're right, of course. I totally spaced out while reading the error message. That'll teach me to reply to lists while on the phone. :/
On Jun 22, 2011, at 7:21 PM, Felipe Almeida Lessa wrote:
> 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
> instead:
>
> myAND F undefined
> myAND F (error "foo")
> myAND F (let x = x in x)
> myAND F (unsafePerformIO $ launchMissiles)
>
> Cheers! =)
>
> --
> Felipe.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 398E692F.asc
Type: application/x-apple-msg-attachment
Size: 24295 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110622/d6c16cef/attachment-0001.bin>
-------------- next part --------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 881 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110622/d6c16cef/attachment-0001.pgp>
More information about the Beginners
mailing list