required fields in Cabal

Isaac Jones ijones at
Mon Feb 21 20:56:08 EST 2005


I want to have a very quick discussion about which fields are required
in the Cabal.  I intend to implement these in the little sanity
checker, and they should be documented.  If we have any time at all
before GHC gets released, we don't have much so this can't be a very
long discussion ;)

BTW, Should we regularize the names of the fields at this late date?
Sorry for not doing this earlier.  We have libBuildInfo for libraries,
but buildInfo for executables.  We also have exeName.  Does anything
outside of cabal depend on these names (yet)?[1]

* What's required:

Library: exposedModules is required.  If it's empty, and BuildInfo is
non-empty, this is an error.

Executable: exeName and modulePath are required.  If exeName is empty,
this is a parse error.  All buildInfo fields are optional.

Everything in BuildInfo is optional.

So that leaves us with the PackageDescription type itself.  Let's talk
about what I think is absoluteluy required for building, and then the
fields I think should be there in any useful package that someone
wants someone else to use.

Are there any fields that any of the layred tools absolutely require?
(Hackage, etc)?

* What's needed for building

I won't swear to it, but I think all you generally need to build a
library is: 
	package        :: PackageIdentifier,
-- From the library field:
        exposedModules :: [String],

and an executable:
	package        :: PackageIdentifier,
-- from the executables field:
        exeName    :: String,
        modulePath :: FilePath,

* What any good package should have:
	package (name and version) :: PackageIdentifier,
        license        :: License,
-- OR?
        licenseFile    :: FilePath,
        copyright      :: String,
        maintainer     :: String,
	synopsis       :: String,

Personally, I think it should be an error if any of these fields are
missing.  I think I'll go implement that now.  Stop me if you object.



[1] As a reminder, here are the the relevant types.
data PackageDescription
    =  PackageDescription {
	-- the following are required by all packages:
	package        :: PackageIdentifier,
        license        :: License,
        licenseFile    :: FilePath,
        copyright      :: String,
        maintainer     :: String,
	author         :: String,
        stability      :: String,
	testedWith     :: [(CompilerFlavor,VersionRange)],
	homepage       :: String,
	pkgUrl         :: String,
	synopsis       :: String,
	description    :: String,
	category       :: String,
        buildDepends   :: [Dependency],
	-- components
        library        :: Maybe Library,
        executables    :: [Executable]

data Library = Library { exposedModules    :: [String],
                         libBuildInfo      :: BuildInfo }

data Executable = Executable {
        exeName    :: String,
        modulePath :: FilePath,
        buildInfo  :: BuildInfo

data BuildInfo = BuildInfo {
        buildable         :: Bool,      -- ^ component is buildable here
        ccOptions         :: [String],  -- ^ options for C compiler
        ldOptions         :: [String],  -- ^ options for linker
        frameworks        :: [String],
        cSources          :: [FilePath],
        hsSourceDir       :: FilePath,
	otherModules      :: [String],
        extensions        :: [Extension],
        extraLibs         :: [String],
        extraLibDirs      :: [String],
        includeDirs       :: [FilePath],
        includes          :: [FilePath],
        options           :: [(CompilerFlavor,[String])]

More information about the Libraries mailing list