Are pattern guards obsolete?

mm schneegloeckchen at
Sun Dec 10 19:06:19 EST 2006


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
  fail = var1 + var2


> 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' :)


More information about the Haskell-prime mailing list