3 ms·
You did say that only Lisp implements "if" as a function, but I thought I'd share that in Haskell "if" is syntactic sugar for a case expression. That is: if
by tomjakubowski 14y ago
You did say that only Lisp implements "if" as a function, but I thought I'd share that in Haskell "if" is syntactic sugar for a case expression. That is:
if x then y else z
is sugar for:
case x of
True -> y
False -> z
There have been suggestions to replace this sugaring with a proper "if" function, e.g.:
if :: Bool -> a -> a -> a
if True x _ = x
if False _ y = y
to remove arguably redundant syntax, but it seems unlikely that this change would happen. See more here: http://www.haskell.org/haskellwiki/If-then-else http://www.haskell.org/haskellwiki/If-then-else