3. A Solution for Haskell in Haskell

As mentioned above, the foremost user interface for this system will be a Haskell program to be executed by the default Haskell Implementation. This Haskell program, Setup.lhs, will perform the tasks of building the package (where necessary), installing the package, and making the package available to the system.

3.1. The Module Design

I propose a set of modules based on these three major tasks:

3.2. But Why Should We Use Haskell?

It is very appropriate that this solution be implemented in Haskell:

3.3. Setup.lhs Command-Line Interface

The purpose of the Setup script is to provide a standard interface to end users and layered tools. For any particular application, the script may be implemented in a variety of ways: For pure Haskell applications, the Distribution module should perform all of the heavy lifting, requiring only a few lines of code from the developer. For applications that feel they need a complete and robust make-based system, the Setup script can wrap such a system.

One of the early design tasks of this project should be to decide on a format for the command-line interface of the Setup script, but here is an example of how it might behave:

Table 1. Setup.lhs interface

./Setup.lhs info

Output package configuration information

./Setup.lhs build all

Compile / prepare this package for all installed Haskell Implementations

./Setup.lhs build default

Compile / prepare this package for the default Haskell Implementation

./Setup.lhs build {NHC,GHC,Hugs, ...}

Compile / prepare this package for the given Haskell Implementation

./Setup.lhs install {all,default,NHC,GHC,Hugs,...}

Install this package.

./Setup.lhs register {all,default,NHC,GHC,Hugs,...}

Register this package with the package management system (making it available to the given Haskell Implementation.)

./Setup.lhs bdist_{deb,rpm,...}

Create a binary distribution package for Debian, RPM, etc.

./Setup.lhs sdist

Create a source distribution archive.

./Setup.lhs test

Run the package's test suite.

Other commands may be available, and it is important to anticipate commands that may some day be desirable.

3.4. An Example Setup.lhs Script

Here's what the setup script might look like for HUnit, which has no complex dependencies.

#!/usr/bin/env haskell
import Distribution.Core
import Distribution.Package

toolInfo = (defaultPackage "HUnit"
                           (NumberedVersion 1 0 0))
                    "HUnitLang98.lhs","HUnitLangExc.lhs", "Info.lhs",
                    "Terminal.lhs", "HUnitTest98.lhs", "TerminalTest.lhs",
                    "HUnit.lhs", "HUnitTestBase.lhs", "HUnitBase.lhs",
                    "HUnitTestExc.lhs", "HUnitLang.lhs", "HUnitText.lhs",
	    docs = ["Example.hs", "Guide.html", "License", "README"]}

main = defaultMain toolInfo id id
-- Those last to parameters might be pre-install and post-install functions

defaultMain would implement all of the standard command-line flags, and defaultPackage is a template with sane default values for most fields.