Haskell is a general purpose, purely functional, programming language.
Haskell generates machine code that can be run natively on Linux. There is nothing special required to run a binary (already compiled) software, like the ones provided in the official repositories or by the ArchHaskell group. On the other side, AUR packages or source codes requires a compiler to build the software.
Installing the compiler alone permits to build Haskell source code. A few additional tools are needed for development work.
To build a Haskell source–code into native–code, a compiler must be installed. There are several implementations available, but the one used most (which is now de facto the reference) is the GHC (Glasgow Haskell Compiler). It is available in the official repositories as .
You can try it with the following file:
main = putStrLn "Hello, World"
and by running:
$ ghc -dynamic Main.hs $ ./Main
GHC uses static linking by default and the
-dynamic flag is used to select dynamic linking. Starting with package version 8.0.2-1, the Arch package no longer contains static versions of the GHC platform libraries. Installing the package is now necessary for the default compilation flags to work.
Dynamic linking is used for most Haskell modules packaged through pacman and is common for packages in the AUR. Since GHC provides no ABI compatibility between compiler releases, static linking is often the preferred option for local development outside of the package system.
This also causes issues with Cabal trying to use the default static linking. To force dynamic linking in Cabal, edit
~/.cabal/config and add the line
Haskell development tools
To start developing in Haskell easily, one option is the haskell-platform bundle which is described as:
- The easiest way to get started with programming Haskell. It comes with all you need to get up and running. Think of it as "Haskell: batteries included".
- ghc (boot libraries, and supplementary static boot libraries and ) — Compiler with dynamic
- cabal-install ( ) — A command line interface for Cabal and Hackage
- haddock ( and ) — Tools for generating documentation
- happy ( ) — Parser generator
- alex ( ) — Lexical analyzer generator
Alternatively, you can use Arch Linux install instructions.to manage your Haskell environment by following the
Managing Haskell packages
Many Haskell libraries and executables are grouped in packages. They are all available on Hackage. To install and manage these packages, several methods are available and unusual ones are explained in the rest of this section.
The recommended workflow is the following:
- Official repositories or ArchHaskell repository as principal source of Haskell packages (the or is exclusive here)
- cabal-install (possibly with sandboxes) for Haskell development
- Arch User Repository for packages that are not available elsewhere
cblrepo is a tool used for maintaining Haskell packages for Linux distributions. A wrapper around this, AUR[broken link: archived in aur-mirror], can create PKGBUILD files from Hackage packages. See Haskell package guidelines for more information on creating new Haskell packages.
Pros/Cons of the different methods
The following table documents the advantages and disadvantages of different package management styles.
|Official repositories||Provided by ArchLinux developers, consistent versions of packages, already compiled||Only a few packages available|
|ArchHaskell repository||Provided by ArchHaskell group, consistent versions of packages, already compiled||Need manual intervention to get started with|
|cabal-install||All packages available||Installed in home folder, is not a package manager, incompatible versions of packages possible (aka. cabal hell)|
|Arch User Repository||Simple to get started||Risk of unmaintained or orphaned packages, incompatible versions of packages possible|
See ArchHaskell for details.
Preparation and $PATH
Install official repositories.from the
To run installed executables without specifying the path, the cabal binary folder
~/.cabal/bin must be added to the
$PATH variable. That can be done by putting the following line in your shell configuration file, for instance
~/.bashrc for or
~/.zshrc for :
PATH=$PATH:~/.cabal/binTo run executables within a cabal sandbox, you must also add
$ cabal update $ cabal install <pkg>
It is possible to install a package system–wide with the
--global flag, but this is strongly discouraged. With the user–wide install, all files are kept in
~/.cabal and libraries are registered to
~/.ghc, offering the possibility to do a clean-up easily by simply removing these folders. With system–wide install, the files will be dispersed in the file system and difficult to manage.
There is no easy way to do it. Cabal does not have removing process.
One thing to make your life easier is use zsh auto completion to find all the haskell packages.
If you want/can fix/reinstall whole Haskell package system - remove
~/.ghc and start from scratch.