[Haskell-cafe] coding standard question
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Mon Jun 22 08:30:25 EDT 2009
Johan Tibell <johan.tibell at gmail.com> wrote:
> > Example:
> > f a b = g (a+b) (b-a)
> > where g a c = a*c
> > ---->
> > f a b = g (a+b) (b-a)
> > where g a' c = a*c
>
> Actually there's a warning:
> <interactive>:1:34: Warning: Defined but not used: `a''
Clearly I simplified the example too far. Try this, only slightly more
complex, example instead. Remember, the larger the example, the more
likely you are to miss an occurrence.
f a b = g (a+b) (b-a)
where g a c = a*(c-a)
---->
f a b = g (a+b) (b-a)
where g a' c = a'*(c-a)
Perhaps I should advocate for a new warning in GHC to cover this case:
-fwarn-mixed-scopes, which could flag the use of the unprimed a, due to
being bound at an outer scope.
Because warn-mixed-scopes is almost the opposite of warn-name-shadowing,
then the only way to avoid warnings would be to manually lambda-lift all
functions. :-)
Regards,
Malcolm
More information about the Haskell-Cafe
mailing list