-
Notifications
You must be signed in to change notification settings - Fork 72
Packages
To avoid compiling everything from source all the time, there is a notion of a precompiled package.
A package is simply a set of modules that are compiled together and that can then be installed in
a known place (typically ~/.mcabal/mhs-VERSION/packages/).
Packages can depend on already installed packages.
There is a search path for installed packages, controlled by the -a flag.
There is no need for any extra flags to mhs to use installed packages, they are all visible at all times.
When compiling to a binary, only the used parts of a package will be included in the binary.
To compile a package, use the command mhs -Ppackage-name.pkg modules... where modules...
are all the modules you wish to expose from the package. If other modules are needed, they will
automatically be included in the package.
You typically also want to use the -o flag to give the package a sensible name.
To install a package, use the command mhs -Q package-name.pkg [install-dir].
If the install-dir is left out, the package is installed in the default place.
Normally a package is downloaded from Hackage and it will have a .cabal file
that describes the package contents. To install a downloaded package, simply
do mcabal install. The mcabal program is included in the MicroHs download.
You can also do mcabal install PKG to download and install a package.
The packages are typically installed in ~/.mcabal/ and it has the following
layout:
-
.mcabal/bin/installed binaries, initiallymhs,cpphs, andmcabal -
.mcabal/mhs-VER/installed files for the givenmhsversion -
.mcabal/mhs-VER/packages/for each library package aPKG.pkgfile (the binary blob for the package) and also (maybe) a directoryPKG/that containsdata/,include/, andcbits/for the package. -
.mcabal/.../MODULE.txta file for each installed module, it contains the name of the package that contains that module.
For example, after installing mhs version 0.10.5.0 we will have something like this:
.mcabal/
bin/cpphs
mcabal
mhs
mhs-0.10.5.0/Control/Applicative.txt -- contains "base-0.10.5.0.pkg"
...
Monad/Fail.txt -- contains "base-0.10.5.0.pkg"
...
...
Data/
...
Prelude.txt -- contains "base-0.10.5.0.pkg"
packages/base-0.10.5.0.pkg
mhs-0.10.5.0/data/src/runtime/eval.c
...
A (maybe) short-coming of the package system is that there can only be one version of a
package installed at a time. If you need multiple versions, you have to use different directories for them
and use -a to control it. There are absolutely no checks for consistency among packages.
There is also no compatibility between packages compiled with different versions of the compiler.
Hackage is full of great packages, unfortunately most of them contain some GHC specific code. Some compile, most don't. Some have replacement, most don't. Here's a summary of the current state:
-
arraysome of the functionality -
basemost of what GHC has inbase -
bytestringsome of the functionality -
deepseqsome of the functionality -
directorysome of the functionality -
hashablea little of the functionality integer-logarithms-
processvery little of the functionality -
stmmost of the functionality -
textsome of the functionality
You can find the status for various packages. If a package is not in the list it just means that nobody has reported success of failure with the package. Please do so.