[Haskell-cafe] let and fixed point operator
andrewcoppin at btinternet.com
Thu Aug 30 17:13:53 EDT 2007
Dan Piponi wrote:
> On 8/30/07, Andrew Coppin <andrewcoppin at btinternet.com> wrote:
>> Obviously you might very well have *meant* to write x = f x. But would
>> it be possible to add some kind of optional compiler warning to find
>> such assignments?
> The thing that convinced me to learn Haskell in the first place was
> the fact that you could write x = f x. Equations where you refer to
> the same variable on the left and right hand sides are the bread of
> butter and mathematics, and I was really pleased to find a programming
> language that let me do the same.
Yeah, but... programs aren't like mathematics. I know people claim that
they are, but they aren't.
In mathematics, if you write "x = f y" you mean that these two
expressions are equal. In Haskell, if you say "x = f y" you mean *make*
(Let us not even go into the times when expressions like "z = f z"
actually means "z[n+1] = f [z]"...)
> So to me the idea of having a
> warning for this is a bit like putting a sign on bottled water saying
> "Warning: Contents may be wet". But that's just me. :-)
Well, it's definitely a valid thing to want to do, which is why I asked
for a *warning* not an error. ;-) Still, this seems to be an extremely
common way for me to hurt myself, so...
> Still, it might be useful to for the compiler to warn when a newly
> introduced name shadows another one.
More information about the Haskell-Cafe