From: rrt Date: Fri, 19 May 2000 12:00:47 +0000 (+0000) Subject: [project @ 2000-05-19 12:00:47 by rrt] X-Git-Tag: Approximately_9120_patches~4424 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=d81a27200736892424570e71001daed81df8ff84;p=ghc-hetmet.git [project @ 2000-05-19 12:00:47 by rrt] Added BNW of Installing It Yourself to DocBook docs. Added new world of pattern guards to Glasgow Exts. --- diff --git a/docs/building.sgml b/docs/building.sgml index 90fca74..1ba537c 100644 --- a/docs/building.sgml +++ b/docs/building.sgml @@ -1,6 +1,6 @@ -
+
@@ -182,32 +182,26 @@ Here's a list of things to check before you get started. -Disk space neededDisk 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–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 estimates of disk-space needs. (I don't yet -know the disk requirements for the non-GHC tools). - +Disk space needed +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 +estimates of disk-space needs. (Note: our benchmark hamburger is a standard Double Whopper with Cheese, with an RRP of UKP2.99.) 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). gives the full run-down on ports or lack thereof. - @@ -647,19 +641,7 @@ documentation that comes with the fptools projects: DocBook, pre-supposed -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 Cygnus DocBook -tools, 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 -Cygnus 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 -noarch -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 (). diff --git a/ghc/docs/users_guide/glasgow_exts.sgml b/ghc/docs/users_guide/glasgow_exts.sgml index 6cbb5fe..e1467fa 100644 --- a/ghc/docs/users_guide/glasgow_exts.sgml +++ b/ghc/docs/users_guide/glasgow_exts.sgml @@ -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 “stuck” on performance because of the implementation costs of Haskell's -“high-level” features—you can always code “under” them. In an -extreme case, you can write all your time-critical code in C, and then -just glue it together with Haskell! +“high-level” features—you can always code “under” them. In an extreme case, you can write all your time-critical code in C, and then just glue it together with Haskell! @@ -78,6 +76,15 @@ for some nested declarations, where this would not be legal in Haskell +Pattern guards + + +Instead of being a boolean expression, a guard is a list of qualifiers, exactly as in a list comprehension. See . + + + + + Calling out to C: @@ -1341,17 +1348,142 @@ The libraries documentatation gives more details on all these + + +Pattern guards + + +Pattern guards (Glasgow extension) +The discussion that follows is an abbreviated version of Simon Peyton Jones's original proposal. (Note that the proposal was written before pattern guards were implemented, so refers to them as unimplemented.) + + + +Suppose we have an abstract data type of finite maps, with a +lookup operation: + + +lookup :: FiniteMap -> Int -> Maybe Int + + +The lookup returns Nothing if the supplied key is not in the domain of the mapping, and (Just v) otherwise, +where v is the value that the key maps to. Now consider the following definition: + + + +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 + + + +The auxiliary functions are + + + +maybeToBool :: Maybe a -> Bool +maybeToBool (Just x) = True +maybeToBool Nothing = False + +expectJust :: Maybe a -> a +expectJust (Just x) = x +expectJust Nothing = error "Unexpected Nothing" + + + +What is clunky doing? The guard ok1 && +ok2 checks that both lookups succeed, using +maybeToBool to convert the Maybe +types to booleans. The (lazily evaluated) expectJust +calls extract the values from the results of the lookups, and binds the +returned values to val1 and val2 +respectively. If either lookup fails, then clunky takes the +otherwise case and returns the sum of its arguments. + + + +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: + + + +clunky env var1 var1 = case lookup env var1 of + Nothing -> fail + Just val1 -> case lookup env var2 of + Nothing -> fail + Just val2 -> val1 + val2 +where + fail = val1 + val2 + + + +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 (fail), and the whole expression +tends to become more and more indented. + + + +Here is how I would write clunky: + + + +clunky env var1 var1 + | Just val1 <- lookup env var1 + , Just val2 <- lookup env var2 + = val1 + val2 +...other equations for clunky... + + + +The semantics should be clear enough. The qualifers are matched in order. +For a <- 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 +<- 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. + + + +Just as with list comprehensions, boolean expressions can be freely mixed +with among the pattern guards. For example: + + + +f x | [y] <- x + , y > 3 + , Just z <- h y + = ... + + + +Haskell's current guards therefore emerge as a special case, in which the +qualifier list has just one element, a boolean expression. + + + + -Calling C directly from Haskell - +Calling C directly from Haskell C calls (Glasgow extension) _ccall_ (Glasgow extension) _casm_ (Glasgow extension) - - - 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. diff --git a/ghc/docs/users_guide/installing.sgml b/ghc/docs/users_guide/installing.sgml index 09c443c..9603188 100644 --- a/ghc/docs/users_guide/installing.sgml +++ b/ghc/docs/users_guide/installing.sgml @@ -28,7 +28,7 @@ so binary distributions allow you to install them without having a Haskell compi Binary distributions come in “bundles,” one bundle per file called -<bundle>-<platform>.tar.gz. (See the building guide for the definition of a platform.) Suppose that you untar a binary-distribution bundle, thus: +<bundle>-<platform>.tar.gz. (See the building guide () for the definition of a platform.) Suppose that you untar a binary-distribution bundle, thus: @@ -353,8 +353,8 @@ stuff in your bin directory. . Be sure to use a -v 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 (. @@ -505,11 +505,10 @@ with a binary distribution, or in source form in Installing on Windows -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 ;-) System requirements @@ -527,52 +526,6 @@ To run GHC comfortably, your machine should have at least 32M of memory. -Your environment variables - - -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 PATH variable (for example), -do the following: - - - -Press Start/Settings/Control Panels -Double-click System -Press Advanced -Press Environment Variables -Under System Variables, select PATH -Press Edit -Add ";C:/whatever/" to the end of the string (for example) -Press OK - - - -Some environment variables are “user variables” and -some are “system variables”. I'm not sure of the difference -but both are changed though the same dialogue. - - - -In addition, when running a Cygwin (see ) shell -you can set environment variables in your .bashrc 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 cvs.exe without going via bash. - - - -On a Win9x machine you need to edit autoexec.bat using -Windows/system/Sysedit. You need to reboot to make -the new settings take effect. - - - - - Software required @@ -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 gcc, as and ld), 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.) @@ -669,6 +622,50 @@ instructions on how to set this up. + + + +Environment variables + + +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 PATH +variable (for example), do the following: + + + +Press Start/Settings/Control Panels +Double-click System +Press Advanced +Press Environment Variables +Under System Variables, select PATH +Press Edit +Add ";C:/whatever/" to the end of the string (for example) +Press OK + + + +Some environment variables are “user variables” and +some are “system variables”. I'm not sure of the difference +but both are changed though the same dialogue. + + + +In addition, when running bash +you can set environment variables in your .bashrc 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 cvs.exe without going via bash. + + + +On a Win9x machine you need to edit autoexec.bat using +Windows/system/Sysedit. You must reboot to make +the new settings take effect. + + The following environment variables must be set: @@ -744,6 +741,15 @@ We think this is due to a bug in Cygwin. + +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 +GCC_EXEC_PREFIX and INCLUDE. + + @@ -865,10 +871,8 @@ Further information on using GHC under Windows can be found in Installing ghc-win32 FAQ +Installing ghc-win32 FAQ @@ -900,6 +904,59 @@ All being well, ghc should then start to function. +I'm having trouble with symlinks. + + + + + +Symlinks only work under Cygwin (), so binaries +not linked to the Cygwin DLL, in particular those built for Mingwin, will not +work with symlinks. + + + + + + + +I'm getting ``permission denied'' messages from rm or +mv. + + + + + +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. + + + + + + + + + +I get errors when trying to build GHC 4.07 with GHC 4.05. + + + + + +This seems to work better if you don't use in GhcHcOpts. It's a bug in 4.05, unfortunately. Anyway, better to install 4.07 binaries and use those. + + + + + + - + + + + + + + + +Building the documentation - -System.getArgs always return the empty list, i.e. the following program always prints “[]”: +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 - -module Main(main) where -import qualified System -main = System.getArgs >>= print - + +Instructions on installing and configuring the DocBook tools follow. + - + +Installing the DocBook tools from RPMs - -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 Cygnus DocBook +tools, 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). Note that most of these RPMs are +architecture neutral, so are likely to be found in a +noarch directory. N.B. The Cygnus +version of the tools is assumed. Others, such as the SuSE version, may not +work. - - + - + +Installing the DocBook tools from source - + +Especially if you're working in Windows, you may find Norman Walsh's installation +notes a better way to install DocBook tools. You should get version +3.1 of DocBook, and note that his file test.sgm won't +work, as it needs version 3.0. + - -Building the documentation + +Jade + + +Install OpenJade (Windows binaries are available as well as sources). If you want DVI, PS, or PDF then install JadeTeX from the dsssl +subdirectory. (If you get the error: + + +! LaTeX Error: Unknown option implicit=false' for package hyperref'. + + +your version of hyperref is out of date; download it from +CTAN (macros/latex/contrib/supported/hyperref), 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 +hyperref, you can abort at that point and proceed +straight to make install, or enter them as +../filename.) + + + +Make links from virtex to jadetex +and pdfvirtex to pdfjadetex +(otherwise DVI, PostScript and PDF output will not work). Copy +dsssl/*.{dtd,dsl} and catalog to /usr/[local/]lib/sgml. + + + + + +DocBook and the DocBook stylesheets + + +Get a Zip of DocBook +and install the contents in /usr/[local/]/lib/sgml. + + + +Get the DocBook +stylesheets and install in +/usr/[local/]lib/sgml/stylesheets (thereby creating a +subdirectory docbook). For indexing, copy or link collateindex.pl from the DocBook stylesheets archive in bin into a directory on your PATH. + -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 ISO +entities into /usr/[local/]lib/sgml. + + + + + + + +Configuring the DocBook tools + + +The supported way to do this is to edit one of the +CATALOG files in +fptools/glafp-utils/docbook to suit your system. +CATALOG.generic should work on most Unix systems when the files have been installed as per these instructions; CATALOG.cygnus 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 CATALOG, and placed in the same directory. + + + +Alternatively, if you have a properly working DocBook toolset (the FreeBSD package is likely to be one such), set SGML_CATALOG_FILES 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 CATALOG in glafp-utils/docbook and SGML_CATALOG_FILES is unset. -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. + + + +Remaining problems + + +If you install from source, you'll get a pile of warnings of the form + +DTDDECL catalog entries are not supported + +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 DTDDECL entries from docbook.cat. + + + +