01 02 03 04 05 06 01 02 03 04 05 06 07 ← →
module Main where
We define add
to be a function that adds its arguments unless one of its
arguments is zero, in which case it returns zero. Here, we use an if
statement.
add ∷ Int → Int → Int add x y = if x == 0 || y == 0 then 0 else x + y main ∷ IO () main = do print $ add 0 1 print $ add 1 0 print $ add 1 1
0 0 2