1 <?xml version="1.0" encoding="iso-8859-1"?>
6 <indexterm><primary>packages</primary></indexterm>
8 <para>A package is a library of Haskell modules known to the compiler. GHC
9 comes with several packages: see the accompanying
10 <ulink url="../libraries/index.html">library documentation</ulink>.</para>
12 <para>Using a package couldn't be simpler: if you're using
13 <option>--make</option> or GHCi, then most of the installed packages will be
14 automatically available to your program without any further options. The
15 exceptions to this rule are covered below in <xref
16 linkend="using-packages" />.</para>
18 <para>Building your own packages is also quite straightforward: we provide
19 the <ulink url="http://www.haskell.org/cabal/">Cabal</ulink> infrastructure which
20 automates the process of configuring, building, installing and distributing
21 a package. All you need to do is write a simple configuration file, put a
22 few files in the right places, and you have a package. See the
23 <ulink url="../Cabal/index.html">Cabal documentation</ulink>
24 for details, and also the Cabal libraries (<ulink url="../libraries/Cabal/Distribution-Simple.html">Distribution.Simple</ulink>,
27 <sect2 id="using-packages">
30 <indexterm><primary>packages</primary>
31 <secondary>using</secondary></indexterm>
33 <para>GHC only knows about packages that are <emphasis>installed</emphasis>.</para>
35 <para>An installed package is either <emphasis>exposed</emphasis> or <emphasis>hidden</emphasis>
36 by default. Command-line flags, described below, allow you to expose a hidden package
37 or hide an exposed one.
38 Only modules from exposed packages may be imported by your Haskell code; if
39 you try to import a module from a hidden package, GHC will emit an error
42 <para>The GHC command line options that control packages are:</para>
47 <option>-package <replaceable>P</replaceable></option>
48 <indexterm><primary><option>-package</option></primary></indexterm>
51 <para>This option causes the installed package <replaceable>P</replaceable> to be
52 exposed. The package <replaceable>P</replaceable> can be specified
53 in full with its version number
54 (e.g. <literal>network-1.0</literal>) or the version number can be
55 omitted if there is only one version of the package
58 <para>If there are multiple versions of <replaceable>P</replaceable>
59 installed, then all other versions will become hidden.</para>
61 <para>The <option>-package <replaceable>P</replaceable></option>
62 option also causes package <replaceable>P</replaceable> to be
63 linked into the resulting executable. In
64 <option>––make</option> mode and GHCi, the compiler
65 normally determines which packages are required by the current
66 Haskell modules, and links only those. In batch mode however, the
67 dependency information isn't available, and explicit
68 <option>-package</option> options must be given when linking.</para>
70 <para>For example, to link a program consisting of objects
71 <filename>Foo.o</filename> and <filename>Main.o</filename>, where
72 we made use of the <literal>network</literal> package, we need to
73 give GHC the <literal>-package</literal> flag thus:
75 <screen>$ ghc -o myprog Foo.o Main.o -package network</screen>
77 The same flag is necessary even if we compiled the modules from
78 source, because GHC still reckons it's in batch mode:
80 <screen>$ ghc -o myprog Foo.hs Main.hs -package network</screen>
82 In <literal>--make</literal> and <literal>--interactive</literal>
83 modes (<xref linkend="modes" />), however, GHC figures out the
84 packages required for linking without further assistance.</para>
86 <para>The one other time you might need to use
87 <option>-package</option> to force linking a package is when the
88 package does not contain any Haskell modules (it might contain a C
89 library only, for example). In that case, GHC
90 will never discover a dependency on it, so it has to be mentioned
96 <term><option>-hide-all-packages</option>
97 <indexterm><primary><option>-hide-package</option></primary>
100 <para>Ignore the exposed flag on installed packages, and hide them
101 all by default. If you use
102 this flag, then any packages you require (including
103 <literal>base</literal>) need to be explicitly exposed using
104 <option>-package</option> options.</para>
106 <para>This is a good way to insulate your program from
107 differences in the globally exposed packages, and being
108 explicit about package dependencies is a Good Thing.
109 Cabal always passes the
110 <option>-hide-all-packages</option> flag to GHC, for
111 exactly this reason.</para>
116 <term><option>-hide-package</option> <replaceable>P</replaceable>
117 <indexterm><primary><option>-hide-package</option></primary>
120 <para>This option does the opposite of <option>-package</option>: it
121 causes the specified package to be <firstterm>hidden</firstterm>,
122 which means that none of its modules will be available for import
123 by Haskell <literal>import</literal> directives.</para>
125 <para>Note that the package might still end up being linked into the
126 final program, if it is a dependency (direct or indirect) of
127 another exposed package.</para>
132 <term><option>-ignore-package</option> <replaceable>P</replaceable>
133 <indexterm><primary><option>-ignore-package</option></primary>
136 <para>Causes the compiler to behave as if package
137 <replaceable>P</replaceable>, and any packages that depend on
138 <literal>P</literal>, are not installed at all.</para>
140 <para>Saying <literal>-ignore-package P</literal> is the same as
141 giving <literal>-hide-package</literal> flags for
142 <literal>P</literal> and all the packages that depend on
143 <literal>P</literal>. Sometimes we don't know ahead of time which
144 packages will be installed that depend on <literal>P</literal>,
145 which is when the <literal>-ignore-package</literal> flag can be
151 <term><option>-package-name</option> <replaceable>foo</replaceable>
152 <indexterm><primary><option>-package-name</option></primary>
155 <para>Tells GHC the the module being compiled forms part of
156 package <replaceable>foo</replaceable>.
157 If this flag is omitted (a very common case) then the
158 default package <literal>main</literal> is assumed.</para>
159 <para>Note: the argument to <option>-package-name</option>
160 should be the full package identifier for the package,
161 that is it should include the version number. For example:
162 <literal>-package mypkg-1.2</literal>.</para>
168 <para>To see which packages are installed, use the
169 <literal>ghc-pkg</literal> command:</para>
173 /usr/lib/ghc-6.4/package.conf:
174 base-1.0, haskell98-1.0, template-haskell-1.0, mtl-1.0, unix-1.0,
175 Cabal-1.0, haskell-src-1.0, parsec-1.0, network-1.0,
176 QuickCheck-1.0, HUnit-1.1, fgl-1.0, X11-1.1, HGL-3.1, OpenGL-2.0,
177 GLUT-2.0, stm-1.0, readline-1.0, (lang-1.0), (concurrent-1.0),
178 (posix-1.0), (util-1.0), (data-1.0), (text-1.0), (net-1.0),
179 (hssource-1.0), rts-1.0
182 <para>Packages hidden by default are listed in
183 parentheses (eg. <literal>(lang-1.0)</literal>) in the output above.
184 To expose a package which is hidden by
185 default, use the <option>-package</option>
186 flag (see above).</para>
188 <para>When a package is exposed, it makes available for import the <emphasis>exposed modules</emphasis>
189 of the package. To see which modules are exposed by a package use the
190 <literal>ghc-pkg</literal> command (see <xref linkend="package-management"/>):</para>
193 $ ghc-pkg field network exposed-modules
194 exposed-modules: Network.BSD,
201 <para>In general, packages containing hierarchical modules are usually
202 exposed by default. However, it is possible for two packages to contain
203 the same module: in this case, only one of the packages should be
204 exposed. It is an error to import a module that belongs to more than one
205 exposed package.</para>
209 <sect2 id="package-main">
210 <title>The main package</title>
212 <para>Every complete Haskell program must define <literal>main</literal> in
213 module <literal>Main</literal>
214 in package <literal>main</literal>. (Omitting the <option>-package-name</option> flag compiles
215 code for package <literal>main</literal>.) Failure to do so leads to a somewhat obscure
216 link-time error of the form:
218 /usr/bin/ld: Undefined symbols:
226 <sect2 id="package-overlaps">
227 <title>Consequences of packages</title>
229 <para>It is possible that by using packages you might end up with
230 a program that contains two modules with the same name: perhaps
231 you used a package P that has a <emphasis>hidden</emphasis> module
232 M, and there is also a module M in your program. Or perhaps the
233 dependencies of packages that you used contain some overlapping
234 modules. Perhaps the program even contains multiple versions of a
235 certain package, due to dependencies from other packages.</para>
237 <para>None of these scenarios gives rise to an error on its
238 own<footnote><para>it used to in GHC 6.4, but not since
239 6.6</para></footnote>, but they may have some interesting
240 consequences. For instance, if you have a type
241 <literal>M.T</literal> from version 1 of package
242 <literal>P</literal>, then this is <emphasis>not</emphasis> the
243 same as the type <literal>M.T</literal> from version 2 of package
244 <literal>P</literal>, and GHC will report an error if you try to
245 use one where the other is expected.</para>
247 <para>Formally speaking, in Haskell 98, an entity (function, type
248 or class) in a program is uniquely identified by the pair of the
249 module name in which it is defined and its name. In GHC, an
250 entity is uniquely defined by a triple: package, module, and
254 <sect2 id="package-databases">
255 <title>Package Databases</title>
257 <para>A package database is a file, normally called
258 <literal>package.conf</literal> which contains descriptions of installed
259 packages. GHC usually knows about two package databases:</para>
263 <para>The global package database, which comes with your GHC
267 <para>A package database private to each user. On Unix
269 <filename>$HOME/.ghc/<replaceable>arch</replaceable>-<replaceable>os</replaceable>-<replaceable>version</replaceable>/package.conf</filename>, and on
270 Windows it will be something like
271 <filename>C:\Documents And Settings\<replaceable>user</replaceable>\ghc</filename>.
272 The <literal>ghc-pkg</literal> tool knows where this file should be
273 located, and will create it if it doesn't exist (see <xref linkend="package-management" />).</para>
277 <para>When GHC starts up, it reads the contents of these two package
278 databases, and builds up a list of the packages it knows about. You can
279 see GHC's package table by running GHC with the <option>-v</option>
282 <para>Package databases may overlap: for example, packages in the user
283 database will override those of the same name in the global
286 <para>You can control the loading of package databases using the following
292 <option>-package-conf <replaceable>file</replaceable></option>
293 <indexterm><primary><option>-package-conf</option></primary></indexterm>
296 <para>Read in the package configuration file
297 <replaceable>file</replaceable> in addition to the system
298 default file and the user's local file. Packages in additional
299 files read this way will override those in the global and user
305 <term><option>-no-user-package-conf</option>
306 <indexterm><primary><option>-no-user-package-conf</option></primary>
310 <para>Prevent loading of the user's local package database.</para>
315 <para>To create a new package database, just create
316 a new file and put the string
317 <quote><literal>[]</literal></quote> in it. Packages can be
318 added to the file using the
319 <literal>ghc-pkg</literal> tool, described in <xref
320 linkend="package-management"/>.</para>
322 <sect3 id="ghc-package-path">
323 <title>The <literal>GHC_PACKAGE_PATH</literal> environment variable</title>
324 <indexterm><primary>Environment variable</primary><secondary><literal>GHC_PACKAGE_PATH</literal></secondary>
326 <indexterm><primary><literal>GHC_PACKAGE_PATH</literal></primary></indexterm>
327 <para>The <literal>GHC_PACKAGE_PATH</literal> environment variable may be
328 set to a <literal>:</literal>-separated (<literal>;</literal>-separated
329 on Windows) list of files containing package databases. This list of
330 package databases is used by GHC and ghc-pkg, with earlier databases in
331 the list overriding later ones. This order was chosen to match the
332 behaviour of the <literal>PATH</literal> environment variable; think of
333 it as a list of package databases that are searched left-to-right for
336 <para>If <literal>GHC_PACKAGE_PATH</literal> ends in a separator, then
337 the default user and system package databases are appended, in that
338 order. e.g. to augment the usual set of packages with a database of
339 your own, you could say (on Unix):
341 $ export GHC_PACKAGE_PATH=$HOME/.my-ghc-packages.conf:</screen>
342 (use <literal>;</literal> instead of <literal>:</literal> on
345 <para>To check whether your <literal>GHC_PACKAGE_PATH</literal> setting
346 is doing the right thing, <literal>ghc-pkg list</literal> will list all
347 the databases in use, in the reverse order they are searched.</para>
352 <sect2 id="building-packages">
353 <title>Building a package from Haskell source</title>
354 <indexterm><primary>packages</primary>
355 <secondary>building</secondary></indexterm>
357 <para>We don't recommend building packages the hard way. Instead, use the
358 <ulink url="../Cabal/index.html">Cabal</ulink> infrastructure
359 if possible. If your package is particularly complicated or requires a
360 lot of configuration, then you might have to fall back to the low-level
361 mechanisms, so a few hints for those brave souls follow.</para>
365 <para>You need to build an "installed package info" file for
366 passing to <literal>ghc-pkg</literal> when installing your
367 package. The contents of this file are described in <xref
368 linkend="installed-pkg-info" />.</para>
372 <para>The Haskell code in a package may be built into one or
373 more archive libraries
374 (e.g. <filename>libHSfoo.a</filename>), or a single DLL on
375 Windows (e.g. <filename>HSfoo.dll</filename>). The
376 restriction to a single DLL on Windows is because the
377 package system is used to tell the compiler when it should
378 make an inter-DLL call rather than an intra-DLL call
379 (inter-DLL calls require an extra
380 indirection). <emphasis>Building packages as DLLs doesn't
381 work at the moment; see <xref linkend="win32-dlls-create"/>
382 for the gory details.</emphasis>
385 <para>Building a static library is done by using the
386 <literal>ar</literal> tool, like so:</para>
388 <screen>ar cqs libHSfoo.a A.o B.o C.o ...</screen>
390 <para>where <filename>A.o</filename>,
391 <filename>B.o</filename> and so on are the compiled Haskell
392 modules, and <filename>libHSfoo.a</filename> is the library
393 you wish to create. The syntax may differ slightly on your
394 system, so check the documentation if you run into
397 <para>Versions of the Haskell libraries for use with GHCi
398 may also be included: GHCi cannot load <literal>.a</literal>
399 files directly, instead it will look for an object file
400 called <filename>HSfoo.o</filename> and load that. On some
401 systems, the <literal>ghc-pkg</literal> tool can
402 automatically build the GHCi version of each library, see
403 <xref linkend="package-management"/>. To build these
404 libraries by hand from the <literal>.a</literal> archive, it
405 is possible to use GNU <command>ld</command> as
408 <screen>ld -r ––whole-archive -o HSfoo.o libHSfoo.a</screen>
411 <literal>––--whole-archive</literal> with
412 <literal>–all_load</literal> on MacOS X)</para>
414 <para>GHC does not maintain detailed cross-package
415 dependency information. It does remember which modules in
416 other packages the current module depends on, but not which
417 things within those imported things.</para>
421 <para>To compile a module which is to be part of a new package,
422 use the <literal>-package-name</literal> option (<xref linkend="using-packages"/>).
423 Failure to use the <literal>-package-name</literal> option
424 when compiling a package will probably result in disaster, but
425 you will only discover later when you attempt to import modules
426 from the package. At this point GHC will complain that the
427 package name it was expecting the module to come from is not the
428 same as the package name stored in the <literal>.hi</literal>
431 <para>It is worth noting that on Windows, when each package
432 is built as a DLL, since a reference to a DLL costs an extra
433 indirection, intra-package references are cheaper than
434 inter-package references. Of course, this applies to the
435 <filename>main</filename> package as well.</para>
438 <sect2 id="package-management">
439 <title>Package management (the <literal>ghc-pkg</literal> command)</title>
440 <indexterm><primary>packages</primary>
441 <secondary>management</secondary></indexterm>
443 <para>The <literal>ghc-pkg</literal> tool allows packages to be
444 added or removed from a package database. By default,
445 the system-wide package database is modified, but alternatively
446 the user's local package database or another specified
447 file can be used.</para>
449 <para>To see what package databases are in use, say
450 <literal>ghc-pkg list</literal>. The stack of databases that
451 <literal>ghc-pkg</literal> knows about can be modified using the
452 <literal>GHC_PACKAGE_PATH</literal> environment variable (see <xref
453 linkend="ghc-package-path" />, and using
454 <literal>--package-conf</literal> options on the
455 <literal>ghc-pkg</literal> command line.</para>
457 <para>When asked to modify a database, <literal>ghc-pkg</literal> modifies
458 the global database by default. Specifying <option>--user</option>
459 causes it to act on the user database, or <option>--package-conf</option>
460 can be used to act on another database entirely. When multiple of these
461 options are given, the rightmost one is used as the database to act
464 <para>If the environment variable <literal>GHC_PACKAGE_PATH</literal> is
465 set, and its value does not end in a separator (<literal>:</literal> on
466 Unix, <literal>;</literal> on Windows), then the last database is
467 considered to be the global database, and will be modified by default by
468 <literal>ghc-pkg</literal>. The intention here is that
469 <literal>GHC_PACKAGE_PATH</literal> can be used to create a virtual
470 package environment into which Cabal packages can be installed without
471 setting anything other than <literal>GHC_PACKAGE_PATH</literal>.</para>
473 <para>The <literal>ghc-pkg</literal> program may be run in the ways listed
474 below. Where a package name is required, the package can be named in
475 full including the version number
476 (e.g. <literal>network-1.0</literal>), or without the version number.
477 Naming a package without the version number matches all versions of the
478 package; the specified action will be applied to all the matching
479 packages. A package specifier that matches all version of the package
480 can also be written <replaceable>pkg</replaceable><literal>-*</literal>,
481 to make it clearer that multiple packages are being matched.</para>
485 <term><literal>ghc-pkg register <replaceable>file</replaceable></literal></term>
487 <para>Reads a package specification from
488 <replaceable>file</replaceable> (which may be “<literal>-</literal>”
489 to indicate standard input),
490 and adds it to the database of installed packages. The syntax of
491 <replaceable>file</replaceable> is given in <xref
492 linkend="installed-pkg-info" />.</para>
494 <para>The package specification must be a package that isn't already
500 <term><literal>ghc-pkg update <replaceable>file</replaceable></literal></term>
502 <para>The same as <literal>register</literal>, except that if a
503 package of the same name is already installed, it is
504 replaced by the new one.</para>
509 <term><literal>ghc-pkg unregister <replaceable>P</replaceable></literal></term>
511 <para>Remove the specified package from the database.</para>
516 <term><literal>ghc-pkg expose <replaceable>P</replaceable></literal></term>
518 <para>Sets the <literal>exposed</literal> flag for package
519 <replaceable>P</replaceable> to <literal>True</literal>.</para>
524 <term><literal>ghc-pkg hide <replaceable>P</replaceable></literal></term>
526 <para>Sets the <literal>exposed</literal> flag for package
527 <replaceable>P</replaceable> to <literal>False</literal>.</para>
532 <term><literal>ghc-pkg list [<replaceable>P</replaceable>] [<option>--simple-output</option>]</literal></term>
534 <para>This option displays the currently installed
535 packages, for each of the databases known to
536 <literal>ghc-pkg</literal>. That includes the global database, the
537 user's local database, and any further files specified using the
538 <option>-f</option> option on the command line.</para>
540 <para>Hidden packages (those for which the <literal>exposed</literal>
541 flag is <literal>False</literal>) are shown in parentheses in the
542 list of packages.</para>
544 <para>If an optional package identifier <replaceable>P</replaceable>
545 is given, then only packages matching that identifier are
548 <para>If the option <option>--simple-output</option> is given, then
549 the packages are listed on a single line separated by spaces, and
550 the database names are not included. This is intended to make it
551 easier to parse the output of <literal>ghc-pkg list</literal> using
557 <term><literal>ghc-pkg latest <replaceable>P</replaceable></literal></term>
559 <para>Prints the latest available version of package
560 <replaceable>P</replaceable>.</para>
565 <term><literal>ghc-pkg describe <replaceable>P</replaceable></literal></term>
567 <para>Emit the full description of the specified package. The
568 description is in the form of an
569 <literal>InstalledPackageInfo</literal>, the same as the input file
570 format for <literal>ghc-pkg register</literal>. See <xref
571 linkend="installed-pkg-info" /> for details.</para>
576 <term><literal>ghc-pkg field <replaceable>P</replaceable> <replaceable>field</replaceable></literal></term>
578 <para>Show just a single field of the installed package description
579 for <literal>P</literal>.</para>
584 <para>Additionally, the following flags are accepted by
585 <literal>ghc-pkg</literal>:</para>
590 <option>––auto-ghci-libs</option><indexterm><primary><option>––auto-ghci-libs</option></primary>
594 <para>Automatically generate the GHCi
595 <filename>.o</filename> version of each
596 <filename>.a</filename> Haskell library, using GNU ld (if
597 that is available). Without this option,
598 <literal>ghc-pkg</literal> will warn if GHCi versions of
599 any Haskell libraries in the package don't exist.</para>
601 <para>GHCi <literal>.o</literal> libraries don't
602 necessarily have to live in the same directory as the
603 corresponding <literal>.a</literal> library. However,
604 this option will cause the GHCi library to be created in
605 the same directory as the <literal>.a</literal>
612 <option>-f</option> <replaceable>file</replaceable>
613 <indexterm><primary><option>-f</option></primary>
617 <option>-package-conf</option> <replaceable>file</replaceable>
618 <indexterm><primary><option>-package-conf</option></primary>
622 <para>Adds <replaceable>file</replaceable> to the stack of package
623 databases. Additionally, <replaceable>file</replaceable> will
624 also be the database modified by a <literal>register</literal>,
625 <literal>unregister</literal>, <literal>expose</literal> or
626 <literal>hide</literal> command, unless it is overriden by a later
627 <option>--package-conf</option>, <option>--user</option> or
628 <option>--global</option> option.</para>
634 <option>––force</option>
636 <option>––force</option>
637 </primary></indexterm>
640 <para>Causes <literal>ghc-pkg</literal> to ignore missing
641 dependencies, directories and libraries when registering a package,
642 and just go ahead and add it anyway. This might be useful if your
643 package installation system needs to add the package to
644 GHC before building and installing the files.</para>
650 <option>––global</option><indexterm><primary><option>––global</option></primary>
654 <para>Operate on the global package database (this is the default).
655 This flag affects the <literal>register</literal>,
656 <literal>update</literal>, <literal>unregister</literal>,
657 <literal>expose</literal>, and <literal>hide</literal>
664 <option>––help</option><indexterm><primary><option>––help</option></primary>
668 <option>-?</option><indexterm><primary><option>-?</option></primary>
672 <para>Outputs the command-line syntax.</para>
678 <option>––user</option><indexterm><primary><option>––user</option></primary>
682 <para>Operate on the current user's local package database.
683 This flag affects the <literal>register</literal>,
684 <literal>update</literal>, <literal>unregister</literal>,
685 <literal>expose</literal>, and <literal>hide</literal>
692 <option>-V</option><indexterm><primary><option>-V</option></primary>
696 <option>––version</option><indexterm><primary><option>––version</option></primary>
700 <para>Output the <literal>ghc-pkg</literal> version number.</para>
705 <para>When modifying the package database
706 <replaceable>file</replaceable>, a copy of the original file is
707 saved in <replaceable>file</replaceable><literal>.old</literal>,
708 so in an emergency you can always restore the old settings by
709 copying the old file back again.</para>
713 <sect2 id="installed-pkg-info">
715 <literal>InstalledPackageInfo</literal>: a package specification
718 <para>A package specification is a Haskell record; in particular, it is the
720 url="../libraries/Cabal/Distribution-InstalledPackageInfo.html#%tInstalledPackageInfo">InstalledPackageInfo</ulink> in the module Distribution.InstalledPackageInfo, which is part of the Cabal package distributed with GHC.</para>
722 <para>An <literal>InstalledPackageInfo</literal> has a human
723 readable/writable syntax. The functions
724 <literal>parseInstalledPackageInfo</literal> and
725 <literal>showInstalledPackageInfo</literal> read and write this syntax
726 respectively. Here's an example of the
727 <literal>InstalledPackageInfo</literal> for the <literal>unix</literal> package:</para>
730 $ ghc-pkg describe unix
735 maintainer: libraries@haskell.org
743 exposed-modules: System.Posix,
744 System.Posix.DynamicLinker.Module,
745 System.Posix.DynamicLinker.Prim,
746 System.Posix.Directory,
747 System.Posix.DynamicLinker,
752 System.Posix.Process,
753 System.Posix.Resource,
755 System.Posix.Terminal,
759 System.Posix.Signals.Exts
760 import-dirs: /usr/lib/ghc-6.4/libraries/unix
761 library-dirs: /usr/lib/ghc-6.4/libraries/unix
763 extra-libraries: HSunix_cbits, dl
764 include-dirs: /usr/lib/ghc-6.4/libraries/unix/include
769 <para>The full <ulink url="../Cabal/index.html">Cabal documentation</ulink>
770 is still in preparation (at time of writing), so in the meantime
771 here is a brief description of the syntax of this file:</para>
773 <para>A package description consists of a number of field/value pairs. A
774 field starts with the field name in the left-hand column followed by a
775 “<literal>:</literal>”, and the value continues until the next line that begins in the
776 left-hand column, or the end of file.</para>
778 <para>The syntax of the value depends on the field. The various field
783 <term>freeform</term>
785 <para>Any arbitrary string, no interpretation or parsing is
792 <para>A sequence of non-space characters, or a sequence of arbitrary
793 characters surrounded by quotes <literal>"...."</literal>.</para>
797 <term>string list</term>
799 <para>A sequence of strings, separated by commas. The sequence may
805 <para>In addition, there are some fields with special syntax (e.g. package
806 names, version, dependencies).</para>
808 <para>The allowed fields, with their types, are:</para>
813 <literal>name</literal>
814 <indexterm><primary><literal>name</literal></primary><secondary>package specification</secondary></indexterm>
817 <para>The package's name (without the version).</para>
823 <literal>version</literal>
824 <indexterm><primary><literal>version</literal></primary><secondary>package specification</secondary></indexterm>
827 <para>The package's version, usually in the form
828 <literal>A.B</literal> (any number of components are allowed).</para>
834 <literal>license</literal>
835 <indexterm><primary><literal>auto</literal></primary><secondary>package specification</secondary></indexterm>
838 <para>(string) The type of license under which this package is distributed.
839 This field is a value of the <ulink
840 url="../libraries/Cabal/Distribution-License.html#t:License"><literal>License</literal></ulink> type.</para>
846 <literal>license-file</literal>
847 <indexterm><primary><literal>license-file</literal></primary><secondary>package specification</secondary></indexterm>
850 <para>(optional string) The name of a file giving detailed license
851 information for this package.</para>
857 <literal>copyright</literal>
858 <indexterm><primary><literal>copyright</literal></primary><secondary>package specification</secondary></indexterm>
861 <para>(optional freeform) The copyright string.</para>
867 <literal>maintainer</literal>
868 <indexterm><primary><literal>maintainer</literal></primary><secondary>package specification</secondary></indexterm>
871 <para>(optinoal freeform) The email address of the package's maintainer.</para>
877 <literal>stability</literal>
878 <indexterm><primary><literal>stability</literal></primary><secondary>package specification</secondary></indexterm>
881 <para>(optional freeform) A string describing the stability of the package
882 (eg. stable, provisional or experimental).</para>
888 <literal>homepage</literal>
889 <indexterm><primary><literal>homepage</literal></primary><secondary>package specification</secondary></indexterm>
892 <para>(optional freeform) URL of the package's home page.</para>
898 <literal>package-url</literal>
899 <indexterm><primary><literal>package-url</literal></primary><secondary>package specification</secondary></indexterm>
902 <para>(optional freeform) URL of a downloadable distribution for this
903 package. The distribution should be a Cabal package.</para>
909 <literal>description</literal>
910 <indexterm><primary><literal>description</literal></primary><secondary>package specification</secondary></indexterm>
913 <para>(optional freeform) Description of the package.</para>
919 <literal>category</literal>
920 <indexterm><primary><literal>category</literal></primary><secondary>package specification</secondary></indexterm>
923 <para>(optinoal freeform) Which category the package belongs to. This field
924 is for use in conjunction with a future centralised package
925 distribution framework, tentatively titled Hackage.</para>
931 <literal>author</literal>
932 <indexterm><primary><literal>author</literal></primary><secondary>package specification</secondary></indexterm>
935 <para>(optional freeform) Author of the package.</para>
941 <literal>exposed</literal>
942 <indexterm><primary><literal>exposed</literal></primary><secondary>package specification</secondary></indexterm>
945 <para>(bool) Whether the package is exposed or not.</para>
951 <literal>exposed-modules</literal>
952 <indexterm><primary><literal>exposed-modules</literal></primary><secondary>package specification</secondary></indexterm>
955 <para>(string list) modules exposed by this package.</para>
961 <literal>hidden-modules</literal>
962 <indexterm><primary><literal>hidden-modules</literal></primary><secondary>package specification</secondary></indexterm>
965 <para>(string list) modules provided by this package,
966 but not exposed to the programmer. These modules cannot be
967 imported, but they are still subject to the overlapping constraint:
968 no other package in the same program may provide a module of the
975 <literal>import-dirs</literal>
976 <indexterm><primary><literal>import-dirs</literal></primary><secondary>package specification</secondary></indexterm>
979 <para>(string list) A list of directories containing interface files
980 (<literal>.hi</literal> files) for this package.</para>
982 <para>If the package contains profiling libraries, then
983 the interface files for those library modules should have
984 the suffix <literal>.p_hi</literal>. So the package can
985 contain both normal and profiling versions of the same
986 library without conflict (see also
987 <literal>library_dirs</literal> below).</para>
993 <literal>library-dirs</literal>
994 <indexterm><primary><literal>library-dirs</literal></primary><secondary>package specification</secondary></indexterm>
997 <para>(string list) A list of directories containing libraries for this
1004 <literal>hs-libraries</literal>
1005 <indexterm><primary><literal>hs-libraries</literal></primary><secondary>package specification</secondary></indexterm>
1008 <para>(string list) A list of libraries containing Haskell code for this
1009 package, with the <literal>.a</literal> or
1010 <literal>.dll</literal> suffix omitted. When packages are
1011 built as libraries, the
1012 <literal>lib</literal> prefix is also omitted.</para>
1014 <para>For use with GHCi, each library should have an
1015 object file too. The name of the object file does
1016 <emphasis>not</emphasis> have a <literal>lib</literal>
1017 prefix, and has the normal object suffix for your
1020 <para>For example, if we specify a Haskell library as
1021 <filename>HSfoo</filename> in the package spec, then the
1022 various flavours of library that GHC actually uses will be
1026 <term><filename>libHSfoo.a</filename></term>
1028 <para>The name of the library on Unix and Windows
1029 (mingw) systems. Note that we don't support
1030 building dynamic libraries of Haskell code on Unix
1035 <term><filename>HSfoo.dll</filename></term>
1037 <para>The name of the dynamic library on Windows
1038 systems (optional).</para>
1042 <term><filename>HSfoo.o</filename></term>
1043 <term><filename>HSfoo.obj</filename></term>
1045 <para>The object version of the library used by
1055 <literal>extra-libraries</literal>
1056 <indexterm><primary><literal>extra-libraries</literal></primary><secondary>package specification</secondary></indexterm>
1059 <para>(string list) A list of extra libraries for this package. The
1060 difference between <literal>hs-libraries</literal> and
1061 <literal>extra-libraries</literal> is that
1062 <literal>hs-libraries</literal> normally have several
1063 versions, to support profiling, parallel and other build
1064 options. The various versions are given different
1065 suffixes to distinguish them, for example the profiling
1066 version of the standard prelude library is named
1067 <filename>libHSbase_p.a</filename>, with the
1068 <literal>_p</literal> indicating that this is a profiling
1069 version. The suffix is added automatically by GHC for
1070 <literal>hs-libraries</literal> only, no suffix is added
1072 <literal>extra-libraries</literal>.</para>
1074 <para>The libraries listed in
1075 <literal>extra-libraries</literal> may be any libraries
1076 supported by your system's linker, including dynamic
1077 libraries (<literal>.so</literal> on Unix,
1078 <literal>.DLL</literal> on Windows).</para>
1080 <para>Also, <literal>extra-libraries</literal> are placed
1081 on the linker command line after the
1082 <literal>hs-libraries</literal> for the same package. If
1083 your package has dependencies in the other direction (i.e.
1084 <literal>extra-libraries</literal> depends on
1085 <literal>hs-libraries</literal>), and the libraries are
1086 static, you might need to make two separate
1093 <literal>include-dirs</literal>
1094 <indexterm><primary><literal>include-dirs</literal></primary><secondary>package specification</secondary></indexterm>
1097 <para>(string list) A list of directories containing C includes for this
1104 <literal>includes</literal>
1105 <indexterm><primary><literal>includes</literal></primary><secondary>package specification</secondary></indexterm>
1108 <para>(string list) A list of files to include for via-C compilations
1109 using this package. Typically the include file(s) will
1110 contain function prototypes for any C functions used in
1111 the package, in case they end up being called as a result
1112 of Haskell functions from the package being
1119 <literal>depends</literal>
1120 <indexterm><primary><literal>depends</literal></primary><secondary>package specification</secondary></indexterm>
1123 <para>(package name list) Packages on which this package depends. This field contains
1124 packages with explicit versions are required, except that when
1125 submitting a package to <literal>ghc-pkg register</literal>, the
1126 versions will be filled in if they are unambiguous.</para>
1132 <literal>hugs-options</literal>
1133 <indexterm><primary><literal>hugs-options</literal></primary><secondary>package specification</secondary></indexterm>
1136 <para>(string list) Options to pass to Hugs for this package.</para>
1142 <literal>cc-options</literal>
1143 <indexterm><primary><literal>cc-options</literal></primary><secondary>package specification</secondary></indexterm>
1146 <para>(string list) Extra arguments to be added to the gcc command line
1147 when this package is being used (only for via-C
1148 compilations).</para>
1154 <literal>ld-options</literal>
1155 <indexterm><primary><literal>ld-options</literal></primary><secondary>package specification</secondary></indexterm>
1158 <para>(string list) Extra arguments to be added to the
1159 <command>gcc</command> command line (for linking) when
1160 this package is being used.</para>
1166 <literal>framework-dirs</literal>
1167 <indexterm><primary><literal>framework-dirs</literal></primary><secondary>package specification</secondary></indexterm>
1170 <para>(string list) On Darwin/MacOS X, a list of directories containing
1171 frameworks for this package. This corresponds to the
1172 <option>-framework-path</option> option. It is ignored on all other
1179 <literal>frameworks</literal>
1180 <indexterm><primary><literal>frameworks</literal></primary><secondary>package specification</secondary></indexterm>
1183 <para>(string list) On Darwin/MacOS X, a list of frameworks to link to. This
1184 corresponds to the <option>-framework</option> option. Take a look
1185 at Apple's developer documentation to find out what frameworks
1186 actually are. This entry is ignored on all other platforms.</para>
1192 <literal>haddock-interfaces</literal>
1193 <indexterm><primary><literal>haddock-interfaces</literal></primary><secondary>package specification</secondary></indexterm>
1196 <para>(string list) A list of filenames containing <ulink
1197 url="http://www.haskell.org/haddock/">Haddock</ulink> interface
1198 files (<literal>.haddock</literal> files) for this package.</para>
1204 <literal>haddock-html</literal>
1205 <indexterm><primary><literal>haddock-html</literal></primary><secondary>package specification</secondary></indexterm>
1208 <para>(optional string) The directory containing the Haddock-generated HTML
1209 for this package.</para>
1214 <!-- This isn't true any more. I'm not sure if we still need it -SDM
1216 The <literal>ghc-pkg</literal> tool performs expansion of
1217 environment variables occurring in input package specifications.
1218 So, if the <literal>mypkg</literal> was added to the package
1219 database as follows:
1222 $ installdir=/usr/local/lib ghc-pkg -a < mypkg.pkg
1226 The occurrence of <literal>${installdir}</literal> is replaced
1227 with <literal>/usr/local/lib</literal> in the package data that
1228 is added for <literal>mypkg</literal>.
1232 This feature enables the distribution of package specification
1233 files that can be easily configured when installing.
1236 <para>For examples of more package specifications, take a look
1237 at the <literal>package.conf</literal> in your GHC
1238 installation.</para>
1246 ;;; Local Variables: ***
1248 ;;; sgml-parent-document: ("users_guide.xml" "book" "chapter" "sect1") ***