如何[暂时]禁止“定义但未使用”警告? [英] How to [temporarily] suppress "defined but not used" warnings?

查看:115
本文介绍了如何[暂时]禁止“定义但未使用”警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

 / Users / bob / SourceCode / course / is 

当我为Haskell程序创建原型时,我总是会得到数百个这样的警告(不是开玩笑) /expriment/LiftedSpine2.hs:70:15:
警告:已定义但未使用:ta

/Users/bob/SourceCode/course/is/expriment/LiftedSpine2.hs: 72:15:
警告:已定义但未使用:'ta'

/Users/bob/SourceCode/course/is/expriment/LiftedSpine2.hs:77:26:
警告:已定义但未使用:'v'

是否有临时删除这些警告的方法?
我试着把它放在我的.hs文件中:

  { - #OPTIONS_GHC -fno-warn-unused-binds -fno-warn-name-shadowing 
-fwarn-monomorphism-restriction -fwarn-hi-shadowing
# - }

不幸的是,它不起作用,尽管我也尝试过:set -fno-warn-unused-binds,但它仍然无效。



非常感谢!

解决方案

另一种可能性取决于您的情况:我相信您可以使用下划线来压制这个警告。所以:

  _x = 42 

$ b $如果 _x 未被使用,b

不会产生警告。


When I prototype Haskell programs, I always get hundreds of warnings like this (not joking):

/Users/bob/SourceCode/course/is/expriment/LiftedSpine2.hs:70:15:
    Warning: Defined but not used: `ta'

/Users/bob/SourceCode/course/is/expriment/LiftedSpine2.hs:72:15:
    Warning: Defined but not used: `ta'

/Users/bob/SourceCode/course/is/expriment/LiftedSpine2.hs:77:26:
    Warning: Defined but not used: `v'

Is there anyway to remove these warnings temporarily? I tried putting this in my .hs file:

 {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-name-shadowing 
    -fwarn-monomorphism-restriction -fwarn-hi-shadowing
 #-}

Unfortunately, it does not work, and although I also tried to :set -fno-warn-unused-binds, it still does not work.

Many thanks!

解决方案

Another possibility, depending on your situation: I believe you can prefix identifiers with an underscore to suppress this warning. So:

_x = 42

will not generate the warning if _x is not used.

这篇关于如何[暂时]禁止“定义但未使用”警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆