[Haskell-cafe] Haskell Style - Pattern Matching with case vs. function declarations

Tom.Amundsen tomamundsen at gmail.com
Wed Mar 18 13:49:54 EDT 2009

Hi All,

I am new to Haskell. I just started reading "Real World Haskell" a few days
ago, so I apologize for being such a noob.

But, I am curious why I see a lot of code where people do pattern matching
via multiple function declarations instead of using the case ... of ...
construct? For example:

foldl' _    zero []     = zero
foldl' step zero (x:xs) =
      let new = step zero x
      in  new `seq` foldl' step new xs

instead of this, which I prefer:

foldl' f acc xs = case xs of
                            [] -> acc
                            (x:xs) -> let new = f acc x
                                          in  new `seq` foldl' f new xs
View this message in context: http://www.nabble.com/Haskell-Style---Pattern-Matching-with-case-vs.-function-declarations-tp22584765p22584765.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list