[Haskell-cafe] Why isn't pattern matching lazy by default?

Felipe Almeida Lessa felipe.lessa at gmail.com
Wed Sep 19 06:49:06 EDT 2007


On 9/19/07, Peter Verswyvelen <bf3 at telenet.be> wrote:
>  Now why isn't pattern matching lazy by default?  This seems odd for a
> newbie since everything else is lazy by default.

AFAIK, pattern matches are desugared to cases, so

f (x:xs) = rhs
f []     = rhs'

is equivalent to

f y = case y of
    (x:xs) -> rhs
    []     -> rhs'

Case's have to be strict because that's how we look inside the values
in Haskell =). Of course I may be somehow mistaken here, as I am
learning Haskell, too.

-- 
Felipe.


More information about the Haskell-Cafe mailing list