From ee13c263bf4eabe2871e1d3b248e3dcd86bc53ac Mon Sep 17 00:00:00 2001 From: rrt Date: Mon, 10 Jul 2000 16:15:36 +0000 Subject: [PATCH] [project @ 2000-07-10 16:15:33 by rrt] 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 | 702 +++++++++++++-------------- ghc/ANNOUNCE | 232 ++++----- ghc/interpreter/test/static/s108.hs | 4 +- ghc/tests/typecheck/should_compile/tc105.hs | 30 +- glafp-utils/docbook/Makefile | 3 +- glafp-utils/nofib-analyse/ClassTable.hs | 188 +++---- glafp-utils/nofib-analyse/DataHtml.hs | 618 +++++++++++------------ glafp-utils/nofib-analyse/OptTable.hs | 184 +++---- 8 files changed, 981 insertions(+), 980 deletions(-) diff --git a/docs/cvs-cheat-sheet.html b/docs/cvs-cheat-sheet.html index 76f4c2e..93e42c0 100644 --- a/docs/cvs-cheat-sheet.html +++ b/docs/cvs-cheat-sheet.html @@ -1,351 +1,351 @@ - - - - - - -Access To The GHC CVS Repository - - - - -

FP Tools CVS Cheat Sheet

- -

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.

- -

Information on using CVS can be obtained from Cyclic -Software.

- -

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 Jeff Lewis).

- -

Contents - -

- -

Remote Read-only CVS Access

- -

Read-only access is available to anyone - there's no need to ask us first. To get -read-only access to our repository: - -

- -

The layout of our CVS repository is described below, under Using CVS -for the first time.

- -

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.

- -

Remote Read-Write CVS Access

- -

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.

- -

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 ssh, which is relatively painless. Log -in to cvs.haskell.org, and set up your .ssh/authorized_keys -file to allow logins from your local machine without a password (the -ssh documentation has details on how to do this). Then, just - -

- -

The CVSROOT 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 CVSROOT -below.

- - -

Caveats: - -

- -

Using CVS for the First Time

- - - -

Checking Out a Source Tree

- - - -

Committing Your Changes

- -

This is only if you have read-write access to the repository. For anoncvs users, CVS -will issue a "read-only repository" error if you try to commit changes. - -

- -

Updating Your Source Tree

- -

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 mk/*.mk files are a good example where problems -crop up quite often). Having an inconsistent tree is a major cause of headaches.

- -

So, to avoid a lot of hassle, follow this recipe for updating your tree:

- -
$ cd fptools
-$ cvs update -Pd 2>&1 | tee log
- -

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:

- -
$ cd <build-tree>
-$ lndir <source-tree>
- -

Some files might have been removed, so you need to remove the links pointing to these -non-existent files:

- -
$ find . -xtype l -exec rm '{}' \;
- -

And finally, re-configure to take into accound any changes in mk/config.mk.in.

- -
$ ./configure
- -

To be *really* safe, you should do

- -
$ gmake boot && gmake all
- -

from the top-level, to update the dependencies and build any changed files.

- -

GHC Tag Policy

- -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: - - - -So, to check out a fresh GHC 4.06 tree you would do: - -
-     $ cvs co -r ghc-4-06 fpconfig
-     $ cd fptools
-     $ cvs co -r ghc-4-06 ghc hslibs
-
- - -

General Hints

- - - -

Reporting Bugs in the CVS sources

- -

If you are reporting a bug or infelicity in the CVS version of -GHC, please send your message to

- - - - - - - - -
- cvs-ghc@haskell.org
- cvs-hslibs@haskell.org - (for hslibs/ stuff)
- cvs-nofib@haskell.org - (for nofib/ stuff)
- -

(not to glasgow-haskell-bugs). Two reasons:

- - - -

Please don't stop sending bug reports though. They are really useful.

- -
- -

Ok, that'll do for now. If there's anything else you'd like to see -in this file, just let us know.

- - - - - - - - -
Jeff Lewis
Simon Marlow
- - + + + + + + +Access To The GHC CVS Repository + + + + +

FP Tools CVS Cheat Sheet

+ +

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.

+ +

Information on using CVS can be obtained from Cyclic +Software.

+ +

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 Jeff Lewis).

+ +

Contents + +

+ +

Remote Read-only CVS Access

+ +

Read-only access is available to anyone - there's no need to ask us first. To get +read-only access to our repository: + +

+ +

The layout of our CVS repository is described below, under Using CVS +for the first time.

+ +

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.

+ +

Remote Read-Write CVS Access

+ +

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.

+ +

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 ssh, which is relatively painless. Log +in to cvs.haskell.org, and set up your .ssh/authorized_keys +file to allow logins from your local machine without a password (the +ssh documentation has details on how to do this). Then, just + +

+ +

The CVSROOT 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 CVSROOT +below.

+ + +

Caveats: + +

+ +

Using CVS for the First Time

+ + + +

Checking Out a Source Tree

+ + + +

Committing Your Changes

+ +

This is only if you have read-write access to the repository. For anoncvs users, CVS +will issue a "read-only repository" error if you try to commit changes. + +

+ +

Updating Your Source Tree

+ +

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 mk/*.mk files are a good example where problems +crop up quite often). Having an inconsistent tree is a major cause of headaches.

+ +

So, to avoid a lot of hassle, follow this recipe for updating your tree:

+ +
$ cd fptools
+$ cvs update -Pd 2>&1 | tee log
+ +

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:

+ +
$ cd <build-tree>
+$ lndir <source-tree>
+ +

Some files might have been removed, so you need to remove the links pointing to these +non-existent files:

+ +
$ find . -xtype l -exec rm '{}' \;
+ +

And finally, re-configure to take into accound any changes in mk/config.mk.in.

+ +
$ ./configure
+ +

To be *really* safe, you should do

+ +
$ gmake boot && gmake all
+ +

from the top-level, to update the dependencies and build any changed files.

+ +

GHC Tag Policy

+ +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: + + + +So, to check out a fresh GHC 4.06 tree you would do: + +
+     $ cvs co -r ghc-4-06 fpconfig
+     $ cd fptools
+     $ cvs co -r ghc-4-06 ghc hslibs
+
+ + +

General Hints

+ + + +

Reporting Bugs in the CVS sources

+ +

If you are reporting a bug or infelicity in the CVS version of +GHC, please send your message to

+ + + + + + + + +
+ cvs-ghc@haskell.org
+ cvs-hslibs@haskell.org + (for hslibs/ stuff)
+ cvs-nofib@haskell.org + (for nofib/ stuff)
+ +

(not to glasgow-haskell-bugs). Two reasons:

+ + + +

Please don't stop sending bug reports though. They are really useful.

+ +
+ +

Ok, that'll do for now. If there's anything else you'd like to see +in this file, just let us know.

+ + + + + + + + +
Jeff Lewis
Simon Marlow
+ + diff --git a/ghc/ANNOUNCE b/ghc/ANNOUNCE index e0d2cf2..87417db 100644 --- a/ghc/ANNOUNCE +++ b/ghc/ANNOUNCE @@ -1,116 +1,116 @@ - 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 - -or - - subscribe cvs-ghc Your Name - -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 + 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 + +or + + subscribe cvs-ghc Your Name + +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 diff --git a/ghc/interpreter/test/static/s108.hs b/ghc/interpreter/test/static/s108.hs index 02954ae..c1c0933 100644 --- a/ghc/interpreter/test/static/s108.hs +++ b/ghc/interpreter/test/static/s108.hs @@ -1,3 +1,3 @@ ---!!! Testing export of unknown name -module Bar(bar) where +--!!! Testing export of unknown name +module Bar(bar) where foo = foo \ No newline at end of file diff --git a/ghc/tests/typecheck/should_compile/tc105.hs b/ghc/tests/typecheck/should_compile/tc105.hs index 891f2c7..5738b67 100644 --- a/ghc/tests/typecheck/should_compile/tc105.hs +++ b/ghc/tests/typecheck/should_compile/tc105.hs @@ -1,15 +1,15 @@ -{-# 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 +{-# 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 diff --git a/glafp-utils/docbook/Makefile b/glafp-utils/docbook/Makefile index 724e437..8b94473 100644 --- a/glafp-utils/docbook/Makefile +++ b/glafp-utils/docbook/Makefile @@ -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 diff --git a/glafp-utils/nofib-analyse/ClassTable.hs b/glafp-utils/nofib-analyse/ClassTable.hs index 78a1699..9472f16 100644 --- a/glafp-utils/nofib-analyse/ClassTable.hs +++ b/glafp-utils/nofib-analyse/ClassTable.hs @@ -1,94 +1,94 @@ ------------------------------------------------------------------------------ --- 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 "" - - +----------------------------------------------------------------------------- +-- 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 "" + + diff --git a/glafp-utils/nofib-analyse/DataHtml.hs b/glafp-utils/nofib-analyse/DataHtml.hs index 75aca4c..a603dff 100644 --- a/glafp-utils/nofib-analyse/DataHtml.hs +++ b/glafp-utils/nofib-analyse/DataHtml.hs @@ -1,309 +1,309 @@ -------------------------------------------------------------------------------- --- $Id: DataHtml.hs,v 1.1 1999/11/12 11:54:17 simonmar 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 >,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 ' ' = " " - htmlizeChar2 c = htmlizeChar c - --- Local Utilites -htmlizeStr :: String -> String -htmlizeStr = concat . map htmlizeChar - -htmlizeChar :: Char -> String -htmlizeChar '<' = ">" -htmlizeChar '>' = "<" -htmlizeChar '&' = "&amb;" -htmlizeChar '"' = """ -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 "©" -spaceHtml = primHtml " " - ------------------------------------------------------------------------------- --- Rendering - -renderHtml html = renderHtml' html (Just 0) ++ footerMessage - -footerMessage - = "\n\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 " ("",""," ") - 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)) - - ------------------------------------------------------------------------------- +------------------------------------------------------------------------------- +-- $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 >,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 ' ' = " " + htmlizeChar2 c = htmlizeChar c + +-- Local Utilites +htmlizeStr :: String -> String +htmlizeStr = concat . map htmlizeChar + +htmlizeChar :: Char -> String +htmlizeChar '<' = ">" +htmlizeChar '>' = "<" +htmlizeChar '&' = "&amb;" +htmlizeChar '"' = """ +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 "©" +spaceHtml = primHtml " " + +------------------------------------------------------------------------------ +-- Rendering + +renderHtml html = renderHtml' html (Just 0) ++ footerMessage + +footerMessage + = "\n\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 " ("",""," ") + 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)) + + +------------------------------------------------------------------------------ diff --git a/glafp-utils/nofib-analyse/OptTable.hs b/glafp-utils/nofib-analyse/OptTable.hs index 07cb339..41ca789 100644 --- a/glafp-utils/nofib-analyse/OptTable.hs +++ b/glafp-utils/nofib-analyse/OptTable.hs @@ -1,92 +1,92 @@ ------------------------------------------------------------------------------ --- $Id: OptTable.hs,v 1.1 1999/11/12 11:54:17 simonmar 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 [] - +----------------------------------------------------------------------------- +-- $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 [] + -- 1.7.10.4