How to set ghci options for cabal repl?

不想你离开。 提交于 2019-12-21 07:13:49

问题


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

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?


回答1:


You can set GHCi options in your ~/.ghci file:

:set -w

This overrides the -Wall from cabal repl for me.

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.

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.



来源:https://stackoverflow.com/questions/25323686/how-to-set-ghci-options-for-cabal-repl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!