Global configuration for GHC build flags

Is there a place where I can set some default flags for GHC? I would like the GHC to always assume that I need the -fwarn-incomplete-patterns flag. This page contains a list of useful flags and indicates that some of them are enabled by default, but again I would like to change the default settings for my system.

I am currently working on OS X, but I use Debian, Arch Linux and Windows 8.1 at home, so a solution for any platform will help.

+7
haskell ghc
source share
3 answers

Besides superimposing the ghc shell command on ghc -fwarn-incomplete-patterns , I don’t think there is a way to do this globally or it would be advisable to do it globally, as this would probably generate a huge amount of warnings when compiling external libraries with bondage. It is probably best to do this project at a time or just with GHCi:

There is a ghc-options section in any cabal file for the project.

 library ... ghc-options: -fwarn-tabs -fwarn-missing-local-sigs -fwarn-incomplete-patterns -fwarn-incomplete-uni-patterns 

For global GHCi, you can add the following line to your ~ / .ghc / ghci.conf file

 :set -fwarn-incomplete-uni-patterns 
+9
source share

Add ghc-options: -fwarn-incomplete-patterns to the program-default-options section of your ~/.cabal/config :

 [...] program-default-options ... ghc-options: -fwarn-incomplete-patterns ... 

This only works with cabalized projects (that is, when you use cabal build/install/[...] instead of running ghc --make SomeFile.hs manually) and requires a fairly recent cabal-install (> = 1.18).

+5
source share

Just because it will be useful for people who come here:

In Gentoo, you can set the parameters for all Cabal packages (almost all of them are) globally, in /etc/portage/make.conf , with the variable CABAL_EXTRA_BUILD_FLAGS . So in your case it will be

 CABAL_EXTRA_BUILD_FLAGS="--ghc-option=-fwarn-incomplete-patterns" 

and here is a more advanced example

 CABAL_EXTRA_BUILD_FLAGS="--ghc-option=+RTS --ghc-option=-M1G --ghc-option=-RTS" 

to limit memory usage to 1 GB (and exit otherwise).

I think this is a similar solution for Arch and Debian, but since OS X is a consumer OS, I don't know.

0
source share

All Articles