[Haskell-cafe] Writing guards shorthand

Jules Bean jules at jellybean.co.uk
Thu Apr 19 09:19:13 EDT 2007


Joel Reymont wrote:
> This is what want. Notice the succinctness.
>

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


Yes, I appreciate what you want, and I know ocaml too :)

I was just talking around the other ways you can achieve it.  I don't 
know if there is a strong reason why haskell doesn't support an 
equivalent syntax. I'd guess something like:

f A = B = C = true
f D = E = F = false

or perhaps

f A = f B = f C = true
f D = f E = f F = false

Jules


More information about the Haskell-Cafe mailing list