减少Eclipse(类型)警告级别

poi*_*oae 7 eclipse haskell

我最近安装了Haskell Eclipse插件"EclipseFP".一切都很好,而有一个功能让我很生气呵呵.我无法降低输出的警告级别.Eclipse/It的插件似乎会自动附加"-Wall"标志,这对于类型事物非常敏感.让我们以一个例子来说明这个:

*Main> head [1,2,3]

<interactive>:1:11:
    Warning: Defaulting the following constraint(s) to type `Integer'
               (Num a0) arising from the literal `3'
    In the expression: 3
    In the first argument of `head', namely `[1, 2, 3]'
    In the expression: head [1, 2, 3]

<interactive>:1:11:
    Warning: Defaulting the following constraint(s) to type `Integer'
               (Num a0) arising from the literal `3' at <interactive>:1:11
               (Show a0) arising from a use of `print' at <interactive>:1:1-12
    In the expression: 3
    In the first argument of `head', namely `[1, 2, 3]'
    In the expression: head [1, 2, 3]
1
*Main> 
Run Code Online (Sandbox Code Playgroud)

是的,真的很烦人.它是由"内在"功能以及自定义功能引起的.另一个:

factorial :: (Integral a) => a -> a
factorial 1 = 1
factorial n = n * factorial (n-1)

*Main> factorial 3

<interactive>:1:1:
    Warning: Defaulting the following constraint(s) to type `Integer'
               (Integral a0) arising from a use of `factorial'
                             at <interactive>:1:1-9
               (Num a0) arising from the literal `3' at <interactive>:1:11
    In the expression: factorial 3
    In an equation for `it': it = factorial 3

<interactive>:1:1:
    Warning: Defaulting the following constraint(s) to type `Integer'
               (Integral a0) arising from a use of `factorial'
                             at <interactive>:1:1-9
               (Num a0) arising from the literal `3' at <interactive>:1:11
               (Show a0) arising from a use of `print' at <interactive>:1:1-11
    In the expression: factorial 3
    In an equation for `it': it = factorial 3
6
*Main> 
Run Code Online (Sandbox Code Playgroud)

Dan*_*her 6

我不了解Eclipse,但您可以在.ghci文件中关闭警告.放

:set -Wall           -- unnecessary if Eclipse already turns it on
:set -fno-warn-type-defaults
:set -fno-warn-unused-do-bind
Run Code Online (Sandbox Code Playgroud)

以及其他任何你不想默认警告你的东西,~/.ghci并减少对重要警告的警告.如果要默认加载某些模块,也可以添加import Control.Applicative(或以其中任何一个).


Ger*_*ger 5

在.cabal文件中写道: ghc-options: -Wall -fno-warn-type-defaults -fno-warn-unused-do-bind