[Haskell-cafe] Haskell guards

Victor Nazarov asviraspossible at gmail.com
Thu Sep 20 09:20:46 EDT 2007


I still can't remember how guards are treated in Haskell. Here is the
code snippet in question:

foo a | a == 1 = 6
foo a | a == 2 = 7
foo a = 8

Would Haskell fall through to the third alternative if a is not equal
to 1 or 2. I know that this can be rewritten more sanely, but I just
consider guard behavior. What would be the value of (foo 3)?

-- 
vir
http://vir.comtv.ru/


More information about the Haskell-Cafe mailing list