Johan Tibell <johan.tib...@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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to