eclipse - 降低 Eclipse(类型)警告级别

标签 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> 

是的,这真的很烦人。它是由“内在”功能以及自定义功能引起的。
另一个:
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> 

最佳答案

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

:set -Wall           -- unnecessary if Eclipse already turns it on
:set -fno-warn-type-defaults
:set -fno-warn-unused-do-bind

以及默认情况下您不想警告的任何其他内容到您的~/.ghci并减少对重要的警告。如果想默认加载一些模块,也可以加import Control.Applicative (或任何一个)。

关于eclipse - 降低 Eclipse(类型)警告级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9022431/

相关文章:

java - 使用 Ant 在新的 jar 文件构建中包含外部 jar 文件

java - 安装的 JRE/JDK 未显示在 Eclipse Mars 的执行环境中

haskell - 是否通常将变量包装在无用的 `id` 调用中以避免证明上的 eta 转换问题?

haskell - Haskell 中的帕斯卡三角形

haskell - 除了 Caledon 之外,还有其他基于 Haskell 的 HOL 编程语言吗?

image - 适用于 Windows 的 Haskell 替代 SDL

java - eclipse根据构造函数参数生成类变量getter setter

android - 如何使用 Espresso 在 Android 上进行测试?

java - "URI is not hierarchical"+ 私钥

sorting - 根据异构标准进行 map 比较