<div class="gmail_quote">On Mon, Jun 22, 2009 at 12:06 PM, Malcolm Wallace <span dir="ltr"><<a href="mailto:Malcolm.Wallace@cs.york.ac.uk">Malcolm.Wallace@cs.york.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Erik de Castro Lopo <<a href="mailto:mle%2Bhs@mega-nerd.com">mle+hs@mega-nerd.com</a>> wrote:<br>
<br>
> Vasili I. Galchin wrote:<br>
><br>
</div><div class="im">> > "where/let" functions use the<br>
> > same name for function parameters as the outer function and hence<br>
> > there is a "shadow" warning from the compiler.<br>
><br>
</div><div class="im">> In Haskell there is an easy way around this. Variables can<br>
</div>> be name a, a', a'' and so on. ...<br>
> ... its a good idea to fix these warnings.<br>
<br>
I would _strongly_ advise not to do that. By trying to silence the<br>
spurious warning about shadowing, there is enormous potential to<br>
introduce new bugs that were not there before.<br>
<br>
Example:<br>
<br>
f a b = g (a+b) (b-a)<br>
where g a c = a*c<br>
<br>
ghc warns that g's parameter a shadows the parameter to f. So we<br>
introduce a primed identifier to eliminate the warning:<br>
<br>
f a b = g (a+b) (b-a)<br>
where g a' c = a*c<br>
<br>
Now, no warnings! But, oops, this function does not do the same thing.<br>
We forgot to add a prime to all occurrences of a on the right-hand-side.<br></blockquote></div><br>Actually there's a warning:<br><br>ghci> let f a b = g (a+b) (b-a) where g a' c = a*c<br><br><interactive>:1:34: Warning: Defined but not used: `a''<br>
<br>Cheers,<br><br>Johan<br><br>