Impact on style of GHC -Wall

前端 未结 6 425
囚心锁ツ
囚心锁ツ 2021-02-02 10:16

It is considered good practice to enable GHC warnings with -Wall. However, I\'ve found out that fixing those warnings has a negative effect for some types of code c

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 10:54

    Name shadowing can be quite dangerous. In particular, it can become difficult to reason about what scope a name is introduced in.

    Unused pattern binds in do notation are not as bad, but can indicate that a less efficient function than necessary is being used (e.g. mapM instead of mapM_).

    As BenMos pointed out, using void or ignore to explicitly discard unused values is a nice way to be explicit about things.

    It would be quite nice to be able to disable warnings for just a section of code, rather than for everything at once. Also, cabal flags and command line ghc flags take precedence over flags in a file, so I can't have -Wall by default everywhere and even easily just disable it for the entirety of a single file.

提交回复
热议问题