Cross-platform makefiles for a small Haskell project?

I recently created a small single-phase utility Haskell, which will be included in the "tools" section of my pure PHP project (raised eyebrows, I know).

First, I checked both the .hs source file and the binary code generated on my Linux development machine with the version control system we use (Git). But now that I think about it more, I would like to create cross-platform makefiles to continue it so that other developers can easily compile it on their systems.

Are there any best practices / recommendations or even the best Makefiles that can be downloaded? Nothing unusual, just something that allows developers to provide some details about their GHC setup and run a simple script to get started.

+7
source share
2 answers

The recommended way to distribute your Haskell projects is to use Cabal . Cabal is both a build system and a package manager for Haskell code, and it makes it easy to collect Haskell code on different platforms when handling dependencies for you.

Here is an example cabal file:

Name: MyPackage Version: 0.0 Cabal-Version: >= 1.2 License: BSD3 Author: Angela Author Synopsis: Small package an utility program Build-Type: Simple Executable myutility Build-Depends: base Main-Is: Main.hs Hs-Source-Dirs: src 

You can create a cabal file interactively by running

 $ cabal init 

Then Kabbalah will ask you some simple questions and create a Kabbalah file based on your answers. Then you can customize this file to suit your specific needs.


To install a package, simply run it in the package directory

 $ cabal install 

You can also upload your package to Hackage , the standard Haskell package repository. This way, people can download and install your package (and any dependencies) in one step with the command

 $ cabal install mypackage 

There are also tools for converting Cabal packages to other package managers if you do not want your users to install Cabal (although Cabal is included in the Haskell Platform ).

It also works well with Haddock to create reference documentation for your package. Check out some packages in Hackage for sample results.

Work is also underway to improve Cabal test suite support.

All in all, these reasons, and many others, make great use of Cabal to organize, build, and distribute your Haskell projects.

+11
source

If you can afford another addiction, try cabal . This is a build specifically designed for Haskell.

+2
source

All Articles