On Mon, Jun 22, 2009 at 12:06 PM, Malcolm Wallace
<Malcolm.Wallace@cs.york.ac.uk> wrote:
> > "where/let" functions use the
> > same name for function parameters as the outer function and hence
> > there is a "shadow" warning from the compiler.
>
> In Haskell there is an easy way around this. Variables can
> be name a, a', a'' and so on. ...
> ... its a good idea to fix these warnings.
I would _strongly_ advise not to do that. By trying to silence the
spurious warning about shadowing, there is enormous potential to
introduce new bugs that were not there before.
Example:
f a b = g (a+b) (b-a)
where g a c = a*c
ghc warns that g's parameter a shadows the parameter to f. So we
introduce a primed identifier to eliminate the warning:
f a b = g (a+b) (b-a)
where g a' c = a*c
Now, no warnings! But, oops, this function does not do the same thing.
We forgot to add a prime to all occurrences of a on the right-hand-side.