In this post, we will take a look at Cabal. It is a follow up on the previous post: Setting Up Haskell Development Environment: The Basics where we took a step back to see how to compile Haskell programs without the use of any build tool. The reason for doing that is to create an appreciation for the fundamental moving parts involved in setting up and developing with Haskell. In this post, we move forward and we introduce Cabal, which is a build tool that can be described as a system for building and packaging Haskell libraries and programs.
This post contains the following sections:
- Clarifying terms
- Installing (or upgrading) cabal-install
- Creating a new project
- Building and running executables
- Adding dependencies
- Having a project with both library and executable
- Configuring visibility of modules in a library
- Using different GHC compiler across different projects
- How to execute a Haskell file as a script
- How to install packages
- Historical Notes
This post is going to outline the procedure for setting up a Haskell development environment.
This post differs from most posts around setting up a Haskell development environment in the sense that it does not directly jump into Cabal or Stack. Instead, it first provides some background information that makes it possible to understand the basics of the development environment in Haskell, the different moving parts, and how those come together in turning Haskell source code into an executable which can then be run.