Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade GHC with Stack

The output of

stack ghc -- --version

is

The Glorious Glasgow Haskell Compilation System, version 7.10.3

I want to upgrade to GHC 8.

How can I tell Stack to upgrade GHC?

like image 370
mac10688 Avatar asked Aug 04 '17 04:08

mac10688


People also ask

Where does stack install GHC?

In its default configuration, Stack will simply ignore any system GHC installation and use a sandboxed GHC that it has installed itself. You can find these sandboxed GHC installations in the ghc-* directories in the stack path --programs directory.

Where is Haskell stack installed?

Stack installs the Stackage libraries in ~/. stack and any project libraries or extra dependencies in a . stack-work directory within each project's directory. None of this should affect any existing Haskell tools at all.

What is stack Ghci?

stack ghci allows you to load components and files of your project into ghci . It uses the same TARGET syntax as stack build , and can also take options like --test , --bench , and --flag . Similarly to stack build , the default is to load up ghci with all libraries and executables in the project.

How do I check my GHC version?

The version number of your copy of GHC can be found by invoking ghc with the --version flag (see Verbosity options). The compiler version can be tested within compiled code with the MIN_VERSION_GLASGOW_HASKELL CPP macro (defined only when CPP is used).


1 Answers

User dysfun from the IRC answered my question so I will post it here for posterity.

To update GHC that's used to compile a project, go to the project's stack.yaml file.

In there is the resolver field. Update that accordingly. Some examples:

resolver: ghc-8.0.2
resolver: lts-9.0
resolver: nightly-2015-09-21

For my case, I learned from this webpage that resolver lts-9.0 uses GHC 8.0.2.

Here's more on Stack's resolvers.

like image 53
mac10688 Avatar answered Sep 18 '22 14:09

mac10688