How can I manage multiple configurations of a single Haskell program?

What is an alternative to autotools in the Haskell world? I want to be able to choose between different configurations of the same source code.

For example, in Haskell there are at least two MD5 implementations: Data.Digest.OpenSSL.MD5and Data.Digest.Pure.MD5. I would like to write the code in such a way that it can determine which library is already installed, and does not require the installation of another.

In C, I can use Autotools / Scons / CMake + cpp. In Python, I can catch ImportError. What tools should be used in Haskell?

+5
source share
2 answers

Haskell Cabal. .cabal, , <yourprojectname>.cabal. :

Name:                myfancypackage
Version:             0.0
Description:         myfancypackage
License:             BSD3
License-file:        LICENSE
Author:              John Doe
Maintainer:          john@example.com
Build-Type:          Simple
Cabal-Version:       >=1.4

Flag pure-haskell-md5
  Description: Choose the purely Haskell MD5 implementation
  Default: False

Executable haq
  Main-is:           Haq.hs
  Build-Depends:     base-4.*
  if flag(pure-haskell-md5)
    Build-Depends:   pureMD5-0.2.*
  else
    Build-Depends:   hopenssl-1.1.*

Cabal , Configurations.

+14

nominolo, Cabal - . , "".

+2

All Articles