[project @ 2000-05-19 12:00:47 by rrt]
authorrrt <unknown>
Fri, 19 May 2000 12:00:47 +0000 (12:00 +0000)
committerrrt <unknown>
Fri, 19 May 2000 12:00:47 +0000 (12:00 +0000)
Added BNW of Installing It Yourself to DocBook docs.
Added new world of pattern guards to Glasgow Exts.

docs/building.sgml
ghc/docs/users_guide/glasgow_exts.sgml
ghc/docs/users_guide/installing.sgml

index 90fca74..1ba537c 100644 (file)
@@ -1,6 +1,6 @@
 <!DOCTYPE Article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
 
-<Article>
+<Article id="building-guide">
 
 <ArtHeader>
 
@@ -182,32 +182,26 @@ Here's a list of things to check before you get started.
 <ListItem>
 
 <Para>
-<IndexTerm><Primary>Disk space needed</Primary></IndexTerm>Disk space needed: About 30MB (five hamburgers' worth) of disk space
-for the most basic binary distribution of GHC; more for some
-platforms, e.g., Alphas.  An extra ``bundle'' (e.g., concurrent
-Haskell libraries) might take you to 8&ndash;10 hamburgers.
-
-You'll need over 100MB (say, 20 hamburgers' worth) if you need to
-build the basic stuff from scratch.
-
-
-All of the above are <Emphasis>estimates</Emphasis> of disk-space needs. (I don't yet
-know the disk requirements for the non-GHC tools).
-
+<IndexTerm><Primary>Disk space needed</Primary></IndexTerm>
+Disk space needed: About 40MB (one tenth of one hamburger's worth) of disk
+space for the most basic binary distribution of GHC; more for some
+platforms, e.g., Alphas.  An extra ``bundle'' (e.g., concurrent Haskell
+libraries) might take you to up to one fifth of a hamburger. You'll need
+over 100MB (say, one fifth a hamburger's worth) if you need to build the
+basic stuff from scratch. All of the above are
+<Emphasis>estimates</Emphasis> of disk-space needs. (Note: our benchmark hamburger is a standard Double Whopper with Cheese, with an RRP of UKP2.99.)
 </Para>
 </ListItem>
 <ListItem>
 
 <Para>
 Use an appropriate machine, compilers, and things.
-
 SPARC boxes, and PCs running Linux, FreeBSD, NetBSD, or Solaris are
 all fully supported.  Win32 and HP boxes are in pretty good shape.
 DEC Alphas running OSF/1, Linux or some BSD variant, MIPS and AIX
 boxes will need some minimal porting effort before they work (as of
 4.06).  <Xref LinkEnd="sec-port-info"> gives the full run-down on
 ports or lack thereof.
-
 </Para>
 </ListItem>
 <ListItem>
@@ -647,19 +641,7 @@ documentation that comes with the <Literal>fptools</Literal> projects:
 <IndexTerm><Primary>DocBook, pre-supposed</Primary></IndexTerm>
 <ListItem>
 <Para>
-All our documentation is written in SGML, using the DocBook DTD.
-Instructions on how to install the SGML processor Jade and the DocBook DTD
-and DSSSL stylesheets follows; if you're using a system that can handle
-RedHat RPM packages, you might be able to use the <ULink
-URL="http://sourceware.cygnus.com/docbook-tools/">Cygnus DocBook
-tools</ULink>, which is the most shrink-wrapped SGML suite that we
-could find. You need all the RPMs except for psgml (i.e. docbook, jade,
-jadetex, sgmlcommon and stylesheets). N.B. The
-<Emphasis>Cygnus</Emphasis> version of the tools is assumed. Others, such as
-the SuSE version, may not work. Note that most of these RPMs are
-architecture neutral, so are likely to be found in a
-<Filename>noarch</Filename>
-directory.
+All our documentation is written in SGML, using the DocBook DTD. Instructions on installing and configuring the DocBook tools are in the installation guide (<XRef LinkEnd="building-docs">).
 </Para>
 
 </ListItem></VarListEntry>
index 6cbb5fe..e1467fa 100644 (file)
@@ -12,9 +12,7 @@ the underlying facilities with which we implement Haskell.  Thus, you
 can get at the Raw Iron, if you are willing to write some non-standard
 code at a more primitive level.  You need not be &ldquo;stuck&rdquo; on
 performance because of the implementation costs of Haskell's
-&ldquo;high-level&rdquo; features&mdash;you can always code &ldquo;under&rdquo; them.  In an
-extreme case, you can write all your time-critical code in C, and then
-just glue it together with Haskell!
+&ldquo;high-level&rdquo; features&mdash;you can always code &ldquo;under&rdquo; them.  In an extreme case, you can write all your time-critical code in C, and then just glue it together with Haskell!
 </Para>
 
 <Para>
@@ -78,6 +76,15 @@ for some nested declarations, where this would not be legal in Haskell
 </VarListEntry>
 
 <VarListEntry>
+<Term>Pattern guards</Term>
+<ListItem>
+<Para>
+Instead of being a boolean expression, a guard is a list of qualifiers, exactly as in a list comprehension. See <XRef LinkEnd="pattern-guards">.
+</Para>
+</ListItem>
+</VarListEntry>
+
+<VarListEntry>
 <Term>Calling out to C:</Term>
 <ListItem>
 <Para>
@@ -1341,17 +1348,142 @@ The libraries documentatation gives more details on all these
 
 </Sect1>
 
+
+<Sect1 id="pattern-guards">
+<Title>Pattern guards</Title>
+
+<Para>
+<IndexTerm><Primary>Pattern guards (Glasgow extension)</Primary></IndexTerm>
+The discussion that follows is an abbreviated version of Simon Peyton Jones's original <ULink URL="http://research.microsoft.com/~simonpj/Haskell/guards.html">proposal</ULink>. (Note that the proposal was written before pattern guards were implemented, so refers to them as unimplemented.)
+</Para>
+
+<Para>
+Suppose we have an abstract data type of finite maps, with a
+lookup operation:
+
+<ProgramListing>
+lookup :: FiniteMap -> Int -> Maybe Int
+</ProgramListing>
+
+The lookup returns <Function>Nothing</Function> if the supplied key is not in the domain of the mapping, and <Function>(Just v)</Function> otherwise,
+where <VarName>v</VarName> is the value that the key maps to.  Now consider the following definition:
+</Para>
+
+<ProgramListing>
+clunky env var1 var2 | ok1 && ok2 = val1 + val2
+| otherwise  = var1 + var2
+where
+  m1 = lookup env var1
+  m2 = lookup env var2
+  ok1 = maybeToBool m1
+  ok2 = maybeToBool m2
+  val1 = expectJust m1
+  val2 = expectJust m2
+</ProgramListing>
+
+<Para>
+The auxiliary functions are 
+</Para>
+
+<ProgramListing>
+maybeToBool :: Maybe a -&gt; Bool
+maybeToBool (Just x) = True
+maybeToBool Nothing  = False
+
+expectJust :: Maybe a -&gt; a
+expectJust (Just x) = x
+expectJust Nothing  = error "Unexpected Nothing"
+</ProgramListing>
+
+<Para>
+What is <Function>clunky</Function> doing? The guard <Literal>ok1 &&
+ok2</Literal> checks that both lookups succeed, using
+<Function>maybeToBool</Function> to convert the <Function>Maybe</Function>
+types to booleans. The (lazily evaluated) <Function>expectJust</Function>
+calls extract the values from the results of the lookups, and binds the
+returned values to <VarName>val1</VarName> and <VarName>val2</VarName>
+respectively.  If either lookup fails, then clunky takes the
+<Literal>otherwise</Literal> case and returns the sum of its arguments.
+</Para>
+
+<Para>
+This is certainly legal Haskell, but it is a tremendously verbose and
+un-obvious way to achieve the desired effect.  Arguably, a more direct way
+to write clunky would be to use case expressions:
+</Para>
+
+<ProgramListing>
+clunky env var1 var1 = case lookup env var1 of
+  Nothing -&gt; fail
+  Just val1 -&gt; case lookup env var2 of
+    Nothing -&gt; fail
+    Just val2 -&gt; val1 + val2
+where
+  fail = val1 + val2
+</ProgramListing>
+
+<Para>
+This is a bit shorter, but hardly better.  Of course, we can rewrite any set
+of pattern-matching, guarded equations as case expressions; that is
+precisely what the compiler does when compiling equations! The reason that
+Haskell provides guarded equations is because they allow us to write down
+the cases we want to consider, one at a time, independently of each other. 
+This structure is hidden in the case version.  Two of the right-hand sides
+are really the same (<Function>fail</Function>), and the whole expression
+tends to become more and more indented. 
+</Para>
+
+<Para>
+Here is how I would write clunky:
+</Para>
+
+<ProgramListing>
+clunky env var1 var1
+  | Just val1 &lt;- lookup env var1
+  , Just val2 &lt;- lookup env var2
+  = val1 + val2
+...other equations for clunky...
+</ProgramListing>
+
+<Para>
+The semantics should be clear enough.  The qualifers are matched in order. 
+For a <Literal>&lt;-</Literal> qualifier, which I call a pattern guard, the
+right hand side is evaluated and matched against the pattern on the left. 
+If the match fails then the whole guard fails and the next equation is
+tried.  If it succeeds, then the appropriate binding takes place, and the
+next qualifier is matched, in the augmented environment.  Unlike list
+comprehensions, however, the type of the expression to the right of the
+<Literal>&lt;-</Literal> is the same as the type of the pattern to its
+left.  The bindings introduced by pattern guards scope over all the
+remaining guard qualifiers, and over the right hand side of the equation.
+</Para>
+
+<Para>
+Just as with list comprehensions, boolean expressions can be freely mixed
+with among the pattern guards.  For example:
+</Para>
+
+<ProgramListing>
+f x | [y] <- x
+    , y > 3
+    , Just z <- h y
+    = ...
+</ProgramListing>
+
+<Para>
+Haskell's current guards therefore emerge as a special case, in which the
+qualifier list has just one element, a boolean expression.
+</Para>
+</Sect1>
+
+
 <Sect1 id="glasgow-ccalls">
-<Title>Calling&nbsp;C directly from Haskell
-</Title>
+<Title>Calling C directly from Haskell</Title>
 
 <Para>
 <IndexTerm><Primary>C calls (Glasgow extension)</Primary></IndexTerm>
 <IndexTerm><Primary>&lowbar;ccall&lowbar; (Glasgow extension)</Primary></IndexTerm>
 <IndexTerm><Primary>&lowbar;casm&lowbar; (Glasgow extension)</Primary></IndexTerm>
-</Para>
-
-<Para>
 GOOD ADVICE: Because this stuff is not Entirely Stable as far as names
 and things go, you would be well-advised to keep your C-callery
 corraled in a few modules, rather than sprinkled all over your code.
index 09c443c..9603188 100644 (file)
@@ -28,7 +28,7 @@ so binary distributions allow you to install them without having a Haskell compi
 
 <Para>
 Binary distributions come in &ldquo;bundles,&rdquo; one bundle per file called
-<Literal>&lt;bundle&gt;-&lt;platform&gt;.tar.gz</Literal>.  (See the building guide for the definition of a platform.)  Suppose that you untar a binary-distribution bundle, thus:
+<Literal>&lt;bundle&gt;-&lt;platform&gt;.tar.gz</Literal>.  (See the building guide (<XRef LinkEnd="pre-supposed-doc-tools">) for the definition of a platform.)  Suppose that you untar a binary-distribution bundle, thus:
 </Para>
 
 <Para>
@@ -353,8 +353,8 @@ stuff in your bin directory.
 <XRef LinkEnd="sec-GHC-test">.  Be sure to use a <Literal>-v</Literal>
 option, so you can see exactly what pathnames it's using.
 
-If things don't work as expected, check the list of know pitfalls in
-the building guide.
+If things don't work as expected, check the list of known pitfalls in
+the building guide (<XRef LinkEnd="pre-supposed-doc-tools">.
 </Para>
 </ListItem>
 
@@ -505,11 +505,10 @@ with a binary distribution, or in source form in
 <Sect1><Title>Installing on Windows</Title>
 
 <Para>
-Getting the Glasgow Haskell Compiler (GHC) to run on Windows95/98 or
-Windows NT4 platforms can be a bit of a trying experience. This document
-tries to simplify the task by enumerating the steps you need to
-follow in order to set up and configure your machine to run GHC (at
-least that's the intention ;-)
+Getting the Glasgow Haskell Compiler (GHC) to run on Windows platforms can
+be a bit of a trying experience. This document tries to simplify the task by
+enumerating the steps you need to follow in order to set up and configure
+your machine to run GHC (at least that's the intention ;-)
 </Para>
 
 <Sect2><Title>System requirements</Title>
@@ -527,52 +526,6 @@ To run GHC comfortably, your machine should have at least 32M of memory.
 </Sect2>
 
 
-<Sect2><Title>Your environment variables</Title>
-
-<Para>
-Much of the Unixy stuff below involves setting environment variables.  
-This section summarises  how to set these variables on a Windows machine, in
-case you don't know alread.y
-On WinNT/Win2k, to edit your <Constant>PATH</Constant> variable (for example),
-do the following:
-</Para>
-
-<ItemizedList>
-<ListItem><Para>Press Start/Settings/Control Panels</Para></ListItem>
-<ListItem><Para>Double-click System</Para></ListItem>
-<ListItem><Para>Press Advanced</Para></ListItem>
-<ListItem><Para>Press Environment Variables</Para></ListItem>
-<ListItem><Para>Under System Variables, select PATH</Para></ListItem>
-<ListItem><Para>Press Edit</Para></ListItem>
-<ListItem><Para>Add "<Filename>;C:/whatever/</Filename>" to the end of the string (for example)</Para></ListItem>
-<ListItem><Para>Press OK</Para></ListItem>
-</ItemizedList>
-
-<Para>
-Some environment variables are &ldquo;user variables&rdquo; and
-some are &ldquo;system variables&rdquo;.  I'm not sure of the difference
-but both are changed though the same dialogue.
-</Para>
-
-<Para>
-In addition, when running a Cygwin (see <XRef LinkEnd="sec-required">) shell
-you can set environment variables in your <Filename>.bashrc</Filename> file.
-But it is better to set your environment variables from the
-control panel (they get inherited by bash) because then they are visible
-to applications that aren't started by bash.  For example,
-when you're invoking CVS (and ssh) via Emacs keybindings;
-it invokes <Filename>cvs.exe</Filename> without going via bash.
-</Para>
-
-<Para>
-On a Win9x machine you need to edit <Filename>autoexec.bat</Filename> using
-<Filename>Windows/system/Sysedit</Filename>.  You need to reboot to make
-the new settings take effect.
-</Para>
-
-</Sect2>
-
-
 <Sect2 id="sec-required"><Title>Software required</Title>
 
 <Para>
@@ -586,7 +539,7 @@ GHC depends at the moment on the cygwin tools to operate, which
 dresses up the Win32 environment into something more UNIX-like.
 (notably, it provides <Command>gcc</Command>, <Command>as</Command> and <Command>ld</Command>),
 so you'll need to install these tools first. You also need
-Cygwin to use CVS.
+Cygwin to use CVS. (We don't yet support later versions of Cygwin.)
 </Para>
 
 <Para>
@@ -669,6 +622,50 @@ instructions on how to set this up.
 
 </ItemizedList>
 
+</Sect3>
+
+
+<Sect3><Title>Environment variables</Title>
+
+<Para>
+In case you don't already know how to set environment variables on a Windows
+machine, here's how. On WinNT/Win2k, to edit your <Constant>PATH</Constant>
+variable (for example), do the following:
+</Para>
+
+<ItemizedList>
+<ListItem><Para>Press Start/Settings/Control Panels</Para></ListItem>
+<ListItem><Para>Double-click System</Para></ListItem>
+<ListItem><Para>Press Advanced</Para></ListItem>
+<ListItem><Para>Press Environment Variables</Para></ListItem>
+<ListItem><Para>Under System Variables, select <Constant>PATH</Constant></Para></ListItem>
+<ListItem><Para>Press Edit</Para></ListItem>
+<ListItem><Para>Add "<Filename>;C:/whatever/</Filename>" to the end of the string (for example)</Para></ListItem>
+<ListItem><Para>Press OK</Para></ListItem>
+</ItemizedList>
+
+<Para>
+Some environment variables are &ldquo;user variables&rdquo; and
+some are &ldquo;system variables&rdquo;.  I'm not sure of the difference
+but both are changed though the same dialogue.
+</Para>
+
+<Para>
+In addition, when running <Command>bash</Command>
+you can set environment variables in your <Filename>.bashrc</Filename> file.
+But it is better to set your environment variables from the
+control panel (they get inherited by bash) because then they are visible
+to applications that aren't started by bash.  For example,
+when you're invoking CVS (and ssh) via Emacs keybindings;
+it invokes <Filename>cvs.exe</Filename> without going via bash.
+</Para>
+
+<Para>
+On a Win9x machine you need to edit <Filename>autoexec.bat</Filename> using
+<Filename>Windows/system/Sysedit</Filename>.  You must reboot to make
+the new settings take effect.
+</Para>
+
 <Para>
 The following environment variables must be set:
 </Para>
@@ -744,6 +741,15 @@ We think this is due to a bug in Cygwin.
 </InformalTable>
 </Para>
 
+<Para>
+In addition, we've had problems in the past with certain environment
+variables being set that seem to have bad effects on GHC. If you have
+installed other systems ported from Unix, you might too. If you get weird
+inexplicable failures to build GHC, then it might be worth weeding out unused
+environment variables. Known culprits from the past include
+<Constant>GCC_EXEC_PREFIX</Constant> and <Constant>INCLUDE</Constant>.
+</Para>
+
 </Sect3>
 
 
@@ -865,10 +871,8 @@ Further information on using GHC under Windows can be found in <ULink URL="http:
 
 </Sect2>
 
-</Sect1>
-
 
-<Sect1 id="winfaq"><title>Installing ghc-win32 FAQ</title>
+<Sect2 id="winfaq"><title>Installing ghc-win32 FAQ</title>
 
 <QandASet>
 
@@ -900,6 +904,59 @@ All being well, ghc should then start to function.
 
 <Question>
 <Para>
+I'm having trouble with symlinks.
+</Para>
+</Question>
+
+<Answer>
+<Para>
+Symlinks only work under Cygwin (<Xref LinkEnd="sec-install">), so binaries
+not linked to the Cygwin DLL, in particular those built for Mingwin, will not
+work with symlinks.
+</Para>
+</Answer>
+
+<QandAEntry>
+
+<Question>
+<Para>
+I'm getting ``permission denied'' messages from <Command>rm</Command> or
+<Command>mv</Command>.
+</Para>
+</Question>
+
+<Answer>
+<Para>
+This can have various causes: trying to rename a directory when an Explorer
+window is open on it tends to fail. Closing the window generally cures the
+problem, but sometimes its cause is more mysterious, and logging off and back
+on or rebooting may be the quickest cure.
+</Para>
+</Answer>
+
+</QandAEntry>
+
+<QandAEntry>
+
+<Question>
+<Para>
+I get errors when trying to build GHC 4.07 with GHC 4.05.
+</Para>
+</Question>
+
+<Answer>
+<Para>
+This seems to work better if you don't use <Option>-O</Option> in <Constant>GhcHcOpts</Constant>. It's a bug in 4.05, unfortunately. Anyway, better to install 4.07 binaries and use those.
+</Para>
+</Answer>
+
+</QandAEntry>
+
+<!--
+<QandAEntry>
+
+<Question>
+<Para>
 When compiling up the <Literal>Hello World</Literal> example, the following happens:
 </Para>
 
@@ -943,7 +1000,7 @@ files within the directory tree that the installer created:
 </Para>
 
 <Screen>
-bin/ghc-4.xx   -- where xx is the minor release number
+bin/ghc-4.xx    where xx is the minor release number
 bin/stat2resid
 bin/hstags
 lib/mkdependHS</Screen>
@@ -961,47 +1018,151 @@ of perl instead, a <ULink URL="http://cygutils.netpedia.net/">cygwin port</ULink
 </Answer>
 
 </QandAEntry>
+-->
 
-<QAndAEntry>
+</QandASet>
+
+</Sect2>
+
+</Sect1>
+
+
+<Sect1 id="building-docs">
+<Title>Building the documentation</Title>
 
-<Question>
 <Para>
-<Function>System.getArgs</Function> always return the empty list, i.e. the following program always prints &ldquo;<Literal>[]</Literal>&rdquo;:
+We use the DocBook DTD, which is widely used; however, shrink-wrapped
+distributions of DocBook are few and far between, and getting it to work out
+of the box can be tricky. There are currently two supported ways of using
+DocBook: installing from sources yourself, and the Cygnus DocBook tools.
+Neither is ideal: installing by yourself is tricky, while the Cygnus tools
+are idiosyncratic, slightly broken, and only available as RedHat RPMs
 </Para>
 
-<ProgramListing>
-module Main(main) where
-import qualified System
-main = System.getArgs >>= print
-</ProgramListing>
+<Para>
+Instructions on installing and configuring the DocBook tools follow.
+</Para>
 
-</Question>
+<Sect2>
+<Title>Installing the DocBook tools from RPMs</Title>
 
-<Answer>
 <Para>
-This is a bug with the RTS DLL that comes with ghc-4.03. To fix, upgrade to
-ghc-4.05.
+If you're using a system that can handle RedHat RPM packages, you can
+probably use the <ULink
+URL="http://sourceware.cygnus.com/docbook-tools/">Cygnus DocBook
+tools</ULink>, which is the most shrink-wrapped SGML suite that we could
+find. You need all the RPMs except for psgml (i.e.
+<Filename>docbook</Filename>, <Filename>jade</Filename>,
+<Filename>jadetex</Filename>, <Filename>sgmlcommon</Filename> and
+<Filename>stylesheets</Filename>). Note that most of these RPMs are
+architecture neutral, so are likely to be found in a
+<Filename>noarch</Filename> directory. N.B. The <Emphasis>Cygnus</Emphasis>
+version of the tools is assumed. Others, such as the SuSE version, may not
+work.
 </Para>
-</Answer>
 
-</QAndAEntry>
+</Sect2>
 
-</QandASet>
+<Sect2>
+<Title>Installing the DocBook tools from source</Title>
 
-</Sect1>
+<Para>
+Especially if you're working in Windows, you may find Norman Walsh's <ULink
+URL="http://nwalsh.com/docbook/dsssl/doc/install.html">installation
+notes</ULink> a better way to install DocBook tools. You should get version
+3.1 of DocBook, and note that his file <Filename>test.sgm</Filename> won't
+work, as it needs version 3.0.
+</Para>
 
 
-<Sect1>
-<Title>Building the documentation</Title>
+<Sect3>
+<Title>Jade</Title>
+
+<Para>
+Install <ULink URL="http://openjade.sourceforge.net/">OpenJade</ULink> (Windows binaries are available as well as sources). If you want DVI, PS, or PDF then install JadeTeX from the <Filename>dsssl</Filename>
+subdirectory. (If you get the error:
+
+<Screen>
+! LaTeX Error: Unknown option implicit=false' for package hyperref'.
+</Screen>
+
+your version of <Command>hyperref</Command> is out of date; download it from
+CTAN (<Filename>macros/latex/contrib/supported/hyperref</Filename>), and
+make it, ensuring that you have first removed or renamed your old copy. If
+you start getting file not found errors when making the test for
+<Command>hyperref</Command>, you can abort at that point and proceed
+straight to <Command>make install</Command>, or enter them as
+<Filename>../<Emphasis>filename</Emphasis></Filename>.)
+</Para>
+
+<Para>
+Make links from <Filename>virtex</Filename> to <Filename>jadetex</Filename>
+and <Filename>pdfvirtex</Filename> to <Filename>pdfjadetex</Filename>
+(otherwise DVI, PostScript and PDF output will not work). Copy
+<Filename>dsssl/*.{dtd,dsl}</Filename> and <Filename>catalog</Filename> to <Filename>/usr/[local/]lib/sgml</Filename>.
+</Para>
+
+</Sect3>
+
+<Sect3>
+<Title>DocBook and the DocBook stylesheets</Title>
+
+<Para>
+Get a Zip of <ULink
+URL="http://www.oasis-open.org/docbook/sgml/3.1/index.html">DocBook</ULink> 
+and install the contents in <Filename>/usr/[local/]/lib/sgml</Filename>.
+</Para>
+
+<Para>
+Get the <ULink URL="http://nwalsh.com/docbook/dsssl/">DocBook
+stylesheets</ULink> and install in
+<Filename>/usr/[local/]lib/sgml/stylesheets</Filename> (thereby creating a
+subdirectory docbook). For indexing, copy or link <Filename>collateindex.pl</Filename> from the DocBook stylesheets archive in <Filename>bin</Filename> into a directory on your <Constant>PATH</Constant>.
+</Para>
 
 <Para>
-This is a slightly sore point at the moment, because the GHC team has been unable to strike a good balance between having a documentation system that is easy to maintain and one that is widely available. We use the DocBook DTD, which is widely used; however, shrink-wrapped distributions of DocBook are few and far between, and getting it to work out of the box is a nightmare. We settled on the Cygnus DocBook tools; however, these are only available as Red Hat RPMs, and hence at the moment the documentation can only be built on systems which can use RPMs (i.e. most versions of Linux). Sorry about that. We will probably add pre-built documentation to future source distributions (it's already in binary distributions, of course) until the situation is sorted out (either we bite the bullet and have our own version of the DocBook tools, or a more portable distribution is made available).
+Download the <ULink
+URL="http://www.oasis-open.org/cover/ISOEnts.zip">ISO
+entities</ULink> into <Filename>/usr/[local/]lib/sgml</Filename>.
+</Para>
+
+</Sect3>
+
+</Sect2>
+
+<Sect2>
+<Title>Configuring the DocBook tools</Title>
+
+<Para>
+The supported way to do this is to edit one of the
+<Filename>CATALOG</Filename> files in
+<Filename>fptools/glafp-utils/docbook</Filename> to suit your system.
+<Filename>CATALOG.generic</Filename> should work on most Unix systems when the files have been installed as per these instructions; <Filename>CATALOG.cygnus</Filename> is for systems with the Cygnus DocBook tools. You need to edit all the paths so they match your system. The edited file should be called <Filename>CATALOG</Filename>, and placed in the same directory.
+</Para>
+
+<Para>
+Alternatively, if you have a properly working DocBook toolset (the FreeBSD package is likely to be one such), set <Constant>SGML_CATALOG_FILES</Constant> to point to the catalog in a pre-installed working system (even if it doesn't normally). The build system will complain if there's no <Filename>CATALOG</Filename> in <Filename>glafp-utils/docbook</Filename> and <Filename>SGML_CATALOG_FILES</Filename> is unset.
 </Para>
 
 <Para>
-See the Building Guide for details of what to install to get the DocBook tools and how to build the documentation (it's done by the build system, but just isn't part of a normal build).
+One day there will be properly-working DocBook distributions everywhere and the world will be a better and a quieter place, whose people will have more time for interesting things.
 </Para>
 
+</Sect2>
+
+<Sect2>
+<Title>Remaining problems</Title>
+
+<Para>
+If you install from source, you'll get a pile of warnings of the form
+
+<Screen>DTDDECL catalog entries are not supported</Screen>
+
+every time you build anything. These can safely be ignored, but if you find them tedious you can get rid of them by removing all the <Constant>DTDDECL</Constant> entries from <Filename>docbook.cat</Filename>.
+</Para>
+
+</Sect2>
+
 </Sect1>
 
 </Chapter>