Hal Daume III wondered:
> f x = f' 0 x
>     where f' acc [] = acc
>           f acc (x:xs) = f' (x+acc) xs

> why are we allowed to rebind f in the where clause?  
this is clearly a
> typo (in this instance) but it seems really strange to 
me that this would
> be allowed.

Because this definition is equivalent to

f x = let f' acc [] = acc
          f acc (x:xs) = f' (x+acc) xs
      in f' 0 x

More generally (if I am not mistaken...)

g p1 q1 ... | c1 = ...
            | c2 = ...
            | ....
   where <bindings>

is the same as

g p1 q1 ... = let <bindings>
              in case () of
                    _ | c1 -> ...
                      | c2 -> ...

This message has been brought to you by the letter alpha and the number pi.


_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to