'What is the suggested way of setting up Haskell on Archlinux?
Long story short, I'd like some guidance on what's the (best) way to have Haskell work on Archlinux.
By work I mean all, in terms of the ghci
command line tool, installing packages I don't have - such as vector-space
, which this answer to a question of mine refers to -, and any other thing that could be necessary to a Haskell ostinate learner.
Archlinux wikipage on Haskell lists three (alternative?) packages for making Haskell work on the system, namely ghc
, cabal-install
, and stack
. I have the first and the third installed on my system, but I think I must have installed the latter later (unless it's a dependency to ghc
) while tampering around (probably in relation to Vim as a Haskell IDE). Furthermore, I have a huge amount of haskell-*
packages installed (why? Who knows? As a learner I must have come multiple times to the point of say uh, let's try this!).
- Are there any pros and cons ("
cons
", ahah) about each of those packages? - Can they all be used with/without conflicts?
- Does any of them make any other superfluous?
- Is there anything else I should be aware of which I seem apparently ignorant about based of what I've written?
Solution 1:[1]
Arch Linux's choice of providing dynamically linked libraries in their packages tends to get in the way if you are looking to develop Haskell code. As an Arch user myself, my default advice would be to not use Arch's Haskell packages at all, and instead to install whatever you need through ghcup or Stack, starting from the guidance in their respective project pages.
Solution 2:[2]
You are basically there. Try the following:
ghci
: If you get the Haskell REPL then it works.stack ghci
: Again you should get the Haskell REPL. There are a lot of versions of GHC, andstack
manages these along with the libraries. Whenever you use a new version of GHCstack
will download it and create a local installation for you.
stack
is independent of your Linux package manager. The trouble is that your distro will only have the Haskell libraries it actually needs for any applications it has integrated, and once you step outside of those you are in dependency hell with no support. So I recommend that you avoid your distro Haskell packages. stack
does everything you need.
If you installed stack
from your Linux package manager then you might want to uninstall it and use a personal copy (i.e. in your ~/.local directory) instead. Then you can always say stack update
to check you have the latest version.
Once you have stack
going, create a project by saying stack new my-project simple
. Then go into the project folder and start editing. You can work with just a .hs
file and GHC if you really want, but its painful; you will do much better with stack
, even if you are just messing around.
You'll also need an editor. Basic functionality like syntax highlighting is available in pretty much everything, but once you get past Towers of Hanoi you are going to want something better. I use Atom with ide-haskell-ghcide. This uses the Haskell Language Server under the hood, so you will need to install that too. I know a bunch of other editors have HLS support, but I don't have experience with them.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Paul Johnson |