1

I want to run a program that demands a specific version of the base package. This version is not the one that comes with my OS's version of Haskell hence I apparently can't use my OS's version of Haskell.

It would be great of conda worked with Haskell the way it works with Python so as to create an environment for a specific version of Haskell, but such is not the case. Nor is it the case that Haskell's sandbox feature permits one to specify a version of base let alone Haskell itself.

PS: Frustratingly, the SE question "How to install an older version of base in Haskell" ended up answering another question without changing the title to reflect the question it did answer.

lehins
  • 9,642
  • 2
  • 35
  • 49
user3673
  • 665
  • 5
  • 21
  • One usually works with haskell-stack to build/... items with a given compiler, library, etc.: https://anaconda.org/conda-forge/stack You can see it as some sort of virtual environment like in Python. – Willem Van Onsem Feb 04 '20 at 19:25
  • The version of the base `base` is linked to the version of the GHC compiler. If your OS's package manager doesn't have old versions of GHC, you can go the GHC website and install them yourself. – HTNW Feb 04 '20 at 21:12

1 Answers1

4

There is a tool that works even better then conda in Haskell called stack. Version of base is hardwired with version of ghc that is installed. You can get stack installed first and it will install version of the ghc you need automatically:

$ curl -sSL https://get.haskellstack.org/ | sh

This command will automatically install ghc-8.6.5, which is specified by lts-14.22 resolver and will make all packages available for you on demand including base

$ stack --resolver lts-14.22 ghci

To obtain the resolver specification:

  1. Go to this table of all packages that come installed with a particular GHC version.
  2. If a desired base version is not available, find the scroll bar at the bottom of the table and scroll to the right until you find one.
  3. Say it is base-4.11.1.0, then look at the header of the column for the ghc version that ships with this base.
  4. In this example either one of this versions of ghc: 8.4.4, 8.4.3, 8.4.2 will have that version of base.
  5. Go on the stackage.org home page and find in the matching lastest resolver in the list "Latest LTS per GHC version".
  6. In this example, any lts-12 will do for the base above.

Latest nightly resolver will always have the newest ghc and base available on stackage.

user3673
  • 665
  • 5
  • 21
lehins
  • 9,642
  • 2
  • 35
  • 49
  • How does one translate from `base >=4.8 && <4.9` to a `resolver`? – user3673 Feb 05 '20 at 15:18
  • @user3673 See the edit I made to the answer: "How to go from base to resolver" – lehins Feb 05 '20 at 15:29
  • I edited further to breakout the steps. However, after following them: ```$ stack --resolver lts-6.35 ghc Run from outside a project, using implicit global project config Using resolver: lts-6.35 specified on command line Compiler version mismatched, found ghc-8.0.1 (x86_64), but expected minor version match with ghc-7.10.3 (x86_64) (based on resolver setting in ~/.stack/global-project/stack.yaml). Try running "stack setup" to install the correct GHC into ~/.stack/programs/x86_64-linux/``` – user3673 Feb 05 '20 at 15:57
  • If you just want to run `ghc`, the do `stack --resolver lts-6.35 exec -- ghc ...` Normally stack is used to work on full projects. So doing `stack new project-name`, and go from there. – lehins Feb 05 '20 at 16:33
  • Also make sure you have newest version of `stack`, not the one provided by the OS. – lehins Feb 05 '20 at 16:34