user316146
user316146

Reputation: 1307

start ghci with extensions specified in cabal configuration file

In my cabal file I have a bunch of language extensions enabled. Let's say I have

Is there a way to start GHCi with these enabled automatically? instead of manually doing

ghci -XTemplateHaskell -XQuasiQuotes -XCPP

Upvotes: 1

Views: 882

Answers (3)

user316146
user316146

Reputation: 1307

cabal-ghci was exactly what I wanted.

Upvotes: 1

isturdy
isturdy

Reputation: 1231

Specify the extensions in a pragma at the top of the source files:

{-# LANGUAGE TemplateHaskell, QuasiQuotes, CPP #-}

For ghc options that are not within the scope of the language pragma, you can also use the OPTIONS_GHC pragma (and you could write {-# OPTIONS_GHC -XTemplateHaskell -XQuasiQuotes -XCPP #-} (note the lack of commas), but the language pragma is preferred where possible, as it is portable to other compilers that support the extensions).

Upvotes: -1

user1429368
user1429368

Reputation:

Yes, you can use the .ghci file. See section 2.9 in the GHC manual.

~/.ghci

:set -XTemplateHaskell -XQuasiQuotes -XCPP

Upvotes: 4

Related Questions