[Haskell-cafe] record field names vs. -fwarn-unused-binds

Thomas Miedema thomasmiedema at gmail.com
Tue Nov 3 18:42:51 UTC 2015


Through a patch
<https://git.haskell.org/ghc.git/commitdiff/aead01902e1c41e85b758dbafd15e60d08956374>
by Oleg Grenrus (phadej), GHC 8 will have the following new flags:
 -fwarn-unused-top-binds
 -fwarn-unused-local-binds
 -fwarn-unused-pattern-binds

So you'll be able to pick and choose.


On Tue, Nov 3, 2015 at 6:47 PM, Evan Laforge <qdunkan at gmail.com> wrote:

> [ ccing haskell-cafe since while it's a ghc flag, I'll bet most
> compilers have an equivalent ]
>
> I really like -fwarn-unused-binds because it frequently finds bugs
> where I forgot to call something or use some value.  If I put an
> export list on, it can find dead functions I forgot to delete.
> However, there's one case where it frequently gives false positives,
> and that's unused record field names.  The problem is that I sometimes
> use record field names as documentation, but the record itself is
> internal and small, so I'm comfortable using positional pattern
> matching to open it (and in fact that can be safer, since then
> warn-unused-binds will make sure I used all the fields).  But GHC sees
> these as unused functions, so it warns about them.  I can work around
> by putting underscores on field names I haven't used yet, but it's a
> hassle to go edit them when I want to use them.  The warning can be
> useful if it indicates an unused field, but since fields can also be
> extracted via the positional syntax it's not reliable.  The other use
> of the warning for dead code or functions you forgot to use doesn't
> apply to record accessors because they're trivial and compiler
> generated.
>
> So, would it be reasonable to exclude record field accessors from
> -fwarn-unused-binds?  Or is there another way to work around it?  I
> guess GHC doesn't have a "suppress warning" pragma like Java does, but
> even if we did it wouldn't be much better than changing the name, and
> more likely to get stale.
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151103/089ffa95/attachment.html>


More information about the Haskell-Cafe mailing list