问题描述
我有一个haskell项目,默认情况下,我使用 -Werror
进行编译。这意味着,当我运行 cabal repl
时,它将在启用 -Werror
选项的情况下运行。这意味着,例如,当我评估 2 + 2
时,会收到以下错误消息:
I have a haskell project which I compile with -Werror
by default. This means that when I run cabal repl
it runs with the option -Werror
turned on. This means that for example when I evaluate 2 + 2
I get the following error message:
<interactive>:2:3: Warning:
Defaulting the following constraint(s) to type `Integer'
(Num a0) arising from a use of `+'
In the expression: 2 + 2
In an equation for `it': it = 2 + 2
所以我需要一种方法来打开 -w
或 -Wwarn
选项 cabal repl
的默认设置。我该怎么做呢?还有 ghci
的默认标志是什么?
So I need a way to turn on the option, -w
or maybe -Wwarn
on by default for cabal repl
. How do I do this? Also what are the default flags for ghci
?
推荐答案
您可以设置〜/ .ghci
文件中的GHCi选项:
You can set GHCi options in your ~/.ghci
file:
:set -w
这将覆盖< -Wall
从 cabal repl
给我。
我的理解是, ghci
默认值为 ghc
:就像没有标志地调用编译器一样。 cabal repl
从您的 .cabal
文件中获取默认值(例如 ghc-options:-Wall
),但这会被您的〜/ .ghci
文件覆盖。
My understanding is that ghci
has the same defaults a ghc
: it's like calling the compiler with no flags. cabal repl
gets its defaults from your .cabal
file (like ghc-options: -Wall
), but this is overridden by your ~/.ghci
file.
您还可以在项目目录中创建 .ghci
文件,并在其中具有每个项目的设置。但是,这似乎与我的全局〜/ .ghci
文件进行了尴尬的交互:添加 set -Wall
不会覆盖全局变量中的:set -w
。我不确定这种行为是故意的还是只是误解了一些。
You can also create a .ghci
file in your project directory, with per-project settings there. However, this seems to interact awkwardly with my global ~/.ghci
file: adding a set -Wall
does not override the :set -w
from the global one. I'm not sure if this behavior is intended or I'm just misunderstanding something.
这篇关于如何为cabal repl设置ghci选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!