Skip to content

Configuration

Managing software

To change your version of GHC, cabal, or the Haskell Language Server:

> ghcup tui

You should see something like:

This makes it easy to change version of the compiler, the Haskell language server, and cabal (the package manager).

Stack

stack is (roughly) an alternative package manager. Either cabal or stack work well, but this documentation defaults to cabal.

Installing packages

To add packages, include their names to the package list in your .cabal file:

library
    exposed-modules:  MyLib

    build-depends:    
        base ^>=4.16.3.0,
        text,
        NEW PACKAGE,
        ANOTHER NEW PACKAGE
    hs-source-dirs:   src
    default-language: GHC2021

Packages are hosted here.

Extensions

Haskell allows new code features to be enabled/disabled with lines like:

{-# LANGUAGE OverloadedStrings #-}

at the top of files.

We recommend setting the default-language to GHC2021, which enables a set of compatible and standard extensions.

Warning

GHC2021 will only work for GHC 9 and greater. Otherwise replace with Haskell2010.

library
    exposed-modules:  MyLib

    build-depends:    
        base ^>=4.16.3.0,
        text,
    hs-source-dirs:   src
    default-language: GHC2021

Last update: January 12, 2023
Created: January 8, 2023

Comments