
10 Dec
2006
10 Dec
'06
7:06 p.m.
Hello, recently I read about pattern guards which are a candidate for Haskell'. As I understand them, their purpose is to provide an easier way to write functions like (taken from the wiki, it does not run): clunky env var1 var1 = case lookup env var1 of Nothing -> fail Just val1 -> case lookup env var2 of Nothing -> fail Just val2 -> val1 + val2 where fail = var1 + var2 Wouldn't
clunky :: Num a => [(a, a)] -> a -> a -> a clunky env var1 var2 = case (lookup var1 env, lookup var2 env) of (Just v1, Just v2) -> v1 + v2 _ -> var1 + var2
be simple enough to make a syntax change superflous? It is so simple, that there is no need for `fail` in Haskell or Haskell' :) schneegloeckchen