[Haskell-beginners] if ands
jfredett at gmail.com
Thu Nov 5 21:09:13 EST 2009
No, consider the definition of (&&)
-- I hope this is the def from the prelude. If it's not, then it's
(&&) :: Bool -> Bool -> Bool
True && x = x
False && _ = False
Since (&&) ignores it's second argument if the first is false, then it
will "Short circuit" (like most `&` operators in other languages) due
to lazy evaluation.
On Nov 5, 2009, at 9:05 PM, Nathan M. Holden wrote:
> If you have an if statement like
> if (a&&b) then fun else fun'
> and a is false, does GHC actually bother to check b?
> Beginners mailing list
> Beginners at haskell.org
More information about the Beginners