Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable language extensions / pragmas project wide by default?

Is there a way to put {-# LANGUAGE <feature> #-} pragmas in either the:

  • <project>.cabal, or
  • stack.yaml

file, to avoid repeating the same header code in every *.hs file of a project?

like image 676
dbanas Avatar asked Jan 31 '18 00:01

dbanas


1 Answers

As @user2407038 said in the comments, you can use the default-extensions field in your <project>.cabal file.

If you wanted to have OverloadStrings and GADTs in all of your modules in the project, you would list it in relevant section of your cabal file (i.e. if you want it for all of your library files, put it in library).

For example:

-- <project>.cabal
...
library
  hs-source-dirs:       src
  default-extensions:   GADTs
                      , OverloadedStrings 
  ...

If you are using a package.yaml configuration file to generate your <project>.cabal file, you can also specify this field there.

-- package.yaml
library:
  source-dirs: src
  default-extensions:
    - OverloadedStrings
    - GADTs
  exposed-modules:
    - MyModule
  ...
like image 153
jkeuhlen Avatar answered Oct 13 '22 19:10

jkeuhlen