[m-rev.] [books]: minor updates and corrections for Ralph's book

Julien Fischer jfischer at opturion.com
Mon Mar 23 23:35:15 AEDT 2020


Since we have a copy of this on the webpage ...

---------------------------------

Minor updates and corrections.

Add a table of contents.

Fix build problems.

tutorial/book.polytex:
     Delete Ralph's old .cs.mu.oz.au address.

     Enable the table of contents.

tutorial/00-introduction.polytex:
     Mention that this document is not being worked on.

     Comment out a paragraph giving the old mercury mailing
     list addresses.

tutorial/01-mercury-by-example.polytex:
     Delete a doubled-up word.

tutorial/02-the-mercury-type-system.polytex:
     Comment out part of a paragraph that describes the mapping of
     Mercury types to C types; it was wrong even when Ralph wrote it.

     Fix spelling

     Update library references.

tutorial/03-the-mercury-mode-system.polytex:
     Fix spelling.

tutorial/04-lists.polytex:
     Delete doubled-up word and fixed spelling.

tutorial/Makefile:
     Build the PDF version using pdflatex instead of dvipdf.

tutorial/polytex:
     Do not assume that GNU awk is installed in /usr/bin.

tutorial/polytex2tex:
     Do not assume that GNU awk is installed in /usr/bin.

     Avoid a warning.

Julien.

diff --git a/tutorial/00-introduction.polytex b/tutorial/00-introduction.polytex
index 8746971..45d6ae3 100644
--- a/tutorial/00-introduction.polytex
+++ b/tutorial/00-introduction.polytex
@@ -8,7 +8,9 @@

  \textbf{Disclaimer.}
  \\
-This is a work in progress.
+This was a work in progress.
+The author has ceased active involvement with Mercury
+and there are (currently) no plans to continue work on it.

  \textbf{What is this book for?}
  \\
@@ -52,11 +54,11 @@ I plan to write the introduction last.  It will include a brief description
  of ``what Mercury is all about'' and an explanation of what the book is
  trying to do.

-\textbf{Where should I send comments?}
-\\
-Please subscribe to the Mercury users' mailing list by sending an e-mail
-containing the word ``subscribe'' in the body (as opposed to the subject
-line) to #mercury-users-request at cs.mu.oz.au# (this is a very low bandwidth
-mailing list).  Then you can send comments to #mercury-users at cs.mu.oz.au#.
-All feedback is very gratefully received, particularly with reference to
-missing topics.
+%\textbf{Where should I send comments?}
+%\\
+%Please subscribe to the Mercury users' mailing list by sending an e-mail
+%containing the word ``subscribe'' in the body (as opposed to the subject
+%line) to #mercury-users-request at cs.mu.oz.au# (this is a very low bandwidth
+%mailing list).  Then you can send comments to #mercury-users at cs.mu.oz.au#.
+%All feedback is very gratefully received, particularly with reference to
+%missing topics.
diff --git a/tutorial/01-mercury-by-example.polytex b/tutorial/01-mercury-by-example.polytex
index 850b1ca..a21911d 100644
--- a/tutorial/01-mercury-by-example.polytex
+++ b/tutorial/01-mercury-by-example.polytex
@@ -684,7 +684,7 @@ clauses to define a predicate or function.
  quotes.  Some characters which the Mercury parser would normally expect to
  see used as infix function symbols, such as #+# and #*#, also need to be
  enclosed in parentheses: #('+')# and #('*')#.  Full details of how special
-characters should be written can be found in the the Mercury Reference
+characters should be written can be found in the Mercury Reference
  Manual.
  \item The #semidet# determinism category means that a predicate can have
  at most one \emph{solution} for a given set of inputs (it fails if it has no
diff --git a/tutorial/02-the-mercury-type-system.polytex b/tutorial/02-the-mercury-type-system.polytex
index 6acffe2..166efba 100644
--- a/tutorial/02-the-mercury-type-system.polytex
+++ b/tutorial/02-the-mercury-type-system.polytex
@@ -42,10 +42,12 @@ are not directly available to the Mercury programmer.
  \section{The primitive types: \texttt{int}, \texttt{float}, \texttt{string}, and \texttt{char}}

  \Note The underlying representation of the primitive types
-depends upon the compiler target (C, Java, .Net etc.)  For the C targets
-#int# corresponds to #int#, #float# to #double#, #char# to #char#
-and #string# to #char *#; number ranges, representations, arithmetic
-overflow handling and so forth are dictated by the target machine.
+depends upon the compiler target (C, Java, .Net etc.)
+% XXX most of the next bit was wrong even when Ralph wrote it.
+%For the C targets
+%#int# corresponds to #int#, #float# to #double#, #char# to #char#
+%and #string# to #char *#; number ranges, representations, arithmetic
+%overflow handling and so forth are dictated by the target machine.

  \subsection*{\texttt{int}}

@@ -403,9 +405,9 @@ more than one purpose provided there is no ambiguity.

  After calling #ordering#, #search# switches on #O# to decide what to do
  next: if the value at the current #branch#, #X#, is less than the value we
-are searching for, #Y#, then search should procede down the right subtree,
+are searching for, #Y#, then search should proceed down the right subtree,
  #R#.  If #X = Y# then the search terminates successfully.  Otherwise, #X# is
-greater than #Y# and the search should procede down the left subtree, #L#.
+greater than #Y# and the search should proceed down the left subtree, #L#.
  The absence of a clause for #leaf# values means that any search that reaches
  a #leaf# will fail.

@@ -534,7 +536,7 @@ filter(P, [X | Xs], Ys, Zs) :-
  %endcode
  the goal #filter(P, As, Bs, Cs)# unifies #Bs# with the list of members of
  #As# that satisfy #P# and unifies #Cs# with the list of members of #As#
-that don't.  The first clause says that filtering the empty list yeilds two
+that don't.  The first clause says that filtering the empty list yields two
  empty lists.  The second clause says that filtering #[X | Xs]# through the
  predicate #P# is the result of filtering #Xs# through #P# and adding #X# to
  the first result if #P(X)# (\ie if #P# succeeds given #X#), or adding #X# to
@@ -566,7 +568,7 @@ higher order arguments.
  The #univ# type provides support for dynamically typed programming.
  Mercury's type system is so expressive that #univ# is hardly ever necessary.
  However, should you require it, here is (a slightly abridged version of) the
-interface to #univ# as defined in the #std_util# standard library module:
+interface to #univ# as defined in the #univ# standard library module:
  %startcode
  :- type  univ.
  :- func  univ(T) = univ.
@@ -593,7 +595,7 @@ To illustrate the use of #univ_to_type#, here is a program to print out
  :- pred main(io::di, io::uo) is det.

  :- implementation.
-:- import_module list, std_util, string.
+:- import_module list, string, univ.

  main(!IO) :-
      print_univ(univ(1),          !IO),
@@ -644,13 +646,12 @@ relevant parts of the Mercury Reference Manual.

  The Mercury standard library defines many useful types, the most common of
  which are examined in more detail in Chapter \XXX{}.  These include #bool#
-for boolean values, #graph# for graph processing, #list# for stacks and
+for Boolean values, #digraph# for directed graph processing, #list# for stacks and
  sequences, #map# for dictionaries, #queue# for first-in first-out (FIFO)
  queues, #pqueue# for priority queues, #random# for random numbers, and #set#
-for sets.  The #std_util# module defines miscellaneous utility types such as
-#univ#, #maybe#, #unit# (the ``dummy'' type), and #pair#.  Many more types
-are defined in the standard library, but the above suffice for the majority
-of data structures.
+for sets.
+Many more types are defined in the standard library, but the above suffice
+for the majority of data structures.



diff --git a/tutorial/03-the-mercury-mode-system.polytex b/tutorial/03-the-mercury-mode-system.polytex
index 18531b4..14a5930 100644
--- a/tutorial/03-the-mercury-mode-system.polytex
+++ b/tutorial/03-the-mercury-mode-system.polytex
@@ -114,7 +114,7 @@ Determinism category    & Number of solutions \\
  #failure#               & $0$ \\
  \end{tabular}

-There are three other determinsm categories that are only occasionally
+There are three other determinism categories that are only occasionally
  needed: #erroneous#, which is used for predicates that only terminate by
  throwing an exception (exceptions are described in Chapter \XXX{}), and
  #cc_multi# and #cc_nondet# which are used for committed-choice
@@ -432,7 +432,7 @@ So far we have only talked about variables going from being uninstantiated
  to being instantiated.  It turns out to be useful to also keep track of the
  possible values a variable can have when it is instantiated.  Mercury uses
  #inst#s for this purpose.  An #inst# represents the possible
-instantiantiation states of a variable at a particular point in a program.
+instantiation states of a variable at a particular point in a program.

  The most basic #inst#s are #free#, meaning a variable is uninstantiated, and
  #ground#, meaning a variable is instantiated with some unknown value of the
diff --git a/tutorial/04-lists.polytex b/tutorial/04-lists.polytex
index 784b2e6..b546242 100644
--- a/tutorial/04-lists.polytex
+++ b/tutorial/04-lists.polytex
@@ -22,7 +22,7 @@ convenient: #[1, 2, 3]# is shorthand for #[1 | [2 | [3 | []]]]# and

  We begin with a simple example: reading in some numbers and computing
  their sum.
-Start by putting the the usual header boilerplate in a file
+Start by putting the usual header boilerplate in a file
  #listdemo.m#:
  %startcode
  :- module listdemo.
@@ -146,7 +146,7 @@ Sum: 10



-\section{The minium and maximum of a list of ints}
+\section{The minimum and maximum of a list of ints}

  Now we extend our program to find the minimum and maximum of the input:
  %startcode
diff --git a/tutorial/Makefile b/tutorial/Makefile
index 52b25db..31def8a 100644
--- a/tutorial/Makefile
+++ b/tutorial/Makefile
@@ -14,5 +14,6 @@ book.ps.gz: book.ps
  	gzip -c book.ps > book.ps.gz

  book.pdf: book.dvi
-	dvipdf book
-
+	pdflatex book
+	pdflatex book
+	pdflatex book
diff --git a/tutorial/book.polytex b/tutorial/book.polytex
index 5751fe9..927dd5f 100644
--- a/tutorial/book.polytex
+++ b/tutorial/book.polytex
@@ -53,7 +53,7 @@
      % -- or can use \settowidth{argument}{text}

  \title{The Art of Mercury}
-\author{Ralph Becket \\ \texttt{\small rafe at cs.mu.oz.au}}
+\author{Ralph Becket}
  \date{15 October 2001}

  % \maketitle
@@ -64,7 +64,7 @@
  %
  % \end{abstract}

-%\tableofcontents
+\tableofcontents

  %- Body -----------------------------------------------------------------------%

diff --git a/tutorial/polytex b/tutorial/polytex
index 8444a2f..e544ad5 100755
--- a/tutorial/polytex
+++ b/tutorial/polytex
@@ -10,7 +10,7 @@ set -x
  case $# in
  0)
  	TEXFILE=$(tempfile --dir=/tmp --suffix=.tex)
-	./polytex2tex > $TEXFILE
+	gawk -f polytex2tex > $TEXFILE
  	latex $TEXFILE && rm $TEXFILE
  	;;
  1)
@@ -22,7 +22,7 @@ case $# in
  	case "$1" in
  	*.polytex)
  		TEXFILE=$(echo "$1" | sed 's/polytex$/tex/')
-		./polytex2tex "$1" > $TEXFILE
+		gawk -f polytex2tex "$1" > $TEXFILE
  		latex $TEXFILE
  		;;
  	*.tex)
diff --git a/tutorial/polytex2tex b/tutorial/polytex2tex
index bbde7cb..30fe3f2 100755
--- a/tutorial/polytex2tex
+++ b/tutorial/polytex2tex
@@ -1,5 +1,3 @@
-#!/usr/bin/gawk -f
-#
  # This is very similar to Hinze and Loh's lhs2tex program, but probably
  # simpler and works for arbitrary languages.
  #
@@ -170,7 +168,7 @@ function apply_subst(lhs, rhs, text,  a, string, i, result) {
  		result     = result substr(text, 1, RSTART - 1)
  		string     = rhs
  		text       = substr(text, RSTART + RLENGTH)
-		gsub(/\&/, a[0], string)
+		gsub(/&/, a[0], string)
  		for(i = 1; i in a; i++) {
  			gsub("\\\\"i, a[i], string)
  		}



More information about the reviews mailing list