why is this legal
Hal Daume III
hdaume@ISI.EDU
Fri, 1 Feb 2002 15:06:06 -0800 (PST)
then, why are we allowed to rebind f in a let clause :)
--
Hal Daume III
"Computer science is no more about computers | hdaume@isi.edu
than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
On Fri, 1 Feb 2002, David Feuer wrote:
> 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
> Haskell@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>