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
34 <emphasis>installed</emphasis>. To see which packages are installed, use
35 the <literal>ghc-pkg</literal> command:</para>
39 /usr/lib/ghc-6.4/package.conf:
40 base-1.0, haskell98-1.0, template-haskell-1.0, mtl-1.0, unix-1.0,
41 Cabal-1.0, haskell-src-1.0, parsec-1.0, network-1.0,
42 QuickCheck-1.0, HUnit-1.1, fgl-1.0, X11-1.1, HGL-3.1, OpenGL-2.0,
43 GLUT-2.0, stm-1.0, readline-1.0, (lang-1.0), (concurrent-1.0),
44 (posix-1.0), (util-1.0), (data-1.0), (text-1.0), (net-1.0),
45 (hssource-1.0), rts-1.0
48 <para>An installed package is either <emphasis>exposed</emphasis> or <emphasis>hidden</emphasis>
49 by default. Packages hidden by default are listed in
50 parentheses (eg. <literal>(lang-1.0)</literal>) in the output above. Command-line flags, described below, allow you to expose a hidden package
51 or hide an exposed one.
52 Only modules from exposed packages may be imported by your Haskell code; if
53 you try to import a module from a hidden package, GHC will emit an error
56 <para>To see which modules are provided by a package use the
57 <literal>ghc-pkg</literal> command (see <xref linkend="package-management"/>):</para>
60 $ ghc-pkg field network exposed-modules
61 exposed-modules: Network.BSD,
68 <para>The GHC command line options that control packages are:</para>
73 <option>-package <replaceable>P</replaceable></option>
74 <indexterm><primary><option>-package</option></primary></indexterm>
77 <para>This option causes the installed package <replaceable>P</replaceable> to be
78 exposed. The package <replaceable>P</replaceable> can be specified
79 in full with its version number
80 (e.g. <literal>network-1.0</literal>) or the version number can be
81 omitted if there is only one version of the package
84 <para>If there are multiple versions of <replaceable>P</replaceable>
85 installed, then all other versions will become hidden.</para>
87 <para>The <option>-package <replaceable>P</replaceable></option>
88 option also causes package <replaceable>P</replaceable> to be
89 linked into the resulting executable. In
90 <option>––make</option> mode and GHCi, the compiler
91 normally determines which packages are required by the current
92 Haskell modules, and links only those. In batch mode however, the
93 dependency information isn't available, and explicit
94 <option>-package</option> options must be given when linking.</para>
96 <para>For example, to link a program consisting of objects
97 <filename>Foo.o</filename> and <filename>Main.o</filename>, where
98 we made use of the <literal>network</literal> package, we need to
99 give GHC the <literal>-package</literal> flag thus:
101 <screen>$ ghc -o myprog Foo.o Main.o -package network</screen>
103 The same flag is necessary even if we compiled the modules from
104 source, because GHC still reckons it's in batch mode:
106 <screen>$ ghc -o myprog Foo.hs Main.hs -package network</screen>
108 In <literal>--make</literal> and <literal>--interactive</literal>
109 modes (<xref linkend="modes" />), however, GHC figures out the
110 packages required for linking without further assistance.</para>
112 <para>The one other time you might need to use
113 <option>-package</option> to force linking a package is when the
114 package does not contain any Haskell modules (it might contain a C
115 library only, for example). In that case, GHC
116 will never discover a dependency on it, so it has to be mentioned
122 <term><option>-hide-all-packages</option>
123 <indexterm><primary><option>-hide-package</option></primary>
126 <para>Ignore the exposed flag on installed packages, and hide them
127 all by default. If you use
128 this flag, then any packages you require (including
129 <literal>base</literal>) need to be explicitly exposed using
130 <option>-package</option> options.</para>
132 <para>This is a good way to insulate your program from
133 differences in the globally exposed packages, and being
134 explicit about package dependencies is a Good Thing.
135 Cabal always passes the
136 <option>-hide-all-packages</option> flag to GHC, for
137 exactly this reason.</para>
142 <term><option>-hide-package</option> <replaceable>P</replaceable>
143 <indexterm><primary><option>-hide-package</option></primary>
146 <para>This option does the opposite of <option>-package</option>: it
147 causes the specified package to be <firstterm>hidden</firstterm>,
148 which means that none of its modules will be available for import
149 by Haskell <literal>import</literal> directives.</para>
151 <para>Note that the package might still end up being linked into the
152 final program, if it is a dependency (direct or indirect) of
153 another exposed package.</para>
158 <term><option>-ignore-package</option> <replaceable>P</replaceable>
159 <indexterm><primary><option>-ignore-package</option></primary>
162 <para>Causes the compiler to behave as if package
163 <replaceable>P</replaceable>, and any packages that depend on
164 <literal>P</literal>, are not installed at all.</para>
166 <para>Saying <literal>-ignore-package P</literal> is the same as
167 giving <literal>-hide-package</literal> flags for
168 <literal>P</literal> and all the packages that depend on
169 <literal>P</literal>. Sometimes we don't know ahead of time which
170 packages will be installed that depend on <literal>P</literal>,
171 which is when the <literal>-ignore-package</literal> flag can be
177 <term><option>-package-name</option> <replaceable>foo</replaceable>
178 <indexterm><primary><option>-package-name</option></primary>
181 <para>Tells GHC the the module being compiled forms part of
182 package <replaceable>foo</replaceable>.
183 If this flag is omitted (a very common case) then the
184 default package <literal>main</literal> is assumed.</para>
185 <para>Note: the argument to <option>-package-name</option>
186 should be the full package identifier for the package,
187 that is it should include the version number. For example:
188 <literal>-package mypkg-1.2</literal>.</para>
194 <sect2 id="package-main">
195 <title>The main package</title>
197 <para>Every complete Haskell program must define <literal>main</literal> in
198 module <literal>Main</literal>
199 in package <literal>main</literal>. (Omitting the <option>-package-name</option> flag compiles
200 code for package <literal>main</literal>.) Failure to do so leads to a somewhat obscure
201 link-time error of the form:
203 /usr/bin/ld: Undefined symbols:
211 <sect2 id="package-overlaps">
212 <title>Consequences of packages</title>
214 <para>It is possible that by using packages you might end up with
215 a program that contains two modules with the same name: perhaps
216 you used a package P that has a <emphasis>hidden</emphasis> module
217 M, and there is also a module M in your program. Or perhaps the
218 dependencies of packages that you used contain some overlapping
219 modules. Perhaps the program even contains multiple versions of a
220 certain package, due to dependencies from other packages.</para>
222 <para>None of these scenarios gives rise to an error on its
223 own<footnote><para>it used to in GHC 6.4, but not since
224 6.6</para></footnote>, but they may have some interesting
225 consequences. For instance, if you have a type
226 <literal>M.T</literal> from version 1 of package
227 <literal>P</literal>, then this is <emphasis>not</emphasis> the
228 same as the type <literal>M.T</literal> from version 2 of package
229 <literal>P</literal>, and GHC will report an error if you try to
230 use one where the other is expected.</para>
232 <para>Formally speaking, in Haskell 98, an entity (function, type
233 or class) in a program is uniquely identified by the pair of the
234 module name in which it is defined and its name. In GHC, an
235 entity is uniquely defined by a triple: package, module, and
239 <sect2 id="package-databases">
240 <title>Package Databases</title>
242 <para>A package database is a file, normally called
243 <literal>package.conf</literal> which contains descriptions of installed
244 packages. GHC usually knows about two package databases:</para>
248 <para>The global package database, which comes with your GHC
252 <para>A package database private to each user. On Unix
254 <filename>$HOME/.ghc/<replaceable>arch</replaceable>-<replaceable>os</replaceable>-<replaceable>version</replaceable>/package.conf</filename>, and on
255 Windows it will be something like
256 <filename>C:\Documents And Settings\<replaceable>user</replaceable>\ghc</filename>.
257 The <literal>ghc-pkg</literal> tool knows where this file should be
258 located, and will create it if it doesn't exist (see <xref linkend="package-management" />).</para>
262 <para>When GHC starts up, it reads the contents of these two package
263 databases, and builds up a list of the packages it knows about. You can
264 see GHC's package table by running GHC with the <option>-v</option>
267 <para>Package databases may overlap: for example, packages in the user
268 database will override those of the same name in the global
271 <para>You can control the loading of package databases using the following
277 <option>-package-conf <replaceable>file</replaceable></option>
278 <indexterm><primary><option>-package-conf</option></primary></indexterm>
281 <para>Read in the package configuration file
282 <replaceable>file</replaceable> in addition to the system
283 default file and the user's local file. Packages in additional
284 files read this way will override those in the global and user
290 <term><option>-no-user-package-conf</option>
291 <indexterm><primary><option>-no-user-package-conf</option></primary>
295 <para>Prevent loading of the user's local package database.</para>
300 <para>To create a new package database, just create
301 a new file and put the string
302 <quote><literal>[]</literal></quote> in it. Packages can be
303 added to the file using the
304 <literal>ghc-pkg</literal> tool, described in <xref
305 linkend="package-management"/>.</para>
307 <sect3 id="ghc-package-path">
308 <title>The <literal>GHC_PACKAGE_PATH</literal> environment variable</title>
309 <indexterm><primary>Environment variable</primary><secondary><literal>GHC_PACKAGE_PATH</literal></secondary>
311 <indexterm><primary><literal>GHC_PACKAGE_PATH</literal></primary></indexterm>
312 <para>The <literal>GHC_PACKAGE_PATH</literal> environment variable may be
313 set to a <literal>:</literal>-separated (<literal>;</literal>-separated
314 on Windows) list of files containing package databases. This list of
315 package databases is used by GHC and ghc-pkg, with earlier databases in
316 the list overriding later ones. This order was chosen to match the
317 behaviour of the <literal>PATH</literal> environment variable; think of
318 it as a list of package databases that are searched left-to-right for
321 <para>If <literal>GHC_PACKAGE_PATH</literal> ends in a separator, then
322 the default user and system package databases are appended, in that
323 order. e.g. to augment the usual set of packages with a database of
324 your own, you could say (on Unix):
326 $ export GHC_PACKAGE_PATH=$HOME/.my-ghc-packages.conf:</screen>
327 (use <literal>;</literal> instead of <literal>:</literal> on
330 <para>To check whether your <literal>GHC_PACKAGE_PATH</literal> setting
331 is doing the right thing, <literal>ghc-pkg list</literal> will list all
332 the databases in use, in the reverse order they are searched.</para>
337 <sect2 id="building-packages">
338 <title>Building a package from Haskell source</title>
339 <indexterm><primary>packages</primary>
340 <secondary>building</secondary></indexterm>
342 <para>We don't recommend building packages the hard way. Instead, use the
343 <ulink url="../Cabal/index.html">Cabal</ulink> infrastructure
344 if possible. If your package is particularly complicated or requires a
345 lot of configuration, then you might have to fall back to the low-level
346 mechanisms, so a few hints for those brave souls follow.</para>
350 <para>You need to build an "installed package info" file for
351 passing to <literal>ghc-pkg</literal> when installing your
352 package. The contents of this file are described in <xref
353 linkend="installed-pkg-info" />.</para>
357 <para>The Haskell code in a package may be built into one or
358 more archive libraries
359 (e.g. <filename>libHSfoo.a</filename>), or a single DLL on
360 Windows (e.g. <filename>HSfoo.dll</filename>). The
361 restriction to a single DLL on Windows is because the
362 package system is used to tell the compiler when it should
363 make an inter-DLL call rather than an intra-DLL call
364 (inter-DLL calls require an extra
365 indirection). <emphasis>Building packages as DLLs doesn't
366 work at the moment; see <xref linkend="win32-dlls-create"/>
367 for the gory details.</emphasis>
370 <para>Building a static library is done by using the
371 <literal>ar</literal> tool, like so:</para>
373 <screen>ar cqs libHSfoo.a A.o B.o C.o ...</screen>
375 <para>where <filename>A.o</filename>,
376 <filename>B.o</filename> and so on are the compiled Haskell
377 modules, and <filename>libHSfoo.a</filename> is the library
378 you wish to create. The syntax may differ slightly on your
379 system, so check the documentation if you run into
382 <para>Versions of the Haskell libraries for use with GHCi
383 may also be included: GHCi cannot load <literal>.a</literal>
384 files directly, instead it will look for an object file
385 called <filename>HSfoo.o</filename> and load that. On some
386 systems, the <literal>ghc-pkg</literal> tool can
387 automatically build the GHCi version of each library, see
388 <xref linkend="package-management"/>. To build these
389 libraries by hand from the <literal>.a</literal> archive, it
390 is possible to use GNU <command>ld</command> as
393 <screen>ld -r ––whole-archive -o HSfoo.o libHSfoo.a</screen>
396 <literal>––--whole-archive</literal> with
397 <literal>–all_load</literal> on MacOS X)</para>
399 <para>GHC does not maintain detailed cross-package
400 dependency information. It does remember which modules in
401 other packages the current module depends on, but not which
402 things within those imported things.</para>
406 <para>To compile a module which is to be part of a new package,
407 use the <literal>-package-name</literal> option (<xref linkend="using-packages"/>).
408 Failure to use the <literal>-package-name</literal> option
409 when compiling a package will probably result in disaster, but
410 you will only discover later when you attempt to import modules
411 from the package. At this point GHC will complain that the
412 package name it was expecting the module to come from is not the
413 same as the package name stored in the <literal>.hi</literal>
416 <para>It is worth noting that on Windows, when each package
417 is built as a DLL, since a reference to a DLL costs an extra
418 indirection, intra-package references are cheaper than
419 inter-package references. Of course, this applies to the
420 <filename>main</filename> package as well.</para>
423 <sect2 id="package-management">
424 <title>Package management (the <literal>ghc-pkg</literal> command)</title>
425 <indexterm><primary>packages</primary>
426 <secondary>management</secondary></indexterm>
428 <para>The <literal>ghc-pkg</literal> tool allows packages to be
429 added or removed from a package database. By default,
430 the system-wide package database is modified, but alternatively
431 the user's local package database or another specified
432 file can be used.</para>
434 <para>To see what package databases are in use, say
435 <literal>ghc-pkg list</literal>. The stack of databases that
436 <literal>ghc-pkg</literal> knows about can be modified using the
437 <literal>GHC_PACKAGE_PATH</literal> environment variable (see <xref
438 linkend="ghc-package-path" />, and using
439 <literal>--package-conf</literal> options on the
440 <literal>ghc-pkg</literal> command line.</para>
442 <para>When asked to modify a database, <literal>ghc-pkg</literal> modifies
443 the global database by default. Specifying <option>--user</option>
444 causes it to act on the user database, or <option>--package-conf</option>
445 can be used to act on another database entirely. When multiple of these
446 options are given, the rightmost one is used as the database to act
449 <para>If the environment variable <literal>GHC_PACKAGE_PATH</literal> is
450 set, and its value does not end in a separator (<literal>:</literal> on
451 Unix, <literal>;</literal> on Windows), then the last database is
452 considered to be the global database, and will be modified by default by
453 <literal>ghc-pkg</literal>. The intention here is that
454 <literal>GHC_PACKAGE_PATH</literal> can be used to create a virtual
455 package environment into which Cabal packages can be installed without
456 setting anything other than <literal>GHC_PACKAGE_PATH</literal>.</para>
458 <para>The <literal>ghc-pkg</literal> program may be run in the ways listed
459 below. Where a package name is required, the package can be named in
460 full including the version number
461 (e.g. <literal>network-1.0</literal>), or without the version number.
462 Naming a package without the version number matches all versions of the
463 package; the specified action will be applied to all the matching
464 packages. A package specifier that matches all version of the package
465 can also be written <replaceable>pkg</replaceable><literal>-*</literal>,
466 to make it clearer that multiple packages are being matched.</para>
470 <term><literal>ghc-pkg register <replaceable>file</replaceable></literal></term>
472 <para>Reads a package specification from
473 <replaceable>file</replaceable> (which may be “<literal>-</literal>”
474 to indicate standard input),
475 and adds it to the database of installed packages. The syntax of
476 <replaceable>file</replaceable> is given in <xref
477 linkend="installed-pkg-info" />.</para>
479 <para>The package specification must be a package that isn't already
485 <term><literal>ghc-pkg update <replaceable>file</replaceable></literal></term>
487 <para>The same as <literal>register</literal>, except that if a
488 package of the same name is already installed, it is
489 replaced by the new one.</para>
494 <term><literal>ghc-pkg unregister <replaceable>P</replaceable></literal></term>
496 <para>Remove the specified package from the database.</para>
501 <term><literal>ghc-pkg expose <replaceable>P</replaceable></literal></term>
503 <para>Sets the <literal>exposed</literal> flag for package
504 <replaceable>P</replaceable> to <literal>True</literal>.</para>
509 <term><literal>ghc-pkg hide <replaceable>P</replaceable></literal></term>
511 <para>Sets the <literal>exposed</literal> flag for package
512 <replaceable>P</replaceable> to <literal>False</literal>.</para>
517 <term><literal>ghc-pkg list [<replaceable>P</replaceable>] [<option>--simple-output</option>]</literal></term>
519 <para>This option displays the currently installed
520 packages, for each of the databases known to
521 <literal>ghc-pkg</literal>. That includes the global database, the
522 user's local database, and any further files specified using the
523 <option>-f</option> option on the command line.</para>
525 <para>Hidden packages (those for which the <literal>exposed</literal>
526 flag is <literal>False</literal>) are shown in parentheses in the
527 list of packages.</para>
529 <para>If an optional package identifier <replaceable>P</replaceable>
530 is given, then only packages matching that identifier are
533 <para>If the option <option>--simple-output</option> is given, then
534 the packages are listed on a single line separated by spaces, and
535 the database names are not included. This is intended to make it
536 easier to parse the output of <literal>ghc-pkg list</literal> using
542 <term><literal>ghc-pkg latest <replaceable>P</replaceable></literal></term>
544 <para>Prints the latest available version of package
545 <replaceable>P</replaceable>.</para>
550 <term><literal>ghc-pkg describe <replaceable>P</replaceable></literal></term>
552 <para>Emit the full description of the specified package. The
553 description is in the form of an
554 <literal>InstalledPackageInfo</literal>, the same as the input file
555 format for <literal>ghc-pkg register</literal>. See <xref
556 linkend="installed-pkg-info" /> for details.</para>
561 <term><literal>ghc-pkg field <replaceable>P</replaceable> <replaceable>field</replaceable></literal></term>
563 <para>Show just a single field of the installed package description
564 for <literal>P</literal>.</para>
569 <para>Additionally, the following flags are accepted by
570 <literal>ghc-pkg</literal>:</para>
575 <option>––auto-ghci-libs</option><indexterm><primary><option>––auto-ghci-libs</option></primary>
579 <para>Automatically generate the GHCi
580 <filename>.o</filename> version of each
581 <filename>.a</filename> Haskell library, using GNU ld (if
582 that is available). Without this option,
583 <literal>ghc-pkg</literal> will warn if GHCi versions of
584 any Haskell libraries in the package don't exist.</para>
586 <para>GHCi <literal>.o</literal> libraries don't
587 necessarily have to live in the same directory as the
588 corresponding <literal>.a</literal> library. However,
589 this option will cause the GHCi library to be created in
590 the same directory as the <literal>.a</literal>
597 <option>-f</option> <replaceable>file</replaceable>
598 <indexterm><primary><option>-f</option></primary>
602 <option>-package-conf</option> <replaceable>file</replaceable>
603 <indexterm><primary><option>-package-conf</option></primary>
607 <para>Adds <replaceable>file</replaceable> to the stack of package
608 databases. Additionally, <replaceable>file</replaceable> will
609 also be the database modified by a <literal>register</literal>,
610 <literal>unregister</literal>, <literal>expose</literal> or
611 <literal>hide</literal> command, unless it is overriden by a later
612 <option>--package-conf</option>, <option>--user</option> or
613 <option>--global</option> option.</para>
619 <option>––force</option>
621 <option>––force</option>
622 </primary></indexterm>
625 <para>Causes <literal>ghc-pkg</literal> to ignore missing
626 dependencies, directories and libraries when registering a package,
627 and just go ahead and add it anyway. This might be useful if your
628 package installation system needs to add the package to
629 GHC before building and installing the files.</para>
635 <option>––global</option><indexterm><primary><option>––global</option></primary>
639 <para>Operate on the global package database (this is the default).
640 This flag affects the <literal>register</literal>,
641 <literal>update</literal>, <literal>unregister</literal>,
642 <literal>expose</literal>, and <literal>hide</literal>
649 <option>––help</option><indexterm><primary><option>––help</option></primary>
653 <option>-?</option><indexterm><primary><option>-?</option></primary>
657 <para>Outputs the command-line syntax.</para>
663 <option>––user</option><indexterm><primary><option>––user</option></primary>
667 <para>Operate on the current user's local package database.
668 This flag affects the <literal>register</literal>,
669 <literal>update</literal>, <literal>unregister</literal>,
670 <literal>expose</literal>, and <literal>hide</literal>
677 <option>-V</option><indexterm><primary><option>-V</option></primary>
681 <option>––version</option><indexterm><primary><option>––version</option></primary>
685 <para>Output the <literal>ghc-pkg</literal> version number.</para>
690 <para>When modifying the package database
691 <replaceable>file</replaceable>, a copy of the original file is
692 saved in <replaceable>file</replaceable><literal>.old</literal>,
693 so in an emergency you can always restore the old settings by
694 copying the old file back again.</para>
698 <sect2 id="installed-pkg-info">
700 <literal>InstalledPackageInfo</literal>: a package specification
703 <para>A package specification is a Haskell record; in particular, it is the
705 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>
707 <para>An <literal>InstalledPackageInfo</literal> has a human
708 readable/writable syntax. The functions
709 <literal>parseInstalledPackageInfo</literal> and
710 <literal>showInstalledPackageInfo</literal> read and write this syntax
711 respectively. Here's an example of the
712 <literal>InstalledPackageInfo</literal> for the <literal>unix</literal> package:</para>
715 $ ghc-pkg describe unix
720 maintainer: libraries@haskell.org
728 exposed-modules: System.Posix,
729 System.Posix.DynamicLinker.Module,
730 System.Posix.DynamicLinker.Prim,
731 System.Posix.Directory,
732 System.Posix.DynamicLinker,
737 System.Posix.Process,
738 System.Posix.Resource,
740 System.Posix.Terminal,
744 System.Posix.Signals.Exts
745 import-dirs: /usr/lib/ghc-6.4/libraries/unix
746 library-dirs: /usr/lib/ghc-6.4/libraries/unix
748 extra-libraries: HSunix_cbits, dl
749 include-dirs: /usr/lib/ghc-6.4/libraries/unix/include
754 <para>The full <ulink url="../Cabal/index.html">Cabal documentation</ulink>
755 is still in preparation (at time of writing), so in the meantime
756 here is a brief description of the syntax of this file:</para>
758 <para>A package description consists of a number of field/value pairs. A
759 field starts with the field name in the left-hand column followed by a
760 “<literal>:</literal>”, and the value continues until the next line that begins in the
761 left-hand column, or the end of file.</para>
763 <para>The syntax of the value depends on the field. The various field
768 <term>freeform</term>
770 <para>Any arbitrary string, no interpretation or parsing is
777 <para>A sequence of non-space characters, or a sequence of arbitrary
778 characters surrounded by quotes <literal>"...."</literal>.</para>
782 <term>string list</term>
784 <para>A sequence of strings, separated by commas. The sequence may
790 <para>In addition, there are some fields with special syntax (e.g. package
791 names, version, dependencies).</para>
793 <para>The allowed fields, with their types, are:</para>
798 <literal>name</literal>
799 <indexterm><primary><literal>name</literal></primary><secondary>package specification</secondary></indexterm>
802 <para>The package's name (without the version).</para>
808 <literal>version</literal>
809 <indexterm><primary><literal>version</literal></primary><secondary>package specification</secondary></indexterm>
812 <para>The package's version, usually in the form
813 <literal>A.B</literal> (any number of components are allowed).</para>
819 <literal>license</literal>
820 <indexterm><primary><literal>auto</literal></primary><secondary>package specification</secondary></indexterm>
823 <para>(string) The type of license under which this package is distributed.
824 This field is a value of the <ulink
825 url="../libraries/Cabal/Distribution-License.html#t:License"><literal>License</literal></ulink> type.</para>
831 <literal>license-file</literal>
832 <indexterm><primary><literal>license-file</literal></primary><secondary>package specification</secondary></indexterm>
835 <para>(optional string) The name of a file giving detailed license
836 information for this package.</para>
842 <literal>copyright</literal>
843 <indexterm><primary><literal>copyright</literal></primary><secondary>package specification</secondary></indexterm>
846 <para>(optional freeform) The copyright string.</para>
852 <literal>maintainer</literal>
853 <indexterm><primary><literal>maintainer</literal></primary><secondary>package specification</secondary></indexterm>
856 <para>(optinoal freeform) The email address of the package's maintainer.</para>
862 <literal>stability</literal>
863 <indexterm><primary><literal>stability</literal></primary><secondary>package specification</secondary></indexterm>
866 <para>(optional freeform) A string describing the stability of the package
867 (eg. stable, provisional or experimental).</para>
873 <literal>homepage</literal>
874 <indexterm><primary><literal>homepage</literal></primary><secondary>package specification</secondary></indexterm>
877 <para>(optional freeform) URL of the package's home page.</para>
883 <literal>package-url</literal>
884 <indexterm><primary><literal>package-url</literal></primary><secondary>package specification</secondary></indexterm>
887 <para>(optional freeform) URL of a downloadable distribution for this
888 package. The distribution should be a Cabal package.</para>
894 <literal>description</literal>
895 <indexterm><primary><literal>description</literal></primary><secondary>package specification</secondary></indexterm>
898 <para>(optional freeform) Description of the package.</para>
904 <literal>category</literal>
905 <indexterm><primary><literal>category</literal></primary><secondary>package specification</secondary></indexterm>
908 <para>(optinoal freeform) Which category the package belongs to. This field
909 is for use in conjunction with a future centralised package
910 distribution framework, tentatively titled Hackage.</para>
916 <literal>author</literal>
917 <indexterm><primary><literal>author</literal></primary><secondary>package specification</secondary></indexterm>
920 <para>(optional freeform) Author of the package.</para>
926 <literal>exposed</literal>
927 <indexterm><primary><literal>exposed</literal></primary><secondary>package specification</secondary></indexterm>
930 <para>(bool) Whether the package is exposed or not.</para>
936 <literal>exposed-modules</literal>
937 <indexterm><primary><literal>exposed-modules</literal></primary><secondary>package specification</secondary></indexterm>
940 <para>(string list) modules exposed by this package.</para>
946 <literal>hidden-modules</literal>
947 <indexterm><primary><literal>hidden-modules</literal></primary><secondary>package specification</secondary></indexterm>
950 <para>(string list) modules provided by this package,
951 but not exposed to the programmer. These modules cannot be
952 imported, but they are still subject to the overlapping constraint:
953 no other package in the same program may provide a module of the
960 <literal>import-dirs</literal>
961 <indexterm><primary><literal>import-dirs</literal></primary><secondary>package specification</secondary></indexterm>
964 <para>(string list) A list of directories containing interface files
965 (<literal>.hi</literal> files) for this package.</para>
967 <para>If the package contains profiling libraries, then
968 the interface files for those library modules should have
969 the suffix <literal>.p_hi</literal>. So the package can
970 contain both normal and profiling versions of the same
971 library without conflict (see also
972 <literal>library_dirs</literal> below).</para>
978 <literal>library-dirs</literal>
979 <indexterm><primary><literal>library-dirs</literal></primary><secondary>package specification</secondary></indexterm>
982 <para>(string list) A list of directories containing libraries for this
989 <literal>hs-libraries</literal>
990 <indexterm><primary><literal>hs-libraries</literal></primary><secondary>package specification</secondary></indexterm>
993 <para>(string list) A list of libraries containing Haskell code for this
994 package, with the <literal>.a</literal> or
995 <literal>.dll</literal> suffix omitted. When packages are
996 built as libraries, the
997 <literal>lib</literal> prefix is also omitted.</para>
999 <para>For use with GHCi, each library should have an
1000 object file too. The name of the object file does
1001 <emphasis>not</emphasis> have a <literal>lib</literal>
1002 prefix, and has the normal object suffix for your
1005 <para>For example, if we specify a Haskell library as
1006 <filename>HSfoo</filename> in the package spec, then the
1007 various flavours of library that GHC actually uses will be
1011 <term><filename>libHSfoo.a</filename></term>
1013 <para>The name of the library on Unix and Windows
1014 (mingw) systems. Note that we don't support
1015 building dynamic libraries of Haskell code on Unix
1020 <term><filename>HSfoo.dll</filename></term>
1022 <para>The name of the dynamic library on Windows
1023 systems (optional).</para>
1027 <term><filename>HSfoo.o</filename></term>
1028 <term><filename>HSfoo.obj</filename></term>
1030 <para>The object version of the library used by
1040 <literal>extra-libraries</literal>
1041 <indexterm><primary><literal>extra-libraries</literal></primary><secondary>package specification</secondary></indexterm>
1044 <para>(string list) A list of extra libraries for this package. The
1045 difference between <literal>hs-libraries</literal> and
1046 <literal>extra-libraries</literal> is that
1047 <literal>hs-libraries</literal> normally have several
1048 versions, to support profiling, parallel and other build
1049 options. The various versions are given different
1050 suffixes to distinguish them, for example the profiling
1051 version of the standard prelude library is named
1052 <filename>libHSbase_p.a</filename>, with the
1053 <literal>_p</literal> indicating that this is a profiling
1054 version. The suffix is added automatically by GHC for
1055 <literal>hs-libraries</literal> only, no suffix is added
1057 <literal>extra-libraries</literal>.</para>
1059 <para>The libraries listed in
1060 <literal>extra-libraries</literal> may be any libraries
1061 supported by your system's linker, including dynamic
1062 libraries (<literal>.so</literal> on Unix,
1063 <literal>.DLL</literal> on Windows).</para>
1065 <para>Also, <literal>extra-libraries</literal> are placed
1066 on the linker command line after the
1067 <literal>hs-libraries</literal> for the same package. If
1068 your package has dependencies in the other direction (i.e.
1069 <literal>extra-libraries</literal> depends on
1070 <literal>hs-libraries</literal>), and the libraries are
1071 static, you might need to make two separate
1078 <literal>include-dirs</literal>
1079 <indexterm><primary><literal>include-dirs</literal></primary><secondary>package specification</secondary></indexterm>
1082 <para>(string list) A list of directories containing C includes for this
1089 <literal>includes</literal>
1090 <indexterm><primary><literal>includes</literal></primary><secondary>package specification</secondary></indexterm>
1093 <para>(string list) A list of files to include for via-C compilations
1094 using this package. Typically the include file(s) will
1095 contain function prototypes for any C functions used in
1096 the package, in case they end up being called as a result
1097 of Haskell functions from the package being
1104 <literal>depends</literal>
1105 <indexterm><primary><literal>depends</literal></primary><secondary>package specification</secondary></indexterm>
1108 <para>(package name list) Packages on which this package depends. This field contains
1109 packages with explicit versions are required, except that when
1110 submitting a package to <literal>ghc-pkg register</literal>, the
1111 versions will be filled in if they are unambiguous.</para>
1117 <literal>hugs-options</literal>
1118 <indexterm><primary><literal>hugs-options</literal></primary><secondary>package specification</secondary></indexterm>
1121 <para>(string list) Options to pass to Hugs for this package.</para>
1127 <literal>cc-options</literal>
1128 <indexterm><primary><literal>cc-options</literal></primary><secondary>package specification</secondary></indexterm>
1131 <para>(string list) Extra arguments to be added to the gcc command line
1132 when this package is being used (only for via-C
1133 compilations).</para>
1139 <literal>ld-options</literal>
1140 <indexterm><primary><literal>ld-options</literal></primary><secondary>package specification</secondary></indexterm>
1143 <para>(string list) Extra arguments to be added to the
1144 <command>gcc</command> command line (for linking) when
1145 this package is being used.</para>
1151 <literal>framework-dirs</literal>
1152 <indexterm><primary><literal>framework-dirs</literal></primary><secondary>package specification</secondary></indexterm>
1155 <para>(string list) On Darwin/MacOS X, a list of directories containing
1156 frameworks for this package. This corresponds to the
1157 <option>-framework-path</option> option. It is ignored on all other
1164 <literal>frameworks</literal>
1165 <indexterm><primary><literal>frameworks</literal></primary><secondary>package specification</secondary></indexterm>
1168 <para>(string list) On Darwin/MacOS X, a list of frameworks to link to. This
1169 corresponds to the <option>-framework</option> option. Take a look
1170 at Apple's developer documentation to find out what frameworks
1171 actually are. This entry is ignored on all other platforms.</para>
1177 <literal>haddock-interfaces</literal>
1178 <indexterm><primary><literal>haddock-interfaces</literal></primary><secondary>package specification</secondary></indexterm>
1181 <para>(string list) A list of filenames containing <ulink
1182 url="http://www.haskell.org/haddock/">Haddock</ulink> interface
1183 files (<literal>.haddock</literal> files) for this package.</para>
1189 <literal>haddock-html</literal>
1190 <indexterm><primary><literal>haddock-html</literal></primary><secondary>package specification</secondary></indexterm>
1193 <para>(optional string) The directory containing the Haddock-generated HTML
1194 for this package.</para>
1199 <!-- This isn't true any more. I'm not sure if we still need it -SDM
1201 The <literal>ghc-pkg</literal> tool performs expansion of
1202 environment variables occurring in input package specifications.
1203 So, if the <literal>mypkg</literal> was added to the package
1204 database as follows:
1207 $ installdir=/usr/local/lib ghc-pkg -a < mypkg.pkg
1211 The occurrence of <literal>${installdir}</literal> is replaced
1212 with <literal>/usr/local/lib</literal> in the package data that
1213 is added for <literal>mypkg</literal>.
1217 This feature enables the distribution of package specification
1218 files that can be easily configured when installing.
1221 <para>For examples of more package specifications, take a look
1222 at the <literal>package.conf</literal> in your GHC
1223 installation.</para>
1231 ;;; Local Variables: ***
1233 ;;; sgml-parent-document: ("users_guide.xml" "book" "chapter" "sect1") ***