Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set ghci options for cabal repl?

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?

like image 306
11Kilobytes Avatar asked Aug 15 '14 08:08

11Kilobytes


1 Answers

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.

like image 191
Tikhon Jelvis Avatar answered Oct 19 '22 12:10

Tikhon Jelvis