[Haskell-cafe] Writing guards shorthand

Joel Reymont joelr1 at gmail.com
Thu Apr 19 09:14:51 EDT 2007


This is what want. Notice the succinctness.

         Objective Caml version 3.10+dev24 (2007-02-16)

# type foo = A | B | C | D | E | F
   ;;
type foo = A | B | C | D | E | F

# A;;
- : foo = A

# let infer = function | A | B | C -> true; | D | E | F -> false;;
val infer : foo -> bool = <fun>

# infer A;;
- : bool = true

# infer B;;
- : bool = true

# infer D;;
- : bool = false

# infer F;;
- : bool = false
#

--
http://wagerlabs.com/







More information about the Haskell-Cafe mailing list