[Haskell-cafe] Why does Haskell have the if-then-else syntax?

Sebastian Sylvan sylvan at student.chalmers.se
Wed Jul 26 21:44:54 EDT 2006


On 7/27/06, mvanier <mvanier at cs.caltech.edu> wrote:
> As opposed to what?

For example case-of, guards (in combination with let or where), or
just a function:

if :: Bool -> a -> a -> a
if True t _ = t
if False _ e = e

-- example usage
myAbs x = if (x < 0) (negate x) x


/S
-- 
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862


More information about the Haskell-Cafe mailing list