[m-rev.] Book - minor latex fixes; Makefile added

Ralph Becket rafe at cs.mu.OZ.AU
Fri Oct 11 14:09:34 AEST 2002


Estimated hours taken: 0.5
Branches: main

tutorial/Makefile.tex:
	Added.

tutorial/expandshortverb:
	Added.

tutorial/*.tex:
	Minor latex fixes.

Index: Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Makefile	11 Oct 2002 02:37:58 -0000
@@ -0,0 +1,52 @@
+.PHONY: all dvi ps gz html
+
+DOCS = book
+
+CHAPTERS = \
+	FFI.tex \
+	RTTI.tex \
+	arrays.tex \
+	compiling-programs.tex \
+	debugging.tex \
+	declarative-vs-imperative.tex \
+	defs.tex \
+	exceptions.tex \
+	functions.tex \
+	hello-world.tex \
+	higher-order.tex \
+	impure-code.tex \
+	introduction.tex \
+	io.tex \
+	lists.tex \
+	logic.tex \
+	maps.tex \
+	modes.tex \
+	modules.tex \
+	optimization.tex \
+	pragmas.tex \
+	predicates.tex \
+	stores.tex \
+	syntax-and-terminology.tex \
+	type-classes.tex \
+	types.tex
+
+all:  dvi
+dvi:  $(addsuffix .dvi,${DOCS})
+ps:   $(addsuffix .ps,${DOCS})
+gz:   $(addsuffix .ps.gz,${DOCS})
+html: $(addsuffix .html,${DOCS})
+
+book.dvi: book.tex $(CHAPTERS)
+
+%.dvi: %.tex
+	latex $*.tex
+
+%.ps: %.dvi
+	dvips $*.dvi
+
+%.ps.gz: %.ps
+	gzip $*.ps
+
+%.html: %.tex
+	expandshortverb $*.tex > $*.exp
+	latex2html -split 0 $*.exp
Index: book.tex
===================================================================
RCS file: /home/mercury1/repository/books/tutorial/book.tex,v
retrieving revision 1.1
diff -u -r1.1 book.tex
--- book.tex	2 Oct 2002 00:21:13 -0000	1.1
+++ book.tex	11 Oct 2002 03:38:48 -0000
@@ -10,9 +10,9 @@
 
 %- Preamble -------------------------------------------------------------------%
 
-\documentclass[a4paper,11pt,notitlepage,onecolumn]{article}
+\documentclass[a4paper,11pt,notitlepage,onecolumn]{book}
     %
-	% [options]
+    % [options]
     %   (10|11|12)pt            -- (default 10pt)
     %   (a4|letter)paper        -- (default letterpaper)
     %   fleqn                   -- (default centred) left-align formulae as
Index: defs.tex
===================================================================
RCS file: /home/mercury1/repository/books/tutorial/defs.tex,v
retrieving revision 1.2
diff -u -r1.2 defs.tex
--- defs.tex	11 Oct 2002 02:21:50 -0000	1.2
+++ defs.tex	11 Oct 2002 03:38:48 -0000
@@ -50,3 +50,5 @@
 \newcommand{\Plant} {\text{plant}}
 \newcommand{\Grain} {\text{grain}}
 \newcommand{\BiggerThan} {\text{bigger-than}}
+
+\newcommand{\Csharp} {C$\sharp$}
Index: expandshortverb
===================================================================
RCS file: expandshortverb
diff -N expandshortverb
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ expandshortverb	5 Sep 2002 05:24:03 -0000
@@ -0,0 +1,14 @@
+#!/usr/bin/gawk -f
+
+# Turns `@...@' sequences in tex documents into `\verb at ...@'.
+# This is necessary for tex documents using
+#
+#	\usepackage{doc}
+#	\MakeShortVerb{\@}
+#
+# that are to be processed by latex2html.
+
+/begin{verbatim}/	{ expand = 0 }			# Skip verbatim blocks
+/end{verbatim}/		{ expand = 1 }
+expand && /@/		{ gsub("@[^@]*@", "\\verb&") }	# Prepend \verb to @...@
+1							# Print the current line
Index: predicates.tex
===================================================================
RCS file: /home/mercury1/repository/books/tutorial/predicates.tex,v
retrieving revision 1.2
diff -u -r1.2 predicates.tex
--- predicates.tex	11 Oct 2002 02:22:09 -0000	1.2
+++ predicates.tex	11 Oct 2002 03:38:49 -0000
@@ -26,7 +26,7 @@
 If the body of a predicate is empty (taken to mean just @true@), one can
 just write
 \begin{verbatim}
-    Head.
+Head.
 \end{verbatim}
 Clauses like this are called \emph{facts}.
 
Index: type-classes.tex
===================================================================
RCS file: /home/mercury1/repository/books/tutorial/type-classes.tex,v
retrieving revision 1.2
diff -u -r1.2 type-classes.tex
--- type-classes.tex	11 Oct 2002 02:22:12 -0000	1.2
+++ type-classes.tex	11 Oct 2002 03:39:16 -0000
@@ -78,14 +78,15 @@
 operations (or methods) we require:
 \begin{verbatim}
 :- typeclass number(T) where [
-	func zero          = T,
-	func one           = T,
-	func from_int(int) = T,
-	func    -T         = T,
-	func T + T         = T,
-	func T - T         = T,
-	func T * T         = T,
-	func T / T         = T
+    func zero          = T,
+    func one           = T,
+    func from_int(int) = T,
+    func    -T         = T,
+    func T + T         = T,
+    func T - T         = T,
+    func T * T         = T,
+    func T / T         = T
+].
 \end{verbatim}
 We include the nullary methods @zero@ and @one@ because they are so
 useful and will have different representations in each \emph{instance}
@@ -121,7 +122,7 @@
 Next, let's look at how we define @int@ as an instance of @number@:
 \begin{verbatim}
 :- instance number(int) where [
-	zero        = 0,
+    zero        = 0,
     one         = 1,
     from_int(X) = X,
     -X          = 'int__-'(X),
@@ -154,7 +155,7 @@
 Making @float@ an instance of @number@ is very similar:
 \begin{verbatim}
 :- instance number(float) where [
-	zero        = 0.0,
+    zero        = 0.0,
     one         = 1.0,
     from_int(X) = X,
     -X          = 'float__-'(X),
@@ -239,7 +240,7 @@
 
 index(K, HT) = hash(K) `mod` size(HT).
 \end{verbatim}
-\XXX{Make sure we add @elem@ and @det_elem@ to @assoc_list at .}
+\XXX{Make sure we add @elem@ and @det\_elem@ to @assoc\_list at .}
 
 We can construct hash functions for all our favourite types:
 \begin{verbatim}
@@ -283,10 +284,10 @@
 
 As an example, for many applications, the most efficient type of hash
 table uses double hashing, rather than chaining buckets off a single
-hash generated index.  For double hashing we probe at indices @h1(K) + I
-* h2(K)@ (modulo the size of the hash table) for $@I@ \in \{0, 1, 2,
-\ldots\}$, looking for the correct entry or an empty slot, depending
-upon whether we are performing an insertion or a lookup.
+hash generated index.  For double hashing we probe at indices
+ at h1(K) + I * h2(K)@ (modulo the size of the hash table) for
+$@I@ \in \{0, 1, 2, \ldots\}$, looking for the correct entry or an empty
+slot, depending upon whether we are performing an insertion or a lookup.
 
 We want to add a new type class for types with a second hash function:
 \begin{verbatim}
@@ -422,7 +423,7 @@
 use it) and can lead to real code maintenance problems.
 \XXX{Do I need to substantiate these claims?}
 
-Several languages, such as Java and C#, have included the notions of
+Several languages, such as Java and \Csharp, have included the notions of
 \emph{interfaces}, which serve much the same purpose as type classes.
 Since we are only allowed to inherit method signatures, there is no
 problem (provided we insist that no method in a sub-type class may have the
@@ -628,7 +629,7 @@
 \end{verbatim}
 because this would restrict the first argument to all members of the
 same type.  What we want to be able to say is, given @X = 10@,
- at Y = " green bottle", Z = @'s'@ is to just call
+ at Y = " green bottle"@, Z = @'s'@ is to just call
 @write_strings([X, Y, Z])@ and see @10 green bottles@ appear in the
 output.
 
@@ -658,7 +659,7 @@
 collections of @stringable@ instance values.
 
 The constraint @=> stringable(T)@ has the arrow pointing in a different
-deirection, because existentially quantified types place a burden on the
+direction, because existentially quantified types place a burden on the
 \emph{caller's} ability to handle a value, rather than the
 \emph{callee's}.  Because of this directionality, existentially
 quantified types are generally ``outputs'' since a caller has no way of
@@ -669,7 +670,7 @@
 just hard or just a SMOP?)} whether an occurrence of an existentially
 quantified data constructor is meant as a construction or
 deconstruction.  To solve this problem, we insist that
-\emph{constructions} be preceeded with `@new ' (note the space), while
+\emph{constructions} be preceeded with `@new @' (note the space), while
 \emph{deconstructions} are not.  Thus, to construct our heterogeneous
 list of @stringable at s, we would write
 \begin{verbatim}

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list