[project @ 2000-07-10 16:15:33 by rrt]
authorrrt <unknown>
Mon, 10 Jul 2000 16:15:36 +0000 (16:15 +0000)
committerrrt <unknown>
Mon, 10 Jul 2000 16:15:36 +0000 (16:15 +0000)
Removed carriage returns (\r) from source files. Please don't check in such
things; they can cause problems on Cygwin (funnily enough). I'm looking into
how to avoid commiting carriage returns when working under Windows.

docs/cvs-cheat-sheet.html
ghc/ANNOUNCE
ghc/interpreter/test/static/s108.hs
ghc/tests/typecheck/should_compile/tc105.hs
glafp-utils/docbook/Makefile
glafp-utils/nofib-analyse/ClassTable.hs
glafp-utils/nofib-analyse/DataHtml.hs
glafp-utils/nofib-analyse/OptTable.hs

index 76f4c2e..93e42c0 100644 (file)
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
-<html>\r
-\r
-<head>\r
-<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">\r
-<meta NAME="GENERATOR" CONTENT="Microsoft FrontPage 3.0">\r
-<title>Access To The GHC CVS Repository</title>\r
-</head>\r
-\r
-<body TEXT="#2C3361" BGCOLOR="#FFFFFF" ALINK="#11BBFF">\r
-\r
-<h1><b>FP Tools CVS Cheat Sheet</b></h1>\r
-\r
-<p>We use CVS (Concurrent Version System) to keep track of our sources for various\r
-software projects. CVS lets several people work on the same software at the same time,\r
-allowing changes to be checked in incrementally. </p>\r
-\r
-<p>Information on using CVS can be obtained from <a HREF="http://www.cyclic.com">Cyclic\r
-Software</a>. </p>\r
-\r
-<p>This note is supposed to be a set of guidelines for how to use our CVS repository, and\r
-will probably evolve in time. The main thing to remember is that most mistakes can be\r
-undone, but if there's anything you're not sure about feel free to bug the local CVS\r
-meister (namely <a HREF="mailto:jlewis@cse.ogi.edu">Jeff Lewis</a>). </p>\r
-\r
-<p><b>Contents</b> \r
-\r
-<ul>\r
-  <li><a HREF="#read-only">Read-only remote access</a></li>\r
-  <li><a HREF="#read-write">Read-write remote access</a></li>\r
-  <li><a HREF="#first">Using CVS for the first time</a></li>\r
-  <li><a HREF="#checkout">Checking out a source tree</a></li>\r
-  <li><a HREF="#commit">Committing changes</a></li>\r
-  <li><a HREF="#update">Updating your source tree</a></li>\r
-  <li><a HREF="#hints">General Hints</a></li>\r
-</ul>\r
-\r
-<h2><a NAME="read-only"></a><b>Remote Read-only CVS Access</b></h2>\r
-\r
-<p>Read-only access is available to anyone - there's no need to ask us first. To get\r
-read-only access to our repository:\r
-\r
-<ul>\r
-  <li>set your CVSROOT environment variable to <tt>:pserver:anoncvs@glass.cse.ogi.edu:/cvs</tt></li>\r
-  <li>The first time you access the repository, you'll need to do <tt>cvs login</tt>.&nbsp;\r
-    The password is simply <tt>cvs</tt>.&nbsp; This sets up a file in your home directory\r
-    called <tt>.cvspass</tt>, which squirrels away the dummy password, so you only need to do\r
-    this step one time.</li>\r
-  <li>Now, you can check out a source tree using normal CVS commands. For example:</li>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs checkout fpconfig\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cd fptools\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs checkout ghc</pre>\r
-  <p>gets a brand spanking new set of GHC sources.</p>\r
-</ul>\r
-\r
-<p>The layout of our CVS repository is described below, under <a HREF="#first">Using CVS\r
-for the first time</a>. </p>\r
-\r
-<p>With read-only CVS access you can do anything except commit changes to the repository.\r
-You can make changes to your local tree, and still use CVS's merge facility to keep your\r
-tree up to date, and you can generate patches using 'cvs diff' in order to send to us for\r
-inclusion. </p>\r
-\r
-<h2><a NAME="read-write"></a><b>Remote Read-Write CVS Access</b></h2>\r
-\r
-<p>We generally supply read-write access to folk doing serious development on some part of\r
-the source tree, when going through us would be a pain. If you're developing some feature,\r
-or think you have the time and inclination to fix bugs in our sources, feel free to ask\r
-for read-write access. There is a certain amount of responsibility that goes with commit\r
-privileges; we are more likely to grant you access if you've demonstrated your competence\r
-by sending us patches via mail in the past. </p>\r
-\r
-<p>To use remote CVS, you need to supply me with a username and\r
-encrypted password. Once you've done that and the account on\r
-cvs.haskell.org has been set up, you need to install <a\r
-HREF="http://www.ssh.fi/">ssh</a>, which is relatively painless.  Log\r
-in to cvs.haskell.org, and set up your <tt>.ssh/authorized_keys</tt>\r
-file to allow logins from your local machine without a password (the\r
-ssh documentation has details on how to do this).  Then, just\r
-\r
-<ul>\r
-  <li> set your <tt>CVSROOT</tt> environment variable to <tt>:ext:&lt;username&gt;@cvs.haskell.org:/home/cvs/root</tt>.\r
-  </li>\r
-  <li>set your<tt> CVS_RSH </tt>environment variable to <tt>ssh</tt>.</li>\r
-</ul>\r
-\r
-<p>The <tt>CVSROOT</tt> environment variable will be recorded in the checked-out tree, so\r
-you don't need to set this every time either. Ignore the instructions for setting <tt>CVSROOT</tt>\r
-below. </p>\r
-<b>\r
-\r
-<p>Caveats:</b> \r
-\r
-<ul>\r
-  <li>Setting your <tt>CVS_RSH</tt> to <tt>ssh</tt> assumes that your CVS client understands\r
-    how to execute shell script (&quot;#!&quot;s,really), which is what <tt>ssh</tt> is. This\r
-    may not be the case on some platforms (read: Win32), so in that case set <tt>CVS_RSH</tt>\r
-    to <tt>ssh1</tt>.</li>\r
-</ul>\r
-\r
-<h2><a NAME="first"></a><b>Using CVS for the First Time</b></h2>\r
-\r
-<ul>\r
-  <li>(ok, everybody now...) Firstly, identify which areas of the source tree you'll be\r
-    working on. The directory structure looks like this:</li>\r
-  <div align="center"><center><table>\r
-    <tr>\r
-      <td>fptools/ghc&nbsp;</td>\r
-      <td>GHC</td>\r
-    </tr>\r
-    <tr>\r
-      <td>fptools/happy&nbsp;</td>\r
-      <td>Happy</td>\r
-    </tr>\r
-    <tr>\r
-      <td>fptools/green-card&nbsp;</td>\r
-      <td>Green Card</td>\r
-    </tr>\r
-    <tr>\r
-      <td>fptools/nofib&nbsp;</td>\r
-      <td>Nofib test suite</td>\r
-    </tr>\r
-    <tr>\r
-      <td>fptools/hdirect&nbsp;</td>\r
-      <td>IDL-to-Haskell compiler</td>\r
-    </tr>\r
-  </table>\r
-  </center></div><p>For each directory, there's a mailing list: <tt>cvs-ghc</tt>, <tt>cvs-nofib</tt>\r
-  etc. Everyone on the mailing list is sent a message automatically by CVS whenever someone\r
-  checks in a change, this helps to keep track of what's going on when several people are\r
-  working on related stuff. To join any of these mailing lists, mail <a\r
-  href="mailto:majordomo@haskell.org">majordomo@haskell.org</a>. </p>\r
-  <li>Create a .cvsrc file. Mine looks like this:</li>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; checkout -P\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; release -d\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; update -P\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diff -c</pre>\r
-  <p>It just gives default flags for some of the CVS commands. For instance, the -P flag to\r
-  'checkout' says prune empty directories, which is normally what you want.</p>\r
-</ul>\r
-\r
-<h2><a NAME="checkout"></a><b>Checking Out a Source Tree</b></h2>\r
-\r
-<ul>\r
-  <li>Check out your sources. Make sure you set your <tt>CVSROOT</tt> environment variable\r
-    according to either of the remote methods above. The Approved Way (at least by me) to\r
-    check out a source tree is as follows:</li>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs checkout fpconfig</pre>\r
-  <p>At this point you have a new directory called 'fptools' which contains the basic stuff\r
-  for the fptools suite - including the configuration files and some other junk. </p>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ mv fptools &lt;directory&gt;</pre>\r
-  <p>You can call the fptools directory whatever you like, CVS won't mind. </p>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cd &lt;directory&gt;\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs checkout ghc happy</pre>\r
-  <p>The second command here checks out the relevant modules you want to work on. For a GHC\r
-  build, for instance, you need at least the <tt>ghc</tt> module (in fact you can get away\r
-  with just that).</p>\r
-</ul>\r
-\r
-<h2><a NAME="commit"></a><b>Committing Your Changes</b></h2>\r
-\r
-<p>This is only if you have read-write access to the repository. For anoncvs users, CVS\r
-will issue a &quot;read-only repository&quot; error if you try to commit changes. \r
-\r
-<ul>\r
-  <li>Build the software, if necessary. Unless you're just working on documentation, you'll\r
-    probably want to build the software in order to test any changes you make. For GHC,\r
-    instructions can be found in the GHC installation guide.</li>\r
-  <li>Make changes. Preferably small ones first.</li>\r
-  <li>Test them. You can see exactly what changes you've made by using the <tt>cvs diff</tt>\r
-    command. For example, <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs diff</pre>\r
-    <p>lists all the changes (using the <tt>diff</tt> command) in and below the current\r
-    directory. In emacs, C-c C-v C-= runs <tt>cvs diff</tt> on the current buffer and shows\r
-    you the results.</p>\r
-  </li>\r
-  <li>Before checking in a change, you need to update your source tree:</li>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cd fptools\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs update</pre>\r
-  <p>This pulls in any changes that other people have made, and merges them with yours. If\r
-  there are any conflicts, CVS will tell you, and you'll have to resolve them before you can\r
-  check your changes in. The documentation describes what to do in the event of a conflict. </p>\r
-  <p>It's not always necessary to do a full cvs update before checking in a change, since\r
-  CVS will always tell you if you try to check in a file that someone else has changed.\r
-  However, you should still update at regular intervals to avoid making changes that don't\r
-  work in conjuction with changes that someone else made. Keeping an eye on what goes by on\r
-  the mailing list can help here. <br>\r
-  &nbsp; <br>\r
-  &nbsp; </p>\r
-  <li>When you're happy that your change isn't going to break anything, check it in. For a\r
-    one-file change:</li>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs commit &lt;filename&gt;</pre>\r
-  <p>CVS will then pop up an editor for you to enter a &quot;commit message&quot;, this is\r
-  just a short description of what your change does, and will be kept in the history of the\r
-  file. </p>\r
-  <p>If you're using emacs, simply load up the file into a buffer and type C-x C-q, and\r
-  emacs will prompt for a commit message and then check in the file for you. </p>\r
-  <p>For a multiple-file change, things are a bit trickier. There are several ways to do\r
-  this, but this is the way I find easiest. First type the commit message into a temporary\r
-  file. Then either </p>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs commit -F &lt;commit-message&gt; &lt;file_1&gt; .... &lt;file_n&gt;</pre>\r
-  <p>or, if nothing else has changed in this part of the source tree, </p>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs commit -F &lt;commit-message&gt; &lt;directory&gt;</pre>\r
-  <p>where &lt;directory&gt; is a common parent directory for all your changes, and\r
-  &lt;commit-message&gt; is the name of the file containing the commit message. </p>\r
-  <p>Shortly afterwards, you'll get some mail from the relevant mailing list saying which\r
-  files changed, and giving the commit message. For a multiple-file change, you should still\r
-  get only *one* message.</p>\r
-</ul>\r
-\r
-<h2><a NAME="update"></a><b>Updating Your Source Tree</b></h2>\r
-\r
-<p>It can be tempting to cvs update just part of a source tree to bring in some changes\r
-that someone else has made, or before committing your own changes. This is NOT\r
-RECOMMENDED! Quite often changes in one part of the tree are dependent on changes in\r
-another part of the tree (the <tt>mk/*.mk</tt> files are a good example where problems\r
-crop up quite often). Having an inconsistent tree is a major cause of headaches. </p>\r
-\r
-<p>So, to avoid a lot of hassle, follow this recipe for updating your tree: </p>\r
-\r
-<pre>$ cd fptools\r
-$ cvs update -Pd 2&gt;&amp;1 | tee log</pre>\r
-\r
-<p>Look at the log file, and fix any conflicts (denoted by a 'C' in the first column). If\r
-you're using multiple build trees, then for every build tree you have pointing at this\r
-source tree, you need to update the links in case any new files have appeared: </p>\r
-\r
-<pre>$ cd &lt;build-tree&gt;\r
-$ lndir &lt;source-tree&gt;</pre>\r
-\r
-<p>Some files might have been removed, so you need to remove the links pointing to these\r
-non-existent files: </p>\r
-\r
-<pre>$ find . -xtype l -exec rm '{}' \;</pre>\r
-\r
-<p>And finally, re-configure to take into accound any changes in mk/config.mk.in. </p>\r
-\r
-<pre>$ ./configure</pre>\r
-\r
-<p>To be *really* safe, you should do </p>\r
-\r
-<pre>$ gmake boot &amp;&amp; gmake all</pre>\r
-\r
-<p>from the top-level, to update the dependencies and build any changed files. </p>\r
-\r
-<h2><a NAME="tags"></a><b>GHC Tag Policy</b></h2>\r
-\r
-If you want to check out a particular version of GHC, you'll need to\r
-know how we tag versions in the repository.  The policy (as of 4.04)\r
-is:\r
-\r
-<ul>\r
-   <li> The tree is branched before every major release.  The branch\r
-   tag is <tt>ghc-x-xx-branch</tt>, where <tt>x-xx</tt> is the version\r
-   number of the release with the <tt>'.'</tt> replaced by a\r
-   <tt>'-'</tt>.  For example, the 4.04 release lives on\r
-   <tt>ghc-4-04-branch</tt>.</li>\r
-\r
-   <li> The release itself is tagged with <tt>ghc-x-xx</tt> (on the\r
-   branch).  eg. 4.06 is called <tt>ghc-4-06</tt>.</li>\r
-\r
-   <li> We didn't always follow these guidelines, so to see what tags\r
-   there are for previous versions, do <tt>cvs log</tt> on a file\r
-   that's been around for a while (like <tt>fptools/ghc/README</tt>).\r
-</ul>\r
-\r
-So, to check out a fresh GHC 4.06 tree you would do:\r
-\r
-<pre>\r
-     $ cvs co -r ghc-4-06 fpconfig\r
-     $ cd fptools\r
-     $ cvs co -r ghc-4-06 ghc hslibs\r
-</pre>\r
-\r
-\r
-<h2><a NAME="hints"></a><b>General Hints</b></h2>\r
-\r
-<ul>\r
-  <li>As a general rule: commit changes in small units, preferably addressing one issue or\r
-    implementing a single feature. Provide a descriptive log message so that the repository\r
-    records exactly which changes were required to implement a given feature/fix a bug. I've\r
-    found this *very* useful in the past for finding out when a particular bug was introduced:\r
-    you can just wind back the CVS tree until the bug disappears.</li>\r
-  <li>Keep the sources at least *buildable* at any given time. No doubt bugs will creep in,\r
-    but it's quite easy to ensure that any change made at least leaves the tree in a buildable\r
-    state. We do nightly builds of GHC to keep an eye on what things work/don't work each day\r
-    and how we're doing in relation to previous verions. This idea is truely wrecked if the\r
-    compiler won't build in the first place!</li>\r
-  <li>To check out extra bits into an already-checked-out tree, use the following procedure.\r
-    Suppose you have a checked-out fptools tree containing just ghc, and you want to add nofib\r
-    to it:</li>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd fptools\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cvs checkout nofib</pre>\r
-  <p>or: </p>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd fptools\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cvs update -d nofib</pre>\r
-  <p>(the -d flag tells update to create a new directory). If you just want part of the\r
-  nofib suite, you can do </p>\r
-  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd fptools\r
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cvs checkout nofib/spectral</pre>\r
-  <p>This works because <tt>nofib</tt> is a module in its own right, and spectral is a\r
-  subdirectory of the nofib module. The path argument to checkout must always start with a\r
-  module name. There's no equivalent form of this command using <tt>update</tt>.</p>\r
-</ul>\r
-\r
-<h2>Reporting Bugs in the CVS sources</h2>\r
-\r
-<p> If you are reporting a bug or infelicity in the CVS version of\r
-GHC, please send your message to </p>\r
-\r
-<table align="center">\r
-<tr><td>\r
-       <a href="mailto:cvs-ghc@haskell.org">cvs-ghc@haskell.org</a><td></td>\r
-</td></tr>\r
-<tr><td>\r
-       <a href="mailto:cvs-hslibs@haskell.org">cvs-hslibs@haskell.org</a> \r
-       <td>(for hslibs/ stuff)</td>\r
-</td></tr>\r
-<tr><td>\r
-       <a href="mailto:cvs-nofib@haskell.org">cvs-nofib@haskell.org</a>\r
-       <td>(for nofib/ stuff)</td>\r
-</td></tr>\r
-</table>\r
-\r
-<p>(not to glasgow-haskell-bugs).   Two reasons:</p>\r
-\r
-<ul>\r
-<li> Readers of glasgow-haskell-bugs will get less junk mail</li>\r
-\r
-<li> I'm a little worried that ghc-bugs readers are beginning to think\r
-  "is ghc really this unreliable?"!    The checked-in-last-night version\r
-  of GHC just isn't going to be solid.  No one expects it to be.  But\r
-  a casual reader might not distinguish.</li>\r
-</ul>\r
-\r
-<p>Please don't stop sending bug reports though.  They are really useful.</p>\r
-\r
-<hr>\r
-\r
-<p>Ok, that'll do for now. If there's anything else you'd like to see\r
-in this file, just let us know. </p>\r
-\r
-<table>\r
-  <tr>\r
-    <td><a HREF="mailto:jlewis@cse.ogi.edu">Jeff Lewis</a> </td>\r
-  </tr>\r
-  <tr>\r
-    <td><a HREF="mailto:simonm@dcs.gla.ac.uk">Simon Marlow</a> </td>\r
-  </tr>\r
-</table>\r
-</body>\r
-</html>\r
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+
+<head>
+<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
+<meta NAME="GENERATOR" CONTENT="Microsoft FrontPage 3.0">
+<title>Access To The GHC CVS Repository</title>
+</head>
+
+<body TEXT="#2C3361" BGCOLOR="#FFFFFF" ALINK="#11BBFF">
+
+<h1><b>FP Tools CVS Cheat Sheet</b></h1>
+
+<p>We use CVS (Concurrent Version System) to keep track of our sources for various
+software projects. CVS lets several people work on the same software at the same time,
+allowing changes to be checked in incrementally. </p>
+
+<p>Information on using CVS can be obtained from <a HREF="http://www.cyclic.com">Cyclic
+Software</a>. </p>
+
+<p>This note is supposed to be a set of guidelines for how to use our CVS repository, and
+will probably evolve in time. The main thing to remember is that most mistakes can be
+undone, but if there's anything you're not sure about feel free to bug the local CVS
+meister (namely <a HREF="mailto:jlewis@cse.ogi.edu">Jeff Lewis</a>). </p>
+
+<p><b>Contents</b> 
+
+<ul>
+  <li><a HREF="#read-only">Read-only remote access</a></li>
+  <li><a HREF="#read-write">Read-write remote access</a></li>
+  <li><a HREF="#first">Using CVS for the first time</a></li>
+  <li><a HREF="#checkout">Checking out a source tree</a></li>
+  <li><a HREF="#commit">Committing changes</a></li>
+  <li><a HREF="#update">Updating your source tree</a></li>
+  <li><a HREF="#hints">General Hints</a></li>
+</ul>
+
+<h2><a NAME="read-only"></a><b>Remote Read-only CVS Access</b></h2>
+
+<p>Read-only access is available to anyone - there's no need to ask us first. To get
+read-only access to our repository:
+
+<ul>
+  <li>set your CVSROOT environment variable to <tt>:pserver:anoncvs@glass.cse.ogi.edu:/cvs</tt></li>
+  <li>The first time you access the repository, you'll need to do <tt>cvs login</tt>.&nbsp;
+    The password is simply <tt>cvs</tt>.&nbsp; This sets up a file in your home directory
+    called <tt>.cvspass</tt>, which squirrels away the dummy password, so you only need to do
+    this step one time.</li>
+  <li>Now, you can check out a source tree using normal CVS commands. For example:</li>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs checkout fpconfig
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cd fptools
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs checkout ghc</pre>
+  <p>gets a brand spanking new set of GHC sources.</p>
+</ul>
+
+<p>The layout of our CVS repository is described below, under <a HREF="#first">Using CVS
+for the first time</a>. </p>
+
+<p>With read-only CVS access you can do anything except commit changes to the repository.
+You can make changes to your local tree, and still use CVS's merge facility to keep your
+tree up to date, and you can generate patches using 'cvs diff' in order to send to us for
+inclusion. </p>
+
+<h2><a NAME="read-write"></a><b>Remote Read-Write CVS Access</b></h2>
+
+<p>We generally supply read-write access to folk doing serious development on some part of
+the source tree, when going through us would be a pain. If you're developing some feature,
+or think you have the time and inclination to fix bugs in our sources, feel free to ask
+for read-write access. There is a certain amount of responsibility that goes with commit
+privileges; we are more likely to grant you access if you've demonstrated your competence
+by sending us patches via mail in the past. </p>
+
+<p>To use remote CVS, you need to supply me with a username and
+encrypted password. Once you've done that and the account on
+cvs.haskell.org has been set up, you need to install <a
+HREF="http://www.ssh.fi/">ssh</a>, which is relatively painless.  Log
+in to cvs.haskell.org, and set up your <tt>.ssh/authorized_keys</tt>
+file to allow logins from your local machine without a password (the
+ssh documentation has details on how to do this).  Then, just
+
+<ul>
+  <li> set your <tt>CVSROOT</tt> environment variable to <tt>:ext:&lt;username&gt;@cvs.haskell.org:/home/cvs/root</tt>.
+  </li>
+  <li>set your<tt> CVS_RSH </tt>environment variable to <tt>ssh</tt>.</li>
+</ul>
+
+<p>The <tt>CVSROOT</tt> environment variable will be recorded in the checked-out tree, so
+you don't need to set this every time either. Ignore the instructions for setting <tt>CVSROOT</tt>
+below. </p>
+<b>
+
+<p>Caveats:</b> 
+
+<ul>
+  <li>Setting your <tt>CVS_RSH</tt> to <tt>ssh</tt> assumes that your CVS client understands
+    how to execute shell script (&quot;#!&quot;s,really), which is what <tt>ssh</tt> is. This
+    may not be the case on some platforms (read: Win32), so in that case set <tt>CVS_RSH</tt>
+    to <tt>ssh1</tt>.</li>
+</ul>
+
+<h2><a NAME="first"></a><b>Using CVS for the First Time</b></h2>
+
+<ul>
+  <li>(ok, everybody now...) Firstly, identify which areas of the source tree you'll be
+    working on. The directory structure looks like this:</li>
+  <div align="center"><center><table>
+    <tr>
+      <td>fptools/ghc&nbsp;</td>
+      <td>GHC</td>
+    </tr>
+    <tr>
+      <td>fptools/happy&nbsp;</td>
+      <td>Happy</td>
+    </tr>
+    <tr>
+      <td>fptools/green-card&nbsp;</td>
+      <td>Green Card</td>
+    </tr>
+    <tr>
+      <td>fptools/nofib&nbsp;</td>
+      <td>Nofib test suite</td>
+    </tr>
+    <tr>
+      <td>fptools/hdirect&nbsp;</td>
+      <td>IDL-to-Haskell compiler</td>
+    </tr>
+  </table>
+  </center></div><p>For each directory, there's a mailing list: <tt>cvs-ghc</tt>, <tt>cvs-nofib</tt>
+  etc. Everyone on the mailing list is sent a message automatically by CVS whenever someone
+  checks in a change, this helps to keep track of what's going on when several people are
+  working on related stuff. To join any of these mailing lists, mail <a
+  href="mailto:majordomo@haskell.org">majordomo@haskell.org</a>. </p>
+  <li>Create a .cvsrc file. Mine looks like this:</li>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; checkout -P
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; release -d
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; update -P
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; diff -c</pre>
+  <p>It just gives default flags for some of the CVS commands. For instance, the -P flag to
+  'checkout' says prune empty directories, which is normally what you want.</p>
+</ul>
+
+<h2><a NAME="checkout"></a><b>Checking Out a Source Tree</b></h2>
+
+<ul>
+  <li>Check out your sources. Make sure you set your <tt>CVSROOT</tt> environment variable
+    according to either of the remote methods above. The Approved Way (at least by me) to
+    check out a source tree is as follows:</li>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs checkout fpconfig</pre>
+  <p>At this point you have a new directory called 'fptools' which contains the basic stuff
+  for the fptools suite - including the configuration files and some other junk. </p>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ mv fptools &lt;directory&gt;</pre>
+  <p>You can call the fptools directory whatever you like, CVS won't mind. </p>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cd &lt;directory&gt;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs checkout ghc happy</pre>
+  <p>The second command here checks out the relevant modules you want to work on. For a GHC
+  build, for instance, you need at least the <tt>ghc</tt> module (in fact you can get away
+  with just that).</p>
+</ul>
+
+<h2><a NAME="commit"></a><b>Committing Your Changes</b></h2>
+
+<p>This is only if you have read-write access to the repository. For anoncvs users, CVS
+will issue a &quot;read-only repository&quot; error if you try to commit changes. 
+
+<ul>
+  <li>Build the software, if necessary. Unless you're just working on documentation, you'll
+    probably want to build the software in order to test any changes you make. For GHC,
+    instructions can be found in the GHC installation guide.</li>
+  <li>Make changes. Preferably small ones first.</li>
+  <li>Test them. You can see exactly what changes you've made by using the <tt>cvs diff</tt>
+    command. For example, <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs diff</pre>
+    <p>lists all the changes (using the <tt>diff</tt> command) in and below the current
+    directory. In emacs, C-c C-v C-= runs <tt>cvs diff</tt> on the current buffer and shows
+    you the results.</p>
+  </li>
+  <li>Before checking in a change, you need to update your source tree:</li>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cd fptools
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs update</pre>
+  <p>This pulls in any changes that other people have made, and merges them with yours. If
+  there are any conflicts, CVS will tell you, and you'll have to resolve them before you can
+  check your changes in. The documentation describes what to do in the event of a conflict. </p>
+  <p>It's not always necessary to do a full cvs update before checking in a change, since
+  CVS will always tell you if you try to check in a file that someone else has changed.
+  However, you should still update at regular intervals to avoid making changes that don't
+  work in conjuction with changes that someone else made. Keeping an eye on what goes by on
+  the mailing list can help here. <br>
+  &nbsp; <br>
+  &nbsp; </p>
+  <li>When you're happy that your change isn't going to break anything, check it in. For a
+    one-file change:</li>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs commit &lt;filename&gt;</pre>
+  <p>CVS will then pop up an editor for you to enter a &quot;commit message&quot;, this is
+  just a short description of what your change does, and will be kept in the history of the
+  file. </p>
+  <p>If you're using emacs, simply load up the file into a buffer and type C-x C-q, and
+  emacs will prompt for a commit message and then check in the file for you. </p>
+  <p>For a multiple-file change, things are a bit trickier. There are several ways to do
+  this, but this is the way I find easiest. First type the commit message into a temporary
+  file. Then either </p>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs commit -F &lt;commit-message&gt; &lt;file_1&gt; .... &lt;file_n&gt;</pre>
+  <p>or, if nothing else has changed in this part of the source tree, </p>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ cvs commit -F &lt;commit-message&gt; &lt;directory&gt;</pre>
+  <p>where &lt;directory&gt; is a common parent directory for all your changes, and
+  &lt;commit-message&gt; is the name of the file containing the commit message. </p>
+  <p>Shortly afterwards, you'll get some mail from the relevant mailing list saying which
+  files changed, and giving the commit message. For a multiple-file change, you should still
+  get only *one* message.</p>
+</ul>
+
+<h2><a NAME="update"></a><b>Updating Your Source Tree</b></h2>
+
+<p>It can be tempting to cvs update just part of a source tree to bring in some changes
+that someone else has made, or before committing your own changes. This is NOT
+RECOMMENDED! Quite often changes in one part of the tree are dependent on changes in
+another part of the tree (the <tt>mk/*.mk</tt> files are a good example where problems
+crop up quite often). Having an inconsistent tree is a major cause of headaches. </p>
+
+<p>So, to avoid a lot of hassle, follow this recipe for updating your tree: </p>
+
+<pre>$ cd fptools
+$ cvs update -Pd 2&gt;&amp;1 | tee log</pre>
+
+<p>Look at the log file, and fix any conflicts (denoted by a 'C' in the first column). If
+you're using multiple build trees, then for every build tree you have pointing at this
+source tree, you need to update the links in case any new files have appeared: </p>
+
+<pre>$ cd &lt;build-tree&gt;
+$ lndir &lt;source-tree&gt;</pre>
+
+<p>Some files might have been removed, so you need to remove the links pointing to these
+non-existent files: </p>
+
+<pre>$ find . -xtype l -exec rm '{}' \;</pre>
+
+<p>And finally, re-configure to take into accound any changes in mk/config.mk.in. </p>
+
+<pre>$ ./configure</pre>
+
+<p>To be *really* safe, you should do </p>
+
+<pre>$ gmake boot &amp;&amp; gmake all</pre>
+
+<p>from the top-level, to update the dependencies and build any changed files. </p>
+
+<h2><a NAME="tags"></a><b>GHC Tag Policy</b></h2>
+
+If you want to check out a particular version of GHC, you'll need to
+know how we tag versions in the repository.  The policy (as of 4.04)
+is:
+
+<ul>
+   <li> The tree is branched before every major release.  The branch
+   tag is <tt>ghc-x-xx-branch</tt>, where <tt>x-xx</tt> is the version
+   number of the release with the <tt>'.'</tt> replaced by a
+   <tt>'-'</tt>.  For example, the 4.04 release lives on
+   <tt>ghc-4-04-branch</tt>.</li>
+
+   <li> The release itself is tagged with <tt>ghc-x-xx</tt> (on the
+   branch).  eg. 4.06 is called <tt>ghc-4-06</tt>.</li>
+
+   <li> We didn't always follow these guidelines, so to see what tags
+   there are for previous versions, do <tt>cvs log</tt> on a file
+   that's been around for a while (like <tt>fptools/ghc/README</tt>).
+</ul>
+
+So, to check out a fresh GHC 4.06 tree you would do:
+
+<pre>
+     $ cvs co -r ghc-4-06 fpconfig
+     $ cd fptools
+     $ cvs co -r ghc-4-06 ghc hslibs
+</pre>
+
+
+<h2><a NAME="hints"></a><b>General Hints</b></h2>
+
+<ul>
+  <li>As a general rule: commit changes in small units, preferably addressing one issue or
+    implementing a single feature. Provide a descriptive log message so that the repository
+    records exactly which changes were required to implement a given feature/fix a bug. I've
+    found this *very* useful in the past for finding out when a particular bug was introduced:
+    you can just wind back the CVS tree until the bug disappears.</li>
+  <li>Keep the sources at least *buildable* at any given time. No doubt bugs will creep in,
+    but it's quite easy to ensure that any change made at least leaves the tree in a buildable
+    state. We do nightly builds of GHC to keep an eye on what things work/don't work each day
+    and how we're doing in relation to previous verions. This idea is truely wrecked if the
+    compiler won't build in the first place!</li>
+  <li>To check out extra bits into an already-checked-out tree, use the following procedure.
+    Suppose you have a checked-out fptools tree containing just ghc, and you want to add nofib
+    to it:</li>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd fptools
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cvs checkout nofib</pre>
+  <p>or: </p>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd fptools
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cvs update -d nofib</pre>
+  <p>(the -d flag tells update to create a new directory). If you just want part of the
+  nofib suite, you can do </p>
+  <pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cd fptools
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cvs checkout nofib/spectral</pre>
+  <p>This works because <tt>nofib</tt> is a module in its own right, and spectral is a
+  subdirectory of the nofib module. The path argument to checkout must always start with a
+  module name. There's no equivalent form of this command using <tt>update</tt>.</p>
+</ul>
+
+<h2>Reporting Bugs in the CVS sources</h2>
+
+<p> If you are reporting a bug or infelicity in the CVS version of
+GHC, please send your message to </p>
+
+<table align="center">
+<tr><td>
+       <a href="mailto:cvs-ghc@haskell.org">cvs-ghc@haskell.org</a><td></td>
+</td></tr>
+<tr><td>
+       <a href="mailto:cvs-hslibs@haskell.org">cvs-hslibs@haskell.org</a> 
+       <td>(for hslibs/ stuff)</td>
+</td></tr>
+<tr><td>
+       <a href="mailto:cvs-nofib@haskell.org">cvs-nofib@haskell.org</a>
+       <td>(for nofib/ stuff)</td>
+</td></tr>
+</table>
+
+<p>(not to glasgow-haskell-bugs).   Two reasons:</p>
+
+<ul>
+<li> Readers of glasgow-haskell-bugs will get less junk mail</li>
+
+<li> I'm a little worried that ghc-bugs readers are beginning to think
+  "is ghc really this unreliable?"!    The checked-in-last-night version
+  of GHC just isn't going to be solid.  No one expects it to be.  But
+  a casual reader might not distinguish.</li>
+</ul>
+
+<p>Please don't stop sending bug reports though.  They are really useful.</p>
+
+<hr>
+
+<p>Ok, that'll do for now. If there's anything else you'd like to see
+in this file, just let us know. </p>
+
+<table>
+  <tr>
+    <td><a HREF="mailto:jlewis@cse.ogi.edu">Jeff Lewis</a> </td>
+  </tr>
+  <tr>
+    <td><a HREF="mailto:simonm@dcs.gla.ac.uk">Simon Marlow</a> </td>
+  </tr>
+</table>
+</body>
+</html>
index e0d2cf2..87417db 100644 (file)
-            The Glasgow Haskell Compiler -- version 4.08\r
-           ==============================================\r
-\r
-We are pleased to announce a new release of the Glasgow Haskell\r
-Compiler (GHC), version 4.08.  The source distribution is freely\r
-available via the World-Wide Web and through anon. FTP; details below.\r
-\r
-Haskell is "the" standard lazy functional programming language; the\r
-current language version is Haskell 98, agreed in December 1998.\r
-Haskell related information is available from the Haskell home page at\r
-\r
-       http://www.haskell.org/\r
-\r
-GHC's Web page lives at\r
-\r
-       http://www.haskell.org/ghc/\r
-\r
-+ What's new\r
-=============\r
-\r
-This should be a stable release.  There have been many enhancements\r
-since 4.06, and shed-loads of bug-fixes (one shed (imperial) ~ one ton\r
-(US)).\r
-\r
-There are the following changes\r
-\r
-   - New profiling subsystem, based on cost-centre stacks.\r
-\r
-   - Working x86 native code generator: now it works properly, runs\r
-     about twice as fast as compiling via C, and is on a par for\r
-     run-time speed (except in FP-intensive programs).\r
-\r
-   - Implicit parameters (i.e. dynamic scoping without the pain).\r
-\r
-   - DEPRECATED pragma for marking obsolescent interfaces.\r
-\r
-   - In the wake of hslibs, a new package system for\r
-     libraries. -package should now be used instead of -syslib.\r
-\r
-   - Result type signatures work.\r
-\r
-   - Many tiresome long-standing bugs and problems (e.g. the trace\r
-     problem) have been fixed.\r
-\r
-   - Many error messages have been made more helpful and/or\r
-     accurate.\r
-\r
-For full details see the release notes:\r
-\r
-       http://www.haskell.org/ghc/docs/4.08/users_guide/release-4-08.html\r
-\r
-\r
-+ Mailing lists\r
-================\r
-\r
-We run mailing lists for GHC users and bug reports; to subscribe, send\r
-mail to majordomo@haskell.org; the msg body should be:\r
-\r
-    subscribe glasgow-haskell-{users,bugs} Your Name <you@where.soever>\r
-\r
-or\r
-\r
-    subscribe cvs-ghc Your Name <you@where.soever>\r
-\r
-Please send bug reports about GHC to glasgow-haskell-bugs@haskell.org;\r
-GHC users hang out on glasgow-haskell-users@haskell.org.  Bleeding\r
-edge CVS users party on cvs-ghc@haskell.org.\r
-\r
-\r
-+ On-line GHC-related resources\r
-================================\r
-\r
-Relevant URLs on the World-Wide Web:\r
-\r
-GHC home page            http://www.haskell.org/ghc/\r
-Haskell home page        http://www.haskell.org/\r
-comp.lang.functional FAQ  http://www.cs.nott.ac.uk/~gmh/faq.html\r
-\r
-\r
-+ How to get it\r
-================\r
-\r
-The easy way is to go to the WWW page, which should be\r
-self-explanatory:\r
-\r
-       http://www.haskell.org/ghc/\r
-\r
-Once you have the distribution, please follow the pointers in the\r
-README file to find all of the documentation about this release.  NB:\r
-preserve modification times when un-tarring the files (no `m' option\r
-for tar, please)!\r
-\r
-\r
-+ System requirements\r
-======================\r
-\r
-To compile the sources, you need a machine with 32+MB memory, GNU C\r
-(`gcc'), `perl' plus a version of GHC installed (3.02 at least).  This\r
-release is known to work on the following platforms:\r
-\r
-  * i386-unknown-{linux,freebsd,netbsd,cygwin32,mingw32}\r
-  * sparc-sun-{sunos4,solaris2}\r
-  * hppa1.1-hp-hpux{9,10}\r
-\r
-Ports to the following platforms should be relatively easy (for a\r
-wunderhacker), but haven't been tested due to lack of time/hardware:\r
-\r
-  * i386-unknown-solaris2\r
-  * alpha-dec-osf{2,3}\r
-  * mips-sgi-irix{5,6}\r
-  * {rs6000,powerpc}-ibm-aix\r
-\r
-The builder's guide included in distribution gives a complete\r
-run-down of what ports work; an on-line version can be found at\r
-\r
-   http://www.haskell.org/ghc/docs/4.08/building/building-guide.html\r
+            The Glasgow Haskell Compiler -- version 4.08
+           ==============================================
+
+We are pleased to announce a new release of the Glasgow Haskell
+Compiler (GHC), version 4.08.  The source distribution is freely
+available via the World-Wide Web and through anon. FTP; details below.
+
+Haskell is "the" standard lazy functional programming language; the
+current language version is Haskell 98, agreed in December 1998.
+Haskell related information is available from the Haskell home page at
+
+       http://www.haskell.org/
+
+GHC's Web page lives at
+
+       http://www.haskell.org/ghc/
+
++ What's new
+=============
+
+This should be a stable release.  There have been many enhancements
+since 4.06, and shed-loads of bug-fixes (one shed (imperial) ~ one ton
+(US)).
+
+There are the following changes
+
+   - New profiling subsystem, based on cost-centre stacks.
+
+   - Working x86 native code generator: now it works properly, runs
+     about twice as fast as compiling via C, and is on a par for
+     run-time speed (except in FP-intensive programs).
+
+   - Implicit parameters (i.e. dynamic scoping without the pain).
+
+   - DEPRECATED pragma for marking obsolescent interfaces.
+
+   - In the wake of hslibs, a new package system for
+     libraries. -package should now be used instead of -syslib.
+
+   - Result type signatures work.
+
+   - Many tiresome long-standing bugs and problems (e.g. the trace
+     problem) have been fixed.
+
+   - Many error messages have been made more helpful and/or
+     accurate.
+
+For full details see the release notes:
+
+       http://www.haskell.org/ghc/docs/4.08/users_guide/release-4-08.html
+
+
++ Mailing lists
+================
+
+We run mailing lists for GHC users and bug reports; to subscribe, send
+mail to majordomo@haskell.org; the msg body should be:
+
+    subscribe glasgow-haskell-{users,bugs} Your Name <you@where.soever>
+
+or
+
+    subscribe cvs-ghc Your Name <you@where.soever>
+
+Please send bug reports about GHC to glasgow-haskell-bugs@haskell.org;
+GHC users hang out on glasgow-haskell-users@haskell.org.  Bleeding
+edge CVS users party on cvs-ghc@haskell.org.
+
+
++ On-line GHC-related resources
+================================
+
+Relevant URLs on the World-Wide Web:
+
+GHC home page            http://www.haskell.org/ghc/
+Haskell home page        http://www.haskell.org/
+comp.lang.functional FAQ  http://www.cs.nott.ac.uk/~gmh/faq.html
+
+
++ How to get it
+================
+
+The easy way is to go to the WWW page, which should be
+self-explanatory:
+
+       http://www.haskell.org/ghc/
+
+Once you have the distribution, please follow the pointers in the
+README file to find all of the documentation about this release.  NB:
+preserve modification times when un-tarring the files (no `m' option
+for tar, please)!
+
+
++ System requirements
+======================
+
+To compile the sources, you need a machine with 32+MB memory, GNU C
+(`gcc'), `perl' plus a version of GHC installed (3.02 at least).  This
+release is known to work on the following platforms:
+
+  * i386-unknown-{linux,freebsd,netbsd,cygwin32,mingw32}
+  * sparc-sun-{sunos4,solaris2}
+  * hppa1.1-hp-hpux{9,10}
+
+Ports to the following platforms should be relatively easy (for a
+wunderhacker), but haven't been tested due to lack of time/hardware:
+
+  * i386-unknown-solaris2
+  * alpha-dec-osf{2,3}
+  * mips-sgi-irix{5,6}
+  * {rs6000,powerpc}-ibm-aix
+
+The builder's guide included in distribution gives a complete
+run-down of what ports work; an on-line version can be found at
+
+   http://www.haskell.org/ghc/docs/4.08/building/building-guide.html
index 02954ae..c1c0933 100644 (file)
@@ -1,3 +1,3 @@
---!!! Testing export of unknown name\r
-module Bar(bar) where\r
+--!!! Testing export of unknown name
+module Bar(bar) where
 foo = foo
\ No newline at end of file
index 891f2c7..5738b67 100644 (file)
@@ -1,15 +1,15 @@
-{-# OPTIONS -fglasgow-exts #-}\r
-\r
--- !!! Scoped type variables in result signatures\r
-module ShouldCompile where\r
-\r
-import PrelST\r
-import PrelArr\r
-\r
-f:: ST s Int\r
-f:: ST s Int = do\r
-    v <- newSTRef 5\r
-    let g :: ST s Int\r
-             -- ^ should be in scope\r
-        g = readSTRef v\r
-    g\r
+{-# OPTIONS -fglasgow-exts #-}
+
+-- !!! Scoped type variables in result signatures
+module ShouldCompile where
+
+import PrelST
+import PrelArr
+
+f:: ST s Int
+f:: ST s Int = do
+    v <- newSTRef 5
+    let g :: ST s Int
+             -- ^ should be in scope
+        g = readSTRef v
+    g
index 724e437..8b94473 100644 (file)
@@ -1,6 +1,7 @@
 TOP=..
 include $(TOP)/mk/boilerplate.mk
 
-SUBDIRS = db2dvi.dir db2html.dir db2pdf.dir db2ps.dir db2rtf.dir
+SUBDIRS = db2dvi.dir db2html.dir db2pdf.dir db2ps.dir db2rtf.dir \
+          dbindex.dir
 
 include $(TOP)/mk/target.mk
index 78a1699..9472f16 100644 (file)
@@ -1,94 +1,94 @@
------------------------------------------------------------------------------\r
---     TableClass : Class for combinators used in building 2D tables.\r
---\r
---     Copyright (c) 1999 Andy Gill\r
---\r
--- This module is distributed as Open Source software under the\r
--- Artistic License; see the file "Artistic" that is included\r
--- in the distribution for details.\r
------------------------------------------------------------------------------\r
-\r
-module ClassTable (\r
-               Table(..),\r
-               showsTable,\r
-               showTable,\r
-       ) where\r
-\r
-infixr 4 `beside`\r
-infixr 3 `above`\r
-\r
-{----------------------------------------------------------------------------\r
-   These combinators can be used to build formated 2D tables.\r
-   The specific target useage is for HTML table generation.\r
- ----------------------------------------------------------------------------\r
-\r
-   Examples of use:\r
-\r
-       > table1 :: (Table t) => t String\r
-       > table1 = single "Hello"       +-----+\r
-                                       |Hello|\r
-         This is a 1x1 cell            +-----+\r
-         Note: single has type\r
-        \r
-               single :: (Table t) => a -> t a\r
-       \r
-         So the cells can contain anything.\r
-       \r
-       > table2 :: (Table t) => t String\r
-       > table2 = single "World"       +-----+\r
-                                       |World|\r
-                                       +-----+\r
-\r
-\r
-       > table3 :: (Table t) => t String\r
-       > table3 = table1 %-% table2    +-----%-----+\r
-                                       |Hello%World|\r
-        % is used to indicate          +-----%-----+\r
-        the join edge between\r
-        the two Tables.  \r
-\r
-       > table4 :: (Table t) => t String\r
-       > table4 = table3 %/% table2    +-----+-----+\r
-                                       |Hello|World|\r
-         Notice the padding on the     %%%%%%%%%%%%%\r
-         smaller (bottom) cell to      |World      |\r
-         force the table to be a       +-----------+\r
-         rectangle.\r
-\r
-       > table5 :: (Table t) => t String\r
-       > table5 = table1 %-% table4    +-----%-----+-----+\r
-                                       |Hello%Hello|World|\r
-         Notice the padding on the     |     %-----+-----+\r
-         leftmost cell, again to       |     %World      |\r
-         force the table to be a       +-----%-----------+\r
-         rectangle.\r
\r
-   Now the table can be rendered with processTable, for example:\r
-       Main> processTable table5\r
-       [[("Hello",(1,2)),\r
-         ("Hello",(1,1)),\r
-         ("World",(1,1))],\r
-        [("World",(2,1))]] :: [[([Char],(Int,Int))]]\r
-       Main> \r
-\r
-----------------------------------------------------------------------------}\r
-\r
-class Table t where\r
-       -- There are no empty tables\r
-\r
-       --Single element table\r
-  single       :: a          -> t a\r
-       -- horizontal composition\r
-  beside       :: t a -> t a -> t a\r
-       -- vertical composition\r
-  above        :: t a -> t a -> t a\r
-       -- generation of raw table matrix\r
-  getMatrix    :: t a -> [[(a,(Int,Int))]]\r
-\r
-showsTable :: (Show a,Table t) => t a -> ShowS\r
-showsTable table = shows (getMatrix table)\r
-\r
-showTable :: (Show a,Table t) => t a -> String\r
-showTable table = showsTable table ""\r
-\r
-\r
+-----------------------------------------------------------------------------
+--     TableClass : Class for combinators used in building 2D tables.
+--
+--     Copyright (c) 1999 Andy Gill
+--
+-- This module is distributed as Open Source software under the
+-- Artistic License; see the file "Artistic" that is included
+-- in the distribution for details.
+-----------------------------------------------------------------------------
+
+module ClassTable (
+               Table(..),
+               showsTable,
+               showTable,
+       ) where
+
+infixr 4 `beside`
+infixr 3 `above`
+
+{----------------------------------------------------------------------------
+   These combinators can be used to build formated 2D tables.
+   The specific target useage is for HTML table generation.
+ ----------------------------------------------------------------------------
+
+   Examples of use:
+
+       > table1 :: (Table t) => t String
+       > table1 = single "Hello"       +-----+
+                                       |Hello|
+         This is a 1x1 cell            +-----+
+         Note: single has type
+        
+               single :: (Table t) => a -> t a
+       
+         So the cells can contain anything.
+       
+       > table2 :: (Table t) => t String
+       > table2 = single "World"       +-----+
+                                       |World|
+                                       +-----+
+
+
+       > table3 :: (Table t) => t String
+       > table3 = table1 %-% table2    +-----%-----+
+                                       |Hello%World|
+        % is used to indicate          +-----%-----+
+        the join edge between
+        the two Tables.  
+
+       > table4 :: (Table t) => t String
+       > table4 = table3 %/% table2    +-----+-----+
+                                       |Hello|World|
+         Notice the padding on the     %%%%%%%%%%%%%
+         smaller (bottom) cell to      |World      |
+         force the table to be a       +-----------+
+         rectangle.
+
+       > table5 :: (Table t) => t String
+       > table5 = table1 %-% table4    +-----%-----+-----+
+                                       |Hello%Hello|World|
+         Notice the padding on the     |     %-----+-----+
+         leftmost cell, again to       |     %World      |
+         force the table to be a       +-----%-----------+
+         rectangle.
+   Now the table can be rendered with processTable, for example:
+       Main> processTable table5
+       [[("Hello",(1,2)),
+         ("Hello",(1,1)),
+         ("World",(1,1))],
+        [("World",(2,1))]] :: [[([Char],(Int,Int))]]
+       Main> 
+
+----------------------------------------------------------------------------}
+
+class Table t where
+       -- There are no empty tables
+
+       --Single element table
+  single       :: a          -> t a
+       -- horizontal composition
+  beside       :: t a -> t a -> t a
+       -- vertical composition
+  above        :: t a -> t a -> t a
+       -- generation of raw table matrix
+  getMatrix    :: t a -> [[(a,(Int,Int))]]
+
+showsTable :: (Show a,Table t) => t a -> ShowS
+showsTable table = shows (getMatrix table)
+
+showTable :: (Show a,Table t) => t a -> String
+showTable table = showsTable table ""
+
+
index 75aca4c..a603dff 100644 (file)
--------------------------------------------------------------------------------\r
--- $Id: DataHtml.hs,v 1.1 1999/11/12 11:54:17 simonmar Exp $\r
---\r
--- Copyright (c) 1999 Andy Gill\r
--------------------------------------------------------------------------------\r
-\r
-module DataHtml (\r
-       Html, HtmlName, HtmlAttr, HtmlTable,\r
-       (+++), verbatim, {- tag, atag, -} noHtml, primHtml, \r
-       concatHtml, htmlStr, htmlLine,\r
-       h1,h2,h3,h4,h5,h6,      \r
-       font, bold, anchor, header, body, theTitle, paragraph, italics,\r
-       ul, tt,\r
-       bar, meta, li,\r
-       {- tr, int, percent -}\r
-       color, bgcolor, href, name, title, height, width, align, valign,\r
-       border, size, cellpadding, cellspacing,\r
-       p, hr, copyright, spaceHtml, \r
-       renderHtml, \r
-       cellHtml, (+/+), above, (+-+), beside, aboves, besides,         \r
-       renderTable, simpleTable, \r
-       ) where\r
-\r
-import qualified OptTable as OT\r
-\r
-infixr 5 +++   -- appending Html\r
-infixr 3 +/+   -- combining HtmlTable\r
-infixr 4 +-+   -- combining HtmlTable\r
-\r
-data Html\r
-       = HtmlAppend Html Html            -- Some Html, followed by more text\r
-       | HtmlVerbatim Html               -- Turn on or off smart formating\r
-       | HtmlEmpty                       -- Nothing!\r
-       | HtmlNestingTag HtmlName [HtmlAttr] Html\r
-       | HtmlSimpleTag  HtmlName [HtmlAttr]\r
-       | HtmlString String\r
-               deriving (Show)\r
-\r
-{-\r
- - A important property of Html is all strings inside the\r
- - structure are already in Html friendly format.\r
- - For example, use of &gt;,etc.\r
- -}\r
-\r
-type HtmlName  = String\r
-type HtmlAttr  = (HtmlName,Either Int String)\r
-type HtmlTable = OT.OptTable (Int -> Int -> Html)\r
-\r
-------------------------------------------------------------------------------\r
--- Interface\r
-------------------------------------------------------------------------------\r
-\r
--- primitive combinators\r
-(+++)          :: Html -> Html                 -> Html\r
-verbatim       :: Html                         -> Html\r
-tag            :: String -> [HtmlAttr] -> Html -> Html\r
-atag           :: String -> [HtmlAttr]         -> Html\r
-noHtml         ::                                 Html\r
-primHtml       :: String                       -> Html\r
-\r
--- useful combinators\r
-concatHtml             :: [Html]                       -> Html\r
-htmlStr, htmlLine      :: String                       -> Html\r
-\r
--- html constructors\r
-h1,h2,h3,h4,h5,h6      :: [HtmlAttr] -> Html           -> Html\r
-font, bold, anchor, \r
- header, body, \r
- theTitle, paragraph,\r
- italics, ul, tt       :: [HtmlAttr] -> Html           -> Html\r
-bar, meta, li          :: [HtmlAttr]                   -> Html\r
-\r
--- html attributes\r
-str                    :: String -> String             -> HtmlAttr\r
-int                    :: String -> Int                -> HtmlAttr\r
-percent                :: String -> Int                -> HtmlAttr\r
-\r
-color, bgcolor, href,\r
- name, title, height,\r
- width, align, valign  :: String                       -> HtmlAttr\r
-\r
-border, size,\r
- cellpadding,\r
- cellspacing           :: Int                          -> HtmlAttr \r
-\r
--- abbriviations\r
-\r
-p                      :: Html                         -> Html\r
-hr                     ::                                 Html\r
-copyright              ::                                 Html\r
-spaceHtml              ::                                 Html\r
-\r
--- rendering\r
-renderHtml             :: Html -> String\r
-\r
--- html tables\r
-cellHtml               :: [HtmlAttr] -> Html           -> HtmlTable\r
-(+/+),above,\r
- (+-+),beside          :: HtmlTable -> HtmlTable       -> HtmlTable\r
-aboves, besides                :: [HtmlTable]                  -> HtmlTable\r
-renderTable            :: [HtmlAttr] -> HtmlTable      -> Html\r
-simpleTable            :: [HtmlAttr] -> [HtmlAttr] -> [[Html]] \r
-                                                       -> Html\r
-\r
-------------------------------------------------------------------------------\r
--- Basic, primitive combinators\r
-\r
--- This is intentionally lazy in the second argument.\r
-(HtmlAppend x y) +++ z = x +++ (y +++ z)\r
-(HtmlEmpty)      +++ z = z\r
-x                +++ z = HtmlAppend x z\r
-\r
-verbatim       = HtmlVerbatim\r
-tag            = HtmlNestingTag\r
-atag           = HtmlSimpleTag\r
-noHtml                 = HtmlEmpty\r
-\r
--- This is not processed for special chars. \r
--- It is used to output them, though!\r
-primHtml       = HtmlString\r
-\r
-------------------------------------------------------------------------------\r
--- Useful Combinators\r
-\r
-concatHtml = foldr (+++) noHtml\r
--- Processing Strings into Html friendly things.\r
--- This converts a string to an Html.\r
-htmlStr = primHtml . htmlizeStr\r
-\r
--- This converts a string, but keeps spaces as non-line-breakable\r
-htmlLine = primHtml . concat . map htmlizeChar2\r
-   where \r
-       htmlizeChar2 ' ' = "&nbsp;"\r
-       htmlizeChar2 c   = htmlizeChar c\r
-\r
--- Local Utilites\r
-htmlizeStr :: String -> String\r
-htmlizeStr = concat . map htmlizeChar\r
-\r
-htmlizeChar :: Char -> String\r
-htmlizeChar '<' = "&gt;"\r
-htmlizeChar '>' = "&lt;"\r
-htmlizeChar '&' = "&amb;"\r
-htmlizeChar '"' = "&quot;"\r
-htmlizeChar c   = [c]\r
-\r
-------------------------------------------------------------------------------\r
--- Html Constructors\r
-h n = tag ("h" ++ show n)\r
-\r
--- Isn't Haskell great!\r
-[h1,h2,h3,h4,h5,h6] = map h [1..6]\r
-\r
--- tags\r
-font                   = tag "font"\r
-bold           = tag "b"\r
-anchor         = tag "a"\r
-header                 = tag "header"\r
-body                   = tag "body"\r
-theTitle       = tag "title"\r
-paragraph      = tag "p"\r
-italics                = tag "i"\r
-ul             = tag "ul"\r
-tt             = tag "tt"\r
-\r
-bar            = atag "hr"\r
-meta           = atag "meta"\r
-li             = atag "li"\r
-\r
-------------------------------------------------------------------------------\r
--- Html Attributes\r
-\r
--- note: the string is presumed to be formated for output\r
---str :: String -> String -> HtmlAttr\r
-str n s = (n,Right s)\r
-\r
---int :: String -> Int -> HtmlAttr\r
-int n v = (n,Left v)\r
-\r
---percent :: String -> Int -> HtmlAttr\r
-percent n v = str n (show v ++ "%")\r
-\r
--- attributes\r
-color          = str "color"\r
-bgcolor        = str "bgcolor"\r
-href           = str "href"\r
-name           = str "name"\r
-title          = str "tile"\r
-height         = str "height" \r
-width          = str "width"\r
-align          = str "align"\r
-valign         = str "valign"\r
-\r
-border         = int "border" \r
-size           = int "size"\r
-cellpadding            = int "cellpadding"\r
-cellspacing            = int "cellspacing"\r
-\r
-------------------------------------------------------------------------------\r
--- abbriviations\r
-p              = paragraph []\r
-hr             = atag "hr" []\r
-copyright      = primHtml "&copy;"\r
-spaceHtml      = primHtml "&nbsp;"\r
-\r
-------------------------------------------------------------------------------\r
--- Rendering\r
-\r
-renderHtml html = renderHtml' html (Just 0) ++ footerMessage\r
-\r
-footerMessage \r
-   = "\n<!-- Generated using the Haskell HTML generator package HaskHTML -->\n"\r
-\r
-renderHtml' (HtmlAppend html1 html2) d\r
-       = renderHtml' html1 d ++ renderHtml' html2 d\r
-renderHtml' (HtmlVerbatim html1) d\r
-       = renderHtml' html1 Nothing\r
-renderHtml' (HtmlEmpty) d = ""\r
-renderHtml' (HtmlSimpleTag name attr) d\r
-       = renderTag True name attr d\r
-renderHtml' (HtmlNestingTag name attr html) d\r
-       = renderTag True name attr d ++ renderHtml' html (incDepth d) ++\r
-         renderTag False name [] d\r
-renderHtml' (HtmlString str) _ = str\r
-\r
-incDepth :: Maybe Int -> Maybe Int\r
-incDepth = fmap (+4)\r
-\r
--- This prints the tags in \r
-renderTag :: Bool -> HtmlName -> [HtmlAttr] -> Maybe Int -> String\r
-renderTag x name attrs n = start ++ base_spaces ++ open ++ name ++ rest attrs ++ ">"\r
-  where\r
-       open = if x then "<" else "</"\r
-       (start,base_spaces,sep) = case n of\r
-                             Nothing -> ("",""," ")\r
-                             Just n ->  ("\n",replicate n ' ',"\n")\r
-                       \r
-       rest []            = ""\r
-       rest [(tag,val)]   = " " ++ tag ++ "=" ++ myShow val \r
-       rest (hd:tl)       = " " ++ showPair hd ++ sep ++\r
-                 foldr1 (\ x y -> x ++ sep ++ y)\r
-                        [ base_spaces ++ replicate (1 + length name + 1) ' ' \r
-                               ++ showPair p | p <- tl ]\r
-\r
-       showPair :: HtmlAttr -> String\r
-       showPair (tag,val) = tag ++ replicate (tagsz - length tag) ' ' ++ \r
-                       " = " ++ myShow val \r
-       myShow (Left n) = show n\r
-       myShow (Right s) = "\"" ++ s ++ "\""\r
-\r
-       tagsz = maximum (map (length.fst) attrs)\r
-\r
-------------------------------------------------------------------------------\r
--- Html table related things\r
-\r
-cellHtml attr html = OT.single cellFn\r
-    where\r
-       cellFn x y = tag "td" (addX x (addY y attr)) html\r
-       addX 1 rest = rest\r
-       addX n rest = int "colspan" n : rest\r
-       addY 1 rest = rest\r
-       addY n rest = int "rowspan" n : rest\r
-\r
-above  = OT.above\r
-(+/+)  = above\r
-beside = OT.beside\r
-(+-+)  = beside\r
-\r
-{-\r
- - Note: Both aboves and besides presume a non-empty list.\r
- -}\r
-\r
-aboves = foldl1 (+/+)\r
-besides = foldl1 (+-+)\r
-\r
--- renderTable takes the HtmlTable, and renders it back into\r
--- and Html object. The attributes are added to the outside\r
--- table tag.\r
-\r
-renderTable attr theTable\r
-       = table [row [theCell x y | (theCell,(x,y)) <- theRow ] \r
-                       | theRow <- OT.getMatrix theTable]\r
-   where\r
-       row :: [Html] -> Html\r
-       row  = tag "tr" [] . concatHtml\r
-\r
-       table :: [Html] -> Html\r
-       table = tag "table" attr . concatHtml\r
-\r
--- If you cant be bothered with the above, then you\r
--- can build simple tables with this.\r
--- Just provide the attributes for the whole table,\r
--- attributes for the cells (same for every cell),\r
--- and a list of list of cell contents,\r
--- and this function will build the table for you.\r
--- It does presume that all the lists are non-empty,\r
--- and there is at least one list.\r
---  \r
--- Different length lists means that the last cell\r
--- gets padded. If you want more power, then\r
--- use the system above.\r
-\r
-simpleTable attr cellAttr\r
-       = renderTable attr \r
-       . aboves\r
-       . map (besides . map (cellHtml cellAttr))\r
-\r
-       \r
-------------------------------------------------------------------------------\r
+-------------------------------------------------------------------------------
+-- $Id: DataHtml.hs,v 1.2 2000/07/10 16:15:34 rrt Exp $
+--
+-- Copyright (c) 1999 Andy Gill
+-------------------------------------------------------------------------------
+
+module DataHtml (
+       Html, HtmlName, HtmlAttr, HtmlTable,
+       (+++), verbatim, {- tag, atag, -} noHtml, primHtml, 
+       concatHtml, htmlStr, htmlLine,
+       h1,h2,h3,h4,h5,h6,      
+       font, bold, anchor, header, body, theTitle, paragraph, italics,
+       ul, tt,
+       bar, meta, li,
+       {- tr, int, percent -}
+       color, bgcolor, href, name, title, height, width, align, valign,
+       border, size, cellpadding, cellspacing,
+       p, hr, copyright, spaceHtml, 
+       renderHtml, 
+       cellHtml, (+/+), above, (+-+), beside, aboves, besides,         
+       renderTable, simpleTable, 
+       ) where
+
+import qualified OptTable as OT
+
+infixr 5 +++   -- appending Html
+infixr 3 +/+   -- combining HtmlTable
+infixr 4 +-+   -- combining HtmlTable
+
+data Html
+       = HtmlAppend Html Html            -- Some Html, followed by more text
+       | HtmlVerbatim Html               -- Turn on or off smart formating
+       | HtmlEmpty                       -- Nothing!
+       | HtmlNestingTag HtmlName [HtmlAttr] Html
+       | HtmlSimpleTag  HtmlName [HtmlAttr]
+       | HtmlString String
+               deriving (Show)
+
+{-
+ - A important property of Html is all strings inside the
+ - structure are already in Html friendly format.
+ - For example, use of &gt;,etc.
+ -}
+
+type HtmlName  = String
+type HtmlAttr  = (HtmlName,Either Int String)
+type HtmlTable = OT.OptTable (Int -> Int -> Html)
+
+------------------------------------------------------------------------------
+-- Interface
+------------------------------------------------------------------------------
+
+-- primitive combinators
+(+++)          :: Html -> Html                 -> Html
+verbatim       :: Html                         -> Html
+tag            :: String -> [HtmlAttr] -> Html -> Html
+atag           :: String -> [HtmlAttr]         -> Html
+noHtml         ::                                 Html
+primHtml       :: String                       -> Html
+
+-- useful combinators
+concatHtml             :: [Html]                       -> Html
+htmlStr, htmlLine      :: String                       -> Html
+
+-- html constructors
+h1,h2,h3,h4,h5,h6      :: [HtmlAttr] -> Html           -> Html
+font, bold, anchor, 
+ header, body, 
+ theTitle, paragraph,
+ italics, ul, tt       :: [HtmlAttr] -> Html           -> Html
+bar, meta, li          :: [HtmlAttr]                   -> Html
+
+-- html attributes
+str                    :: String -> String             -> HtmlAttr
+int                    :: String -> Int                -> HtmlAttr
+percent                :: String -> Int                -> HtmlAttr
+
+color, bgcolor, href,
+ name, title, height,
+ width, align, valign  :: String                       -> HtmlAttr
+
+border, size,
+ cellpadding,
+ cellspacing           :: Int                          -> HtmlAttr 
+
+-- abbriviations
+
+p                      :: Html                         -> Html
+hr                     ::                                 Html
+copyright              ::                                 Html
+spaceHtml              ::                                 Html
+
+-- rendering
+renderHtml             :: Html -> String
+
+-- html tables
+cellHtml               :: [HtmlAttr] -> Html           -> HtmlTable
+(+/+),above,
+ (+-+),beside          :: HtmlTable -> HtmlTable       -> HtmlTable
+aboves, besides                :: [HtmlTable]                  -> HtmlTable
+renderTable            :: [HtmlAttr] -> HtmlTable      -> Html
+simpleTable            :: [HtmlAttr] -> [HtmlAttr] -> [[Html]] 
+                                                       -> Html
+
+------------------------------------------------------------------------------
+-- Basic, primitive combinators
+
+-- This is intentionally lazy in the second argument.
+(HtmlAppend x y) +++ z = x +++ (y +++ z)
+(HtmlEmpty)      +++ z = z
+x                +++ z = HtmlAppend x z
+
+verbatim       = HtmlVerbatim
+tag            = HtmlNestingTag
+atag           = HtmlSimpleTag
+noHtml                 = HtmlEmpty
+
+-- This is not processed for special chars. 
+-- It is used to output them, though!
+primHtml       = HtmlString
+
+------------------------------------------------------------------------------
+-- Useful Combinators
+
+concatHtml = foldr (+++) noHtml
+-- Processing Strings into Html friendly things.
+-- This converts a string to an Html.
+htmlStr = primHtml . htmlizeStr
+
+-- This converts a string, but keeps spaces as non-line-breakable
+htmlLine = primHtml . concat . map htmlizeChar2
+   where 
+       htmlizeChar2 ' ' = "&nbsp;"
+       htmlizeChar2 c   = htmlizeChar c
+
+-- Local Utilites
+htmlizeStr :: String -> String
+htmlizeStr = concat . map htmlizeChar
+
+htmlizeChar :: Char -> String
+htmlizeChar '<' = "&gt;"
+htmlizeChar '>' = "&lt;"
+htmlizeChar '&' = "&amb;"
+htmlizeChar '"' = "&quot;"
+htmlizeChar c   = [c]
+
+------------------------------------------------------------------------------
+-- Html Constructors
+h n = tag ("h" ++ show n)
+
+-- Isn't Haskell great!
+[h1,h2,h3,h4,h5,h6] = map h [1..6]
+
+-- tags
+font                   = tag "font"
+bold           = tag "b"
+anchor         = tag "a"
+header                 = tag "header"
+body                   = tag "body"
+theTitle       = tag "title"
+paragraph      = tag "p"
+italics                = tag "i"
+ul             = tag "ul"
+tt             = tag "tt"
+
+bar            = atag "hr"
+meta           = atag "meta"
+li             = atag "li"
+
+------------------------------------------------------------------------------
+-- Html Attributes
+
+-- note: the string is presumed to be formated for output
+--str :: String -> String -> HtmlAttr
+str n s = (n,Right s)
+
+--int :: String -> Int -> HtmlAttr
+int n v = (n,Left v)
+
+--percent :: String -> Int -> HtmlAttr
+percent n v = str n (show v ++ "%")
+
+-- attributes
+color          = str "color"
+bgcolor        = str "bgcolor"
+href           = str "href"
+name           = str "name"
+title          = str "tile"
+height         = str "height" 
+width          = str "width"
+align          = str "align"
+valign         = str "valign"
+
+border         = int "border" 
+size           = int "size"
+cellpadding            = int "cellpadding"
+cellspacing            = int "cellspacing"
+
+------------------------------------------------------------------------------
+-- abbriviations
+p              = paragraph []
+hr             = atag "hr" []
+copyright      = primHtml "&copy;"
+spaceHtml      = primHtml "&nbsp;"
+
+------------------------------------------------------------------------------
+-- Rendering
+
+renderHtml html = renderHtml' html (Just 0) ++ footerMessage
+
+footerMessage 
+   = "\n<!-- Generated using the Haskell HTML generator package HaskHTML -->\n"
+
+renderHtml' (HtmlAppend html1 html2) d
+       = renderHtml' html1 d ++ renderHtml' html2 d
+renderHtml' (HtmlVerbatim html1) d
+       = renderHtml' html1 Nothing
+renderHtml' (HtmlEmpty) d = ""
+renderHtml' (HtmlSimpleTag name attr) d
+       = renderTag True name attr d
+renderHtml' (HtmlNestingTag name attr html) d
+       = renderTag True name attr d ++ renderHtml' html (incDepth d) ++
+         renderTag False name [] d
+renderHtml' (HtmlString str) _ = str
+
+incDepth :: Maybe Int -> Maybe Int
+incDepth = fmap (+4)
+
+-- This prints the tags in 
+renderTag :: Bool -> HtmlName -> [HtmlAttr] -> Maybe Int -> String
+renderTag x name attrs n = start ++ base_spaces ++ open ++ name ++ rest attrs ++ ">"
+  where
+       open = if x then "<" else "</"
+       (start,base_spaces,sep) = case n of
+                             Nothing -> ("",""," ")
+                             Just n ->  ("\n",replicate n ' ',"\n")
+                       
+       rest []            = ""
+       rest [(tag,val)]   = " " ++ tag ++ "=" ++ myShow val 
+       rest (hd:tl)       = " " ++ showPair hd ++ sep ++
+                 foldr1 (\ x y -> x ++ sep ++ y)
+                        [ base_spaces ++ replicate (1 + length name + 1) ' ' 
+                               ++ showPair p | p <- tl ]
+
+       showPair :: HtmlAttr -> String
+       showPair (tag,val) = tag ++ replicate (tagsz - length tag) ' ' ++ 
+                       " = " ++ myShow val 
+       myShow (Left n) = show n
+       myShow (Right s) = "\"" ++ s ++ "\""
+
+       tagsz = maximum (map (length.fst) attrs)
+
+------------------------------------------------------------------------------
+-- Html table related things
+
+cellHtml attr html = OT.single cellFn
+    where
+       cellFn x y = tag "td" (addX x (addY y attr)) html
+       addX 1 rest = rest
+       addX n rest = int "colspan" n : rest
+       addY 1 rest = rest
+       addY n rest = int "rowspan" n : rest
+
+above  = OT.above
+(+/+)  = above
+beside = OT.beside
+(+-+)  = beside
+
+{-
+ - Note: Both aboves and besides presume a non-empty list.
+ -}
+
+aboves = foldl1 (+/+)
+besides = foldl1 (+-+)
+
+-- renderTable takes the HtmlTable, and renders it back into
+-- and Html object. The attributes are added to the outside
+-- table tag.
+
+renderTable attr theTable
+       = table [row [theCell x y | (theCell,(x,y)) <- theRow ] 
+                       | theRow <- OT.getMatrix theTable]
+   where
+       row :: [Html] -> Html
+       row  = tag "tr" [] . concatHtml
+
+       table :: [Html] -> Html
+       table = tag "table" attr . concatHtml
+
+-- If you cant be bothered with the above, then you
+-- can build simple tables with this.
+-- Just provide the attributes for the whole table,
+-- attributes for the cells (same for every cell),
+-- and a list of list of cell contents,
+-- and this function will build the table for you.
+-- It does presume that all the lists are non-empty,
+-- and there is at least one list.
+--  
+-- Different length lists means that the last cell
+-- gets padded. If you want more power, then
+-- use the system above.
+
+simpleTable attr cellAttr
+       = renderTable attr 
+       . aboves
+       . map (besides . map (cellHtml cellAttr))
+
+       
+------------------------------------------------------------------------------
index 07cb339..41ca789 100644 (file)
@@ -1,92 +1,92 @@
------------------------------------------------------------------------------\r
--- $Id: OptTable.hs,v 1.1 1999/11/12 11:54:17 simonmar Exp $\r
---\r
---     OGI_Table : Class for combinators used in building 2D tables.\r
---\r
---     Copyright (c) 1999 Andy Gill\r
---\r
--- This module is distributed as Open Source software under the\r
--- Artistic License; see the file "Artistic" that is included\r
--- in the distribution for details.\r
------------------------------------------------------------------------------\r
-\r
-module OptTable (\r
-       OptTable,               -- abstract\r
-       single,\r
-       beside,\r
-       above,\r
-       getMatrix,\r
-       ) where\r
-\r
-import qualified ClassTable as TC\r
-\r
-instance TC.Table OptTable where\r
-       single    = OptTable.single\r
-       beside    = OptTable.beside\r
-       above     = OptTable.above\r
-       getMatrix = OptTable.getMatrix\r
-\r
-instance (Show a) => Show (OptTable a) where\r
-       showsPrec p = TC.showsTable\r
-\r
-type TableI a = [[(a,(Int,Int))]] -> [[(a,(Int,Int))]]\r
-\r
-data OptTable a        = Table (Int -> Int -> TableI a) Int Int\r
-\r
-{-\r
- - Perhaps one day I'll fell adventureous, and write the Show instance\r
- - to show boxes aka the above ascii renditions.\r
- -}\r
-\r
--- You can create a (1x1) table entry\r
-single :: a -> OptTable a\r
-single a = Table (\ x y z -> [(a,(x+1,y+1))] : z) 1 1\r
-\r
--- You can compose tables, horizonally and vertically\r
-above :: OptTable a -> OptTable a -> OptTable a\r
-beside :: OptTable a -> OptTable a -> OptTable a\r
-\r
-t1 `above` t2 = trans (combine (trans t1) (trans t2) (.))\r
-\r
-t1 `beside` t2 = combine t1 t2 (\ lst1 lst2 r ->\r
-    let\r
-       -- Note this depends on the fact that\r
-       -- that the result has the same number\r
-       -- of lines as the y dimention; one list\r
-       -- per line. This is not true in general\r
-       -- but is always true for these combinators.\r
-       -- I should assert this!\r
-       beside (x:xs) (y:ys) = (x ++ y) : beside xs ys\r
-       beside (x:xs) []     = x        : xs ++ r\r
-       beside []     (y:ys) = y        : ys ++ r\r
-       beside []     []     =                  r\r
-    in\r
-       beside (lst1 []) (lst2 []))\r
-\r
--- trans flips (transposes) over the x and y axis of\r
--- the table. It is only used internally, and typically\r
--- in pairs, ie. (flip ... munge ... (un)flip).\r
-\r
-trans :: OptTable a -> OptTable a\r
-trans (Table f1 x1 y1) = Table (flip f1) y1 x1\r
-\r
-combine :: OptTable a \r
-       -> OptTable b \r
-       -> (TableI a -> TableI b -> TableI c) \r
-       -> OptTable c\r
-combine (Table f1 x1 y1) (Table f2 x2 y2) comb = Table new_fn (x1+x2) max_y\r
-    where\r
-       max_y = max y1 y2\r
-       new_fn x y =\r
-          case compare y1 y2 of\r
-           EQ -> comb (f1 0 y)             (f2 x y)\r
-           GT -> comb (f1 0 y)             (f2 x (y + y1 - y2))\r
-           LT -> comb (f1 0 (y + y2 - y1)) (f2 x y)\r
-\r
--- This is the other thing you can do with a Table;\r
--- turn it into a 2D list, tagged with the (x,y)\r
--- sizes of each cell in the table.\r
-\r
-getMatrix :: OptTable a -> [[(a,(Int,Int))]]\r
-getMatrix (Table r _ _) = r 0 0 []\r
-\r
+-----------------------------------------------------------------------------
+-- $Id: OptTable.hs,v 1.2 2000/07/10 16:15:34 rrt Exp $
+--
+--     OGI_Table : Class for combinators used in building 2D tables.
+--
+--     Copyright (c) 1999 Andy Gill
+--
+-- This module is distributed as Open Source software under the
+-- Artistic License; see the file "Artistic" that is included
+-- in the distribution for details.
+-----------------------------------------------------------------------------
+
+module OptTable (
+       OptTable,               -- abstract
+       single,
+       beside,
+       above,
+       getMatrix,
+       ) where
+
+import qualified ClassTable as TC
+
+instance TC.Table OptTable where
+       single    = OptTable.single
+       beside    = OptTable.beside
+       above     = OptTable.above
+       getMatrix = OptTable.getMatrix
+
+instance (Show a) => Show (OptTable a) where
+       showsPrec p = TC.showsTable
+
+type TableI a = [[(a,(Int,Int))]] -> [[(a,(Int,Int))]]
+
+data OptTable a        = Table (Int -> Int -> TableI a) Int Int
+
+{-
+ - Perhaps one day I'll fell adventureous, and write the Show instance
+ - to show boxes aka the above ascii renditions.
+ -}
+
+-- You can create a (1x1) table entry
+single :: a -> OptTable a
+single a = Table (\ x y z -> [(a,(x+1,y+1))] : z) 1 1
+
+-- You can compose tables, horizonally and vertically
+above :: OptTable a -> OptTable a -> OptTable a
+beside :: OptTable a -> OptTable a -> OptTable a
+
+t1 `above` t2 = trans (combine (trans t1) (trans t2) (.))
+
+t1 `beside` t2 = combine t1 t2 (\ lst1 lst2 r ->
+    let
+       -- Note this depends on the fact that
+       -- that the result has the same number
+       -- of lines as the y dimention; one list
+       -- per line. This is not true in general
+       -- but is always true for these combinators.
+       -- I should assert this!
+       beside (x:xs) (y:ys) = (x ++ y) : beside xs ys
+       beside (x:xs) []     = x        : xs ++ r
+       beside []     (y:ys) = y        : ys ++ r
+       beside []     []     =                  r
+    in
+       beside (lst1 []) (lst2 []))
+
+-- trans flips (transposes) over the x and y axis of
+-- the table. It is only used internally, and typically
+-- in pairs, ie. (flip ... munge ... (un)flip).
+
+trans :: OptTable a -> OptTable a
+trans (Table f1 x1 y1) = Table (flip f1) y1 x1
+
+combine :: OptTable a 
+       -> OptTable b 
+       -> (TableI a -> TableI b -> TableI c) 
+       -> OptTable c
+combine (Table f1 x1 y1) (Table f2 x2 y2) comb = Table new_fn (x1+x2) max_y
+    where
+       max_y = max y1 y2
+       new_fn x y =
+          case compare y1 y2 of
+           EQ -> comb (f1 0 y)             (f2 x y)
+           GT -> comb (f1 0 y)             (f2 x (y + y1 - y2))
+           LT -> comb (f1 0 (y + y2 - y1)) (f2 x y)
+
+-- This is the other thing you can do with a Table;
+-- turn it into a 2D list, tagged with the (x,y)
+-- sizes of each cell in the table.
+
+getMatrix :: OptTable a -> [[(a,(Int,Int))]]
+getMatrix (Table r _ _) = r 0 0 []
+