Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added translation of concrete syntax and corresponding Scala code

  • Loading branch information...
commit 09f0a8dec5d7bc84b613370a9728432679788681 1 parent 726a59d
Meredith Gregory authored
View
4 src/main/book/content/bibliography/monadic.aux
@@ -1,6 +1,6 @@
\relax
\@setckpt{bibliography/monadic}{
-\setcounter{page}{60}
+\setcounter{page}{64}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -19,7 +19,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{264}
\setcounter{theorem}{0}
\setcounter{section@level}{2}
View
12 src/main/book/content/chapters/eight/ch.aux
@@ -1,12 +1,12 @@
\relax
-\@writefile{toc}{\contentsline {chapter}{\numberline {8}Domain model, storage and state}{55}{chapter.8}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {8}Domain model, storage and state}{59}{chapter.8}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {8.1}Mapping our domain model to storage}{55}{section.8.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {8.2}Storage and language-integrated query}{55}{section.8.2}}
-\@writefile{toc}{\contentsline {section}{\numberline {8.3}Continuations revisited}{55}{section.8.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.1}Mapping our domain model to storage}{59}{section.8.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.2}Storage and language-integrated query}{59}{section.8.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {8.3}Continuations revisited}{59}{section.8.3}}
\@setckpt{chapters/eight/ch}{
-\setcounter{page}{56}
+\setcounter{page}{60}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -25,7 +25,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{264}
\setcounter{theorem}{0}
\setcounter{section@level}{1}
View
12 src/main/book/content/chapters/five/ch.aux
@@ -1,12 +1,12 @@
\relax
-\@writefile{toc}{\contentsline {chapter}{\numberline {5}The domain model as abstract syntax}{49}{chapter.5}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {5}The domain model as abstract syntax}{53}{chapter.5}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {5.1}Our abstract syntax}{49}{section.5.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {5.2}Our application domain model}{49}{section.5.2}}
-\@writefile{toc}{\contentsline {section}{\numberline {5.3}A transform pipeline}{49}{section.5.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.1}Our abstract syntax}{53}{section.5.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.2}Our application domain model}{53}{section.5.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {5.3}A transform pipeline}{53}{section.5.3}}
\@setckpt{chapters/five/ch}{
-\setcounter{page}{50}
+\setcounter{page}{54}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -25,7 +25,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{264}
\setcounter{theorem}{0}
\setcounter{section@level}{1}
View
12 src/main/book/content/chapters/four/ch.aux
@@ -1,12 +1,12 @@
\relax
-\@writefile{toc}{\contentsline {chapter}{\numberline {4}Parsing requests, monadically}{47}{chapter.4}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {4}Parsing requests, monadically}{51}{chapter.4}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {4.1}Obligatory parsing monad}{47}{section.4.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {4.2}Your parser combinators are showing}{47}{section.4.2}}
-\@writefile{toc}{\contentsline {section}{\numberline {4.3}EBNF and why higher levels of abstraction are better}{47}{section.4.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {4.1}Obligatory parsing monad}{51}{section.4.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {4.2}Your parser combinators are showing}{51}{section.4.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {4.3}EBNF and why higher levels of abstraction are better}{51}{section.4.3}}
\@setckpt{chapters/four/ch}{
-\setcounter{page}{48}
+\setcounter{page}{52}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -25,7 +25,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{264}
\setcounter{theorem}{0}
\setcounter{section@level}{1}
View
14 src/main/book/content/chapters/nine/ch.aux
@@ -1,13 +1,13 @@
\relax
-\@writefile{toc}{\contentsline {chapter}{\numberline {9}Putting it all together}{57}{chapter.9}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {9}Putting it all together}{61}{chapter.9}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {9.1}Our web application end-to-end}{57}{section.9.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {9.2}Deploying our application}{57}{section.9.2}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {9.2.1}Why we are not deploying on GAE}{57}{subsection.9.2.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {9.3}From one web application to web framework}{57}{section.9.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {9.1}Our web application end-to-end}{61}{section.9.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {9.2}Deploying our application}{61}{section.9.2}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {9.2.1}Why we are not deploying on GAE}{61}{subsection.9.2.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {9.3}From one web application to web framework}{61}{section.9.3}}
\@setckpt{chapters/nine/ch}{
-\setcounter{page}{58}
+\setcounter{page}{62}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -26,7 +26,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{264}
\setcounter{theorem}{0}
\setcounter{section@level}{1}
View
26 src/main/book/content/chapters/one/ch.aux
@@ -2,7 +2,7 @@
\@writefile{toc}{\contentsline {chapter}{\numberline {1}Motivation and Background}{3}{chapter.1}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {paragraph}{With apologies to Italo Calvino}{3}{section*.6}}
+\@writefile{toc}{\contentsline {paragraph}{If on a winter's night a programmer (with apologies to Italo Calvino)}{3}{section*.6}}
\@writefile{toc}{\contentsline {section}{\numberline {1.1}Where are we}{4}{section.1.1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.1.1}The concurrency squeeze: from the hardware up, from the web down}{4}{subsection.1.1.1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {1.1.2}Ubiquity of robust, high-performance virtual machines}{5}{subsection.1.1.2}}
@@ -20,25 +20,25 @@
\@writefile{toc}{\contentsline {paragraph}{A simple-minded representation}{17}{section*.9}}
\@writefile{toc}{\contentsline {paragraph}{Type parametrization and quotation}{18}{section*.10}}
\@writefile{toc}{\contentsline {paragraph}{Some syntactic sugar}{19}{section*.11}}
-\@writefile{toc}{\contentsline {paragraph}{Digression: complexity management principle}{19}{section*.12}}
+\@writefile{toc}{\contentsline {paragraph}{Digression: complexity management principle}{20}{section*.12}}
\@writefile{toc}{\contentsline {paragraph}{Concrete syntax}{20}{section*.13}}
\@writefile{toc}{\contentsline {paragraph}{Translating concrete syntax to abstract syntax}{20}{section*.14}}
-\@writefile{toc}{\contentsline {paragraph}{Structural equivalence and Relations or What makes abstract syntax abstract}{20}{section*.15}}
-\@writefile{toc}{\contentsline {paragraph}{Digression: the internal structure of the type of variables}{25}{section*.16}}
-\@writefile{toc}{\contentsline {paragraph}{Evaluation -- aka operational semantics}{25}{section*.17}}
-\@writefile{toc}{\contentsline {subsubsection}{What goes into a language definition}{27}{section*.18}}
-\@writefile{toc}{\contentsline {paragraph}{Syntax}{28}{section*.19}}
-\@writefile{toc}{\contentsline {paragraph}{Structural equivalence}{28}{section*.20}}
-\@writefile{toc}{\contentsline {paragraph}{Operational semantics}{28}{section*.21}}
-\@writefile{toc}{\contentsline {paragraph}{Discussion}{28}{section*.22}}
+\@writefile{toc}{\contentsline {paragraph}{Structural equivalence and Relations or What makes abstract syntax abstract}{23}{section*.15}}
+\@writefile{toc}{\contentsline {paragraph}{Digression: the internal structure of the type of variables}{27}{section*.16}}
+\@writefile{toc}{\contentsline {paragraph}{Evaluation -- aka operational semantics}{27}{section*.17}}
+\@writefile{toc}{\contentsline {subsubsection}{What goes into a language definition}{29}{section*.18}}
+\@writefile{toc}{\contentsline {paragraph}{Syntax}{30}{section*.19}}
+\@writefile{toc}{\contentsline {paragraph}{Structural equivalence}{30}{section*.20}}
+\@writefile{toc}{\contentsline {paragraph}{Operational semantics}{30}{section*.21}}
+\@writefile{toc}{\contentsline {paragraph}{Discussion}{30}{section*.22}}
\@setckpt{chapters/one/ch}{
-\setcounter{page}{29}
+\setcounter{page}{31}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
\setcounter{enumiii}{0}
\setcounter{enumiv}{0}
-\setcounter{footnote}{5}
+\setcounter{footnote}{6}
\setcounter{mpfootnote}{0}
\setcounter{part}{0}
\setcounter{chapter}{1}
@@ -51,7 +51,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{73}
\setcounter{theorem}{0}
\setcounter{section@level}{4}
View
118 src/main/book/content/chapters/one/how-are-we-going-to-get-there.tex
@@ -100,19 +100,23 @@ \subsubsection{Our toy language}
\texttt{Scala} code.
\break
-\begin{lstlisting}[language=Scala]
+\begin{lstlisting}[language=Scala,mathescape=true]
trait Expressions {
type Nominal
+ // $M,N ::=$
abstract class Expression
+ // $x$
case class Mention( reference : Nominal )
extends Expression
+ // $\lambda \; x_1,...,x_n.M$
case class Abstraction(
formals : List[Nominal],
body : Expression
) extends Expression
+ // $M N_1 ... N_n$
case class Application(
operation : Expression,
actuals : List[Expression]
@@ -267,10 +271,116 @@ \subsubsection{Our toy language}
\paragraph{Translating concrete syntax to abstract syntax}
The translation from the concrete syntax to the abstract syntax is
-compactly expressed as follows. Perhaps the best way to understand
-this presentation is in terms of a \texttt{Scala} implementation.
+compactly expressed as follows. Even if the form of the translation is
+unfamiliar, it should still leave you with the impression that some
+core of \texttt{Scala} is really the $\lambda$-calculus.
+
+% \begin{mathpar}
+% \inferrule* {} {\meaningof{\lstinline[language=Scala,mathescape=true]!x!} = x}
+% \and
+% \inferrule* {} {\meaningof{\lstinline[language=Scala,mathescape=true]!(x) $\Rightarrow$! expr } = \lambda \; x . \meaningof{expr} }
+% \inferrule* {} {\meaningof{\lstinline[language=Scala,mathescape=true]!val x!} = let \; x = \meaningof{expr_1} in \meaningof{expr_2} }
+% \end{mathpar}
+
+\begin{lstlisting}[language=Scala,mathescape=true]
+ $\ldb$ x $\rdb$ $=$ $x$
+ $\ldb$ (x) => expr $\rdb$ $=$ $\lambda \; x . \ldb$ expr $\rdb$
+ $\ldb$ expr( expr$_1$, ..., expr$_n$ ) $\rdb$ $=$ $\ldb$ expr $\rdb$ $\ldb$ expr$_1$ $\rdb$ ... $\ldb$ expr$n$ $\rdb$
+ $\ldb$ val x = expr$_1$ ; expr$_2$ $\rdb$ $=$ $let$ $\ldb$ x $\rdb$ $=$ $\ldb$ expr$_1$ $\rdb$ $in$ $\ldb$ expr$_2$ $\rdb$
+ $\ldb$ expr$_1$ ; expr$_2$ $\rdb$ $=$ $x$ $\ldb$ expr$_1$ $\rdb$ $;$ $\ldb$ expr$_2$ $\rdb$
+ $\ldb$ { expr } $\rdb$ $=$ ( $\ldb$ expr $\rdb$ )
+\end{lstlisting}
+Further, the value of the explicit representation of sugar in terms of
+structuring the translation should be clear. Of course, in a book
+entitled \emph{Pro Scala} the best way to unpack this presentation
+is in terms of a \texttt{Scala} implementation.
+
+\begin{lstlisting}[language=Scala,mathescape=true]
+ trait Compiler extends Expressions with Nominals {
+ // Abstract away interning variables
+ type Internist =
+ {def intern( varExpr : Absyn.VariableExpr ) : Nominal}
+ def internist() : Internist
+
+ def intern( varExpr : Absyn.VariableExpr )
+ : Nominal = { internist().intern( varExpr ) }
+ def compileExpr( numericExpr : Absyn.Numeric )
+ : Expression = {
+ new IntegerExpression(
+ numericExpr.integer_.asInstanceOf[Int]
+ )
+ }
+
+ // $\ldb$ x $\rdb$ $=$ $x$
+ def compileExpr( mentionExpr : Absyn.Mention )
+ : Expression = {
+ new Mention( intern( mentionExpr.variableexpr_ ) )
+ }
+ // $\ldb$ (x) => expr $\rdb$ $=$ $\lambda \; x . \ldb$ expr $\rdb$
+ def compileExpr( abstractionExpr : Absyn.Abstraction )
+ : Expression = {
+ val fmls : List[Nominal] =
+ abstractionExpr.listvariableexpr_.map(
+ { ( vExpr : Absyn.VariableExpr ) => intern( vExpr ) }
+ ).toList
+ new Abstraction( fmls, compile( abstractionExpr.expression_ ) )
+ }
+ // $\ldb$ expr( expr$_1$, ..., expr$_n$ ) $\rdb$
+ // $=$ $\ldb$ expr $\rdb$ $\ldb$ expr$_1$ $\rdb$ ... $\ldb$ expr$n$ $\rdb$
+ def compileExpr( applicationExpr : Absyn.Application )
+ : Expression = {
+ new Application(
+ compile( applicationExpr.expression_1 ),
+ List( compile( applicationExpr.expression_2 ) )
+ )
+ }
+
+ def compile( expr : Absyn.Expression )
+ : Expression = {
+ expr match {
+ case value : Absyn.Value => {
+ value.valueexpr_ match {
+ case numericExpr : Absyn.Numeric =>
+ compileExpr( numericExpr )
+ }
+ }
+ case numericExpr : Absyn.Numeric => {
+ compileExpr( numericExpr )
+ }
+ case mentionExpr : Absyn.Mention => {
+ compileExpr( mentionExpr )
+ }
+ case abstractionExpr : Absyn.Abstraction => {
+ compileExpr( abstractionExpr )
+ }
+ case applicationExpr : Absyn.Application => {
+ compileExpr( applicationExpr )
+ }
+ }
+ }
+
+ def parse( str : String ) : Absyn.Expression = {
+ (new parser(
+ new Yylex( new StringReader( str ) )
+ ) ).pExpression()
+ }
+
+ def compile( str : String ) : Expression = {
+ try {
+ compile( parse( str ) )
+ }
+ catch {
+ case e => { // log error
+ throw e
+ }
+ }
+ }
+ }
+\end{lstlisting}
+The first thing to notice about this translation is how faithfully it
+follows the equational specification.
\paragraph{Structural equivalence and Relations or What makes abstract syntax abstract}
@@ -449,7 +559,7 @@ \subsubsection{Our toy language}
\lstinline[language=Scala]!String!s, but what about
\lstinline[language=Scala]!Quotations!?
-The question reveals something quite startling about the types of
+The question reveals something quite startling about the types\footnote{Note that here we mean the type of the entity in the model that represents variables -- not a typing for variables in the language we're modeling.} of
variables. Clearly, the type has to include a definition of
equality. Now, if we want to have an inexhaustible supply of
variables, then the definition of equality of variables must make use
View
57 src/main/book/content/chapters/one/motivation.tex
@@ -1,20 +1,21 @@
-\paragraph{With apologies to Italo Calvino} You've just picked up the
-new book by Greg Meredith, Pro Scala. Perhaps you've heard about it on
-one of the mailing lists or seen it advertised on the \texttt{Scala}
-site or at Amazon. You're wondering if it's for you. Maybe you've been
-programming in functional languages or even \texttt{Scala} for as long
-as you can remember. Or maybe you've been a professional programmer
-for quite some time. Or maybe you're a manager of programmers, now and
-you're trying to stay abreast of the latest technology. Or, maybe
-you're a futurologist who looks at technology trends to get a sense of
-where things are heading. Whoever you are, if you're like most people,
-this book is going to make a lot more sense to you if you've already
-got about five to ten thousand hours of either \texttt{Scala} or some
-other functional language programming under your belt \footnote{ Now,
-i've been told that this is too much to expect of a would-be reader;
-but, when i whip out my calculator, i see that (5000 hrs / 25 hrs/wk )
-/ 52 wks/yr) = 3.84615384615 years. That means that if you've put in
-under four years at a hobbyist level, you've met this
+\paragraph{If on a winter's night a programmer (with apologies to Italo Calvino)}
+You've just picked up the new book by Greg Meredith, Pro
+Scala. Perhaps you've heard about it on one of the mailing lists or
+seen it advertised on the \texttt{Scala} site or at Amazon. You're
+wondering if it's for you. Maybe you've been programming in functional
+languages or even \texttt{Scala} for as long as you can remember. Or
+maybe you've been a professional programmer for quite some time. Or
+maybe you're a manager of programmers, now and you're trying to stay
+abreast of the latest technology. Or, maybe you're a futurologist who
+looks at technology trends to get a sense of where things are
+heading. Whoever you are, if you're like most people, this book is
+going to make a lot more sense to you if you've already got about five
+to ten thousand hours of either \texttt{Scala} or some other
+functional language programming under your belt \footnote{ Now, i've
+been told that this is too much to expect of a would-be reader; but,
+when i whip out my calculator, i see that (5000 hrs / 25 hrs/wk ) / 52
+wks/yr) = 3.84615384615 years. That means that if you've put in under
+four years at a hobbyist level, you've met this
requirement. Alternatively, if you've put in less than two years as a
professional working solely in functional languages, you've met the
requirement. Honestly, we don't have to give in to inflationary trends
@@ -41,12 +42,16 @@
applications with nearly continuous operation, 24x7 availability
servicing 100's to 1000's of concurrent requests. They are overwhelmed
by complexity. What the professional programmer really needs are tools
-for complexity management. The design patterns expressed in this book
-have been developed for nearly \emph{fifty} years to address exactly
-those concerns. Since \texttt{Scala} isn't nearly fifty years old you
-can guess that they have origins in older technologies, but
-\texttt{Scala}, it turns out, is an ideal framework in which both to
-realize them and to talk about their ins and outs and pros and
-cons. However, since they don't originate in \texttt{Scala}, you can
-also guess that they have some significant applicability to the other
-eleven technologies the modern professional programmer is juggling.
+for complexity management. The principle aim of this book is to serve
+that need in that community.
+
+The design patterns expressed in this book have been developed for
+nearly \emph{fifty} years to address exactly those concerns. Since
+\texttt{Scala} isn't nearly fifty years old you can guess that they
+have origins in older technologies, but \texttt{Scala}, it turns out,
+is an ideal framework in which both to realize them and to talk about
+their ins and outs and pros and cons. However, since they don't
+originate in \texttt{Scala}, you can also guess that they have some
+significant applicability to the other eleven technologies the modern
+professional programmer is juggling.
+
View
10 src/main/book/content/chapters/seven/ch.aux
@@ -1,11 +1,11 @@
\relax
-\@writefile{toc}{\contentsline {chapter}{\numberline {7}A review of collections as monads}{53}{chapter.7}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {7}A review of collections as monads}{57}{chapter.7}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {7.1}Monad as container}{53}{section.7.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {7.2}Monads and take-out}{53}{section.7.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.1}Monad as container}{57}{section.7.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {7.2}Monads and take-out}{57}{section.7.2}}
\@setckpt{chapters/seven/ch}{
-\setcounter{page}{54}
+\setcounter{page}{58}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -24,7 +24,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{264}
\setcounter{theorem}{0}
\setcounter{section@level}{1}
View
12 src/main/book/content/chapters/six/ch.aux
@@ -1,12 +1,12 @@
\relax
-\@writefile{toc}{\contentsline {chapter}{\numberline {6}Zippers and contexts and URI's, oh my!}{51}{chapter.6}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {6}Zippers and contexts and URI's, oh my!}{55}{chapter.6}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {6.1}Zippers are not just for Bruno anymore}{51}{section.6.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {6.2}Constructing contexts and zippers from data types}{51}{section.6.2}}
-\@writefile{toc}{\contentsline {section}{\numberline {6.3}Mapping URIs to zipper-based paths and back}{51}{section.6.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {6.1}Zippers are not just for Bruno anymore}{55}{section.6.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {6.2}Constructing contexts and zippers from data types}{55}{section.6.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {6.3}Mapping URIs to zipper-based paths and back}{55}{section.6.3}}
\@setckpt{chapters/six/ch}{
-\setcounter{page}{52}
+\setcounter{page}{56}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -25,7 +25,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{264}
\setcounter{theorem}{0}
\setcounter{section@level}{1}
View
16 src/main/book/content/chapters/ten/ch.aux
@@ -1,14 +1,14 @@
\relax
-\@writefile{toc}{\contentsline {chapter}{\numberline {10}The semantic web}{59}{chapter.10}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {10}The semantic web}{63}{chapter.10}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {10.1}How our web framework enables different kinds of application queries}{59}{section.10.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {10.2}Searching for programs}{59}{section.10.2}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {10.2.1}A new foundation for search}{59}{subsection.10.2.1}}
-\@writefile{toc}{\contentsline {subsubsection}{Monad composition via distributive laws}{59}{section*.37}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {10.2.2}Examples}{59}{subsection.10.2.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {10.1}How our web framework enables different kinds of application queries}{63}{section.10.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {10.2}Searching for programs}{63}{section.10.2}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {10.2.1}A new foundation for search}{63}{subsection.10.2.1}}
+\@writefile{toc}{\contentsline {subsubsection}{Monad composition via distributive laws}{63}{section*.37}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {10.2.2}Examples}{63}{subsection.10.2.2}}
\@setckpt{chapters/ten/ch}{
-\setcounter{page}{60}
+\setcounter{page}{64}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -27,7 +27,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{264}
\setcounter{theorem}{0}
\setcounter{section@level}{2}
View
16 src/main/book/content/chapters/three/ch.aux
@@ -1,14 +1,14 @@
\relax
-\@writefile{toc}{\contentsline {chapter}{\numberline {3}An IO-monad for http streams}{39}{chapter.3}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {3}An IO-monad for http streams}{43}{chapter.3}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {3.1}Code first, questions later}{39}{section.3.1}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {3.1.1}An HTTP-request processor}{46}{subsection.3.1.1}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {3.1.2}What we did}{46}{subsection.3.1.2}}
-\@writefile{toc}{\contentsline {section}{\numberline {3.2}Synchrony, asynchrony and buffering}{46}{section.3.2}}
-\@writefile{toc}{\contentsline {section}{\numberline {3.3}State, statelessness and continuations}{46}{section.3.3}}
+\@writefile{toc}{\contentsline {section}{\numberline {3.1}Code first, questions later}{43}{section.3.1}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {3.1.1}An HTTP-request processor}{50}{subsection.3.1.1}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {3.1.2}What we did}{50}{subsection.3.1.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {3.2}Synchrony, asynchrony and buffering}{50}{section.3.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {3.3}State, statelessness and continuations}{50}{section.3.3}}
\@setckpt{chapters/three/ch}{
-\setcounter{page}{47}
+\setcounter{page}{51}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -27,7 +27,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{264}
\setcounter{theorem}{0}
\setcounter{section@level}{1}
View
46 src/main/book/content/chapters/two/ch.aux
@@ -1,29 +1,29 @@
\relax
-\@writefile{toc}{\contentsline {chapter}{\numberline {2}Toolbox}{29}{chapter.2}}
+\@writefile{toc}{\contentsline {chapter}{\numberline {2}Toolbox}{31}{chapter.2}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
-\@writefile{toc}{\contentsline {section}{\numberline {2.1}Introduction to notation and terminology}{29}{section.2.1}}
-\@writefile{toc}{\contentsline {section}{\numberline {2.2}Introduction to core design patterns}{29}{section.2.2}}
-\@writefile{toc}{\contentsline {section}{\numberline {2.3}Variations in presentation}{29}{section.2.3}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {2.3.1}A little history}{29}{subsection.2.3.1}}
-\@writefile{toc}{\contentsline {paragraph}{Haskell's monad API}{30}{section*.23}}
-\@writefile{lol}{\contentsline {lstlisting}{\numberline {2.1}monad typeclass}{30}{lstlisting.2.1}}
-\@writefile{toc}{\contentsline {paragraph}{Do-notation}{30}{section*.24}}
-\@writefile{toc}{\contentsline {paragraph}{for-comprehensions}{31}{section*.25}}
-\@writefile{toc}{\contentsline {subsection}{\numberline {2.3.2}A little more history}{32}{subsection.2.3.2}}
-\@writefile{toc}{\contentsline {subsubsection}{Intuition: Monad as container}{33}{section*.26}}
-\@writefile{toc}{\contentsline {paragraph}{Shape of the container}{33}{section*.27}}
-\@writefile{toc}{\contentsline {paragraph}{Putting things into the container}{33}{section*.28}}
-\@writefile{toc}{\contentsline {paragraph}{Flattening nested containers}{33}{section*.29}}
-\@writefile{toc}{\contentsline {subsubsection}{Preserving connection to existing structure: Monad as generalization of monoid}{33}{section*.30}}
-\@writefile{toc}{\contentsline {paragraph}{Associativity as flattening}{36}{section*.31}}
-\@writefile{toc}{\contentsline {paragraph}{Syntax and containers}{36}{section*.32}}
-\@writefile{toc}{\contentsline {paragraph}{Bracing for \texttt {XML}}{36}{section*.33}}
-\@writefile{toc}{\contentsline {paragraph}{The connection with set-comprehensions}{37}{section*.34}}
-\@writefile{toc}{\contentsline {subsubsection}{Decomposition of monad requirements}{38}{section*.35}}
-\@writefile{toc}{\contentsline {subsubsection}{A categorical way to look at monads}{38}{section*.36}}
+\@writefile{toc}{\contentsline {section}{\numberline {2.1}Introduction to notation and terminology}{31}{section.2.1}}
+\@writefile{toc}{\contentsline {section}{\numberline {2.2}Introduction to core design patterns}{31}{section.2.2}}
+\@writefile{toc}{\contentsline {section}{\numberline {2.3}Variations in presentation}{31}{section.2.3}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {2.3.1}A little history}{31}{subsection.2.3.1}}
+\@writefile{toc}{\contentsline {paragraph}{Haskell's monad API}{32}{section*.23}}
+\@writefile{lol}{\contentsline {lstlisting}{\numberline {2.1}monad typeclass}{32}{lstlisting.2.1}}
+\@writefile{toc}{\contentsline {paragraph}{Do-notation}{32}{section*.24}}
+\@writefile{toc}{\contentsline {paragraph}{for-comprehensions}{33}{section*.25}}
+\@writefile{toc}{\contentsline {subsection}{\numberline {2.3.2}A little more history}{34}{subsection.2.3.2}}
+\@writefile{toc}{\contentsline {subsubsection}{Intuition: Monad as container}{35}{section*.26}}
+\@writefile{toc}{\contentsline {paragraph}{Shape of the container}{35}{section*.27}}
+\@writefile{toc}{\contentsline {paragraph}{Putting things into the container}{35}{section*.28}}
+\@writefile{toc}{\contentsline {paragraph}{Flattening nested containers}{35}{section*.29}}
+\@writefile{toc}{\contentsline {subsubsection}{Preserving connection to existing structure: Monad as generalization of monoid}{35}{section*.30}}
+\@writefile{toc}{\contentsline {paragraph}{Associativity as flattening}{38}{section*.31}}
+\@writefile{toc}{\contentsline {paragraph}{Syntax and containers}{38}{section*.32}}
+\@writefile{toc}{\contentsline {paragraph}{Bracing for \texttt {XML}}{38}{section*.33}}
+\@writefile{toc}{\contentsline {paragraph}{The connection with set-comprehensions}{39}{section*.34}}
+\@writefile{toc}{\contentsline {subsubsection}{Decomposition of monad requirements}{40}{section*.35}}
+\@writefile{toc}{\contentsline {subsubsection}{A categorical way to look at monads}{40}{section*.36}}
\@setckpt{chapters/two/ch}{
-\setcounter{page}{39}
+\setcounter{page}{42}
\setcounter{equation}{0}
\setcounter{enumi}{0}
\setcounter{enumii}{0}
@@ -42,7 +42,7 @@
\setcounter{table}{0}
\setcounter{parentequation}{0}
\setcounter{Item}{0}
-\setcounter{Hfootnote}{5}
+\setcounter{Hfootnote}{6}
\setcounter{lstnumber}{1}
\setcounter{theorem}{0}
\setcounter{section@level}{3}
View
88 src/main/book/content/chapters/two/variation-in-presentation.tex
@@ -332,8 +332,8 @@ \subsubsection{Preserving connection to existing structure: Monad as
\paragraph{Associativity as flattening}
Looking at it from the other way around, one of the properties of a
-monoid is that it's binary operation, it's
-\lstinline[language=Scala]!mult! is associative. The actual content of
+monoid is that it's binary operation, its
+\lstinline[language=Scala]!mult!, is associative. The actual content of
the notion of associativity is that order of grouping doesn't make any
difference. In symbols, a binary operation, $*$, is associative when
$a*(b*c) = (a*b)*c$. This fact gives us the right to erase the parens
@@ -400,14 +400,13 @@ \subsubsection{Preserving connection to existing structure: Monad as
polymorphically ``collect'' elements between braces, like $\{*| a, b, c |*\}$.
This is fine for finite collections, but what about infinitary
-collections or coollections of elements selected programmatically,
+collections or collections of elements selected programmatically,
rather than given explicitly. The set theoretic notation was designed
specifically for this purpose. When we have an extant set of elements
that we can give explicitly, we simply write $\{ a_1, a_2, a_3, ... \}$.
-
When we have a potentially infinitary collection of elements, or
elements that are selected on the basis of a condition, then we write
-$\{ pattern \in S | condition \}$. The idea of monad as comprehension
+$\{ pattern \in S \; | \; condition \}$. The idea of monad as comprehension
recognizes that these operations of collecting, pattern matching and
selection on the basis of a condition can be made \emph{polymorphic}
using monads. Notationally, we can denote the different polymorphic
@@ -419,26 +418,46 @@ \subsubsection{Preserving connection to existing structure: Monad as
\end{itemize}
to build into our notation an explicit representation of the fact that
the operation of collection, pattern matching and filtering on the
-basis of predicate are polymorphic.
+basis of predicate are polymorphic. Now, just to make sure the
+connection is absolutely explicit, there is a one-for-one
+correspondence between the polymorphic set-comprehension notation and
+the \lstinline[language=Scala]!for!-comprehension notation of
+\texttt{Scala}. The correspondence takes $\{*| pattern \in S \; | \; condition |*\}$ to
+
+\begin{lstlisting}[language=Scala,mathescape=true]
+ for( x <- $S$ if $condition$ ) yield {
+ x match { case $pattern$ => x }
+ }
+\end{lstlisting}
+
+As the \texttt{Scala} type checker will explain, this translation is
+only approximate. If the pattern is refutable, then we need to handle
+the \lstinline[language=Scala]!case! when the match is not
+possible. Obviously, we just want to throw those away, so a
+\lstinline[language=Scala]!fold! might be a better a better choice,
+but then that obscures the correspondence.
-Often times, good mathematics, like good programmings is really about
+
+Often times, good mathematics, like good programming is really about
the design of good notation -- it's about DSLs! In this case, the
notation is particularly useful because it begs the question of the
language of patterns and the language of conditions -- something that
Wadler's original paper on monads as generalized comprehensions did
not address. This is a theme to which we will return at the end of the
-book. For now, the central point is to understand how monad as
-container and monad as generalization of monoid are actually views of
-the same underlying idea.
+book when we address search on a semantics basis. For now, the central
+point is to understand how monad as container and monad as
+generalization of monoid are actually views of the same underlying
+idea.
\subsubsection{Decomposition of monad requirements}
-The constraints on any given monad candidate are well factored into
-three different kinds of requirements -- operating at different levels
-of the ``API'': functoriality, naturality and coherence. Often these
-can be mechanically verified, and when they can't there are natural
-ways to generate spot-checks that fit well with tools such as
-$\ScalaCheck$.
+In the presentation of the monad API that we've discussed here the
+constraints on any given monad candidate are well factored into three
+different kinds of requirements -- operating at different levels of
+the ``API'', dubbed in order of abstraction: functoriality, naturality
+and coherence. Often these can be mechanically verified, and when they
+can't there are natural ways to generate spot-checks that fit well
+with tools such as $\ScalaCheck$.
\subsubsection{A categorical way to look at monads}
@@ -446,33 +465,42 @@ \subsubsection{A categorical way to look at monads}
following data
\begin{itemize}
- \item a ``unit'' map enjoying the signature $unit : A \to T[A]$
- \item a ``mult'' map enjoying the signature $mult : T[T[A]] \to T[A]$
+ \item a ``unit'' map enjoying the signature $unit : A \to S[A]$
+ \item a ``mult'' map enjoying the signature $mult : S[S[A]] \to S[A]$
\end{itemize}
subject to the following laws:
\begin{itemize}
- \item $T( id_A ) = id_{T[A]}$ %[Functoriality]
- \item %[Naturality]
+ \item Functoriality
+ \begin{itemize}
+ \item $S( id_A ) = id_{S[A]}$
+ \item $S( f \circ g ) = S( f ) \circ S( g )$
+ \end{itemize}
+ \item Naturality
\begin{itemize}
\item $unit(f) \circ unit_{A} = unit_{B} \circ unit(B)$ %[unit]
- \item $mult(f) \circ mult_{T[A]} = mult_{T[B]} \circ mult(B)$ %[mult]
+ \item $mult(f) \circ mult_{S[A]} = mult_{S[B]} \circ mult(B)$ %[mult]
\end{itemize}
- \item %[Coherence]
+ \item Coherence
\begin{itemize}
- \item $mult \circ T mult = mult \circ mult T$ %[mult-mult]
- \item $mult \circ T unit = mult \circ unit T$ %[mult-unit]
+ \item $mult \circ S mult = mult \circ mult \; S$ %[mult-mult]
+ \item $mult \circ S unit = mult \circ unit \; S$ %[mult-unit]
\end{itemize}
\end{itemize}
-These two definitions are interchangeable. That's what makes them
-``presentations'' of the same underlying idea.
+\texttt{Scala} programmers can certainly understand these laws with a
+little unpacking.
+
+% These two definitions are interchangeable. That's what makes them
+% ``presentations'' of the same underlying idea.
+
+% One of the reasons for the difference in presentation is that $\Haskell$
+% doesn't treat the Monad type class as a Functor. The refactoring of
+% the $mult$ map into the $bind$ map is that it builds functoriality
+% into definition. The other reason is the do notation.
+
-One of the reasons for the difference in presentation is that $\Haskell$
-doesn't treat the Monad type class as a Functor. The refactoring of
-the $mult$ map into the $bind$ map is that it builds functoriality
-into definition. The other reason is the do notation.
View
11 src/main/book/content/local/local.tex
@@ -15,3 +15,14 @@
\def\Haskell{\texttt{Haskell}}
\def\XML{\texttt{XML}}
+\newcommand{\ldb}{[\![}
+\newcommand{\rdb}{]\!]}
+\newcommand{\ldrb}{(\!(}
+\newcommand{\rdrb}{)\!)}
+\newcommand{\lliftb}{\langle\!|}
+\newcommand{\rliftb}{|\!\rangle}
+
+\newcommand{\lrclr}{(\!*|}
+\newcommand{\rrclr}{|\!*)}
+
+\newcommand{\meaningof}[1]{\ldb #1 \rdb}
View
141 src/main/book/content/monadic.log
@@ -1,4 +1,4 @@
-This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=pdflatex 2008.11.17) 1 MAR 2010 02:13
+This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=pdflatex 2008.11.17) 2 MAR 2010 01:42
entering extended mode
**monadic.tex
(./monadic.tex
@@ -371,7 +371,7 @@ Underfull \vbox (badness 2689) has occurred while \output is active []
s been already used, duplicate ignored
<to be read again>
\penalty
-l.50 ... IO-monad for http streams}{39}{chapter.3}
+l.50 ... IO-monad for http streams}{43}{chapter.3}
[1
] [2])
@@ -413,13 +413,13 @@ l.4 \chapter
]
Chapter 1.
-(./chapters/one/motivation.tex) (./chapters/one/where-are-we.tex
+(./chapters/one/motivation.tex
! pdfTeX warning (ext4): destination with the same identifier (name{page.3}) ha
s been already used, duplicate ignored
<to be read again>
\penalty
-l.1 \section
- {Where are we} [3]
+l.47
+ [3]) (./chapters/one/where-are-we.tex
! pdfTeX warning (ext4): destination with the same identifier (name{page.4}) ha
s been already used, duplicate ignored
<to be read again>
@@ -442,16 +442,16 @@ s been already used, duplicate ignored
\penalty
l.128
[6]
-Underfull \vbox (badness 1755) has occurred while \output is active []
+Underfull \vbox (badness 10000) has occurred while \output is active []
! pdfTeX warning (ext4): destination with the same identifier (name{page.7}) ha
s been already used, duplicate ignored
<to be read again>
\penalty
-l.206
- [7]
-Underfull \vbox (badness 10000) has occurred while \output is active []
+l.179 S
+ till these languages suffered when it came to a compelling and [7]
+Underfull \vbox (badness 1755) has occurred while \output is active []
! pdfTeX warning (ext4): destination with the same identifier (name{page.8}) ha
@@ -510,90 +510,103 @@ Underfull \vbox (badness 10000) has occurred while \output is active []
[17]
[18]
-Overfull \hbox (3.25792pt too wide) in paragraph at lines 167--168
+Overfull \hbox (3.25792pt too wide) in paragraph at lines 171--172
[][][][][][][][][][][][][][][][][][][][][][][][][]
[]
[19]
-LaTeX Font Info: Try loading font information for OMS+cmtt on input line 232
+LaTeX Font Info: Try loading font information for OMS+cmtt on input line 236
.
-LaTeX Font Info: No file OMScmtt.fd. on input line 232.
+LaTeX Font Info: No file OMScmtt.fd. on input line 236.
LaTeX Font Warning: Font shape `OMS/cmtt/m/n' undefined
(Font) using `OMS/cmsy/m/n' instead
-(Font) for symbol `textbraceleft' on input line 232.
+(Font) for symbol `textbraceleft' on input line 236.
-[20]
LaTeX Font Info: Try loading font information for OML+cmr on input line 287.
- (/opt/local/share/texmf-dist/tex/latex/base/omlcmr.fd
+(/opt/local/share/texmf-dist/tex/latex/base/omlcmr.fd
File: omlcmr.fd 1999/05/25 v2.5h Standard LaTeX font definitions
)
LaTeX Font Info: Font shape `OML/cmr/bx/n' in size <12> not available
(Font) Font shape `OML/cmm/b/it' tried instead on input line 287.
+ [20]
+Overfull \hbox (14.39014pt too wide) in paragraph at lines 288--289
+[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][
+][][][][][]
+ []
-Overfull \hbox (3.25792pt too wide) in paragraph at lines 309--310
-[][][][][][][][][][][][][][][][][][][][][][][][][][][]
+
+Overfull \hbox (59.65782pt too wide) in paragraph at lines 327--328
+[][][][][][][][][][][][][][][][][][][][][][]
[]
[21]
Underfull \vbox (badness 10000) has occurred while \output is active []
[22]
-Overfull \hbox (3.25792pt too wide) in paragraph at lines 384--385
+Overfull \hbox (3.25792pt too wide) in paragraph at lines 419--420
+[][][][][][][][][][][][][][][][][][][][][][][][][][][]
+ []
+
+[23]
+Underfull \vbox (badness 10000) has occurred while \output is active []
+
+ [24]
+Overfull \hbox (3.25792pt too wide) in paragraph at lines 494--495
[][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[]
Underfull \vbox (badness 10000) has occurred while \output is active []
- [23]
-Overfull \hbox (24.40788pt too wide) in paragraph at lines 406--407
+ [25]
+Overfull \hbox (24.40788pt too wide) in paragraph at lines 516--517
[][][][][][][][][][][][][][][][][][][][][][][]
[]
-Overfull \hbox (59.65782pt too wide) in paragraph at lines 411--412
+Overfull \hbox (59.65782pt too wide) in paragraph at lines 521--522
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[]
-[24] [25]
-Overfull \hbox (10.3079pt too wide) in paragraph at lines 514--515
+[26] [27]
+Overfull \hbox (10.3079pt too wide) in paragraph at lines 624--625
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[]
-Overfull \hbox (17.3579pt too wide) in paragraph at lines 530--531
+Overfull \hbox (17.3579pt too wide) in paragraph at lines 640--641
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[]
Underfull \vbox (badness 10000) has occurred while \output is active []
- [26]
-Overfull \hbox (3.25792pt too wide) in paragraph at lines 544--545
+ [28]
+Overfull \hbox (3.25792pt too wide) in paragraph at lines 654--655
[][][][][][][][][][][][][][][][][][][][][]
[]
-Overfull \hbox (24.40788pt too wide) in paragraph at lines 550--551
+Overfull \hbox (24.40788pt too wide) in paragraph at lines 660--661
[][][][][][][][][][][][][][][][][][]
[]
-Overfull \hbox (45.55785pt too wide) in paragraph at lines 554--555
+Overfull \hbox (45.55785pt too wide) in paragraph at lines 664--665
[][][][][][][][][][][][][][][][][][][][][][][][]
[]
-[27]) [28])
+[29]) [30])
\openout2 = `chapters/two/ch.aux'.
(./chapters/two/ch.tex
Chapter 2.
(./chapters/two/toolbox.tex) (./chapters/two/notation-and-terminology.tex)
(./chapters/two/core-design-patterns.tex)
-(./chapters/two/variation-in-presentation.tex [29
+(./chapters/two/variation-in-presentation.tex [31
@@ -602,7 +615,7 @@ LaTeX Font Info: Font shape `OML/cmr/m/n' in size <12> not available
(Font) Font shape `OML/cmm/m/it' tried instead on input line 26.
Package hyperref Info: bookmark level for unknown lstlisting defaults to 0 on i
nput line 36.
- [30] [31]
+ [32] [33]
Overfull \hbox (3.40813pt too wide) in paragraph at lines 127--129
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[]
@@ -613,23 +626,23 @@ Overfull \hbox (40.958pt too wide) in paragraph at lines 133--134
][][][][][][][][]
[]
-[32] [33] [34] [35]
+[34] [35] [36] [37]
LaTeX Warning: Command \texttrademark invalid in math mode on input line 359.
LaTeX Font Info: Font shape `OT1/cmtt/bx/n' in size <12> not available
(Font) Font shape `OT1/cmtt/m/n' tried instead on input line 364.
-[36] [37]) [38])
+[38] [39] [40]) [41])
\openout2 = `chapters/three/ch.aux'.
- (./chapters/three/ch.tex
-Chapter 3.
-(./chapters/three/io-monad-for-http-streams.tex)
-(./chapters/three/code-first.tex [39
+ (./chapters/three/ch.tex [42
]
+Chapter 3.
+(./chapters/three/io-monad-for-http-streams.tex)
+(./chapters/three/code-first.tex [43]
Overfull \hbox (10.3079pt too wide) in paragraph at lines 34--36
[][][][][][][][][][][][][][][][][][][][][][]
[]
@@ -659,7 +672,7 @@ Overfull \hbox (3.25792pt too wide) in paragraph at lines 63--65
Underfull \vbox (badness 10000) has occurred while \output is active []
- [40]
+ [44]
Overfull \hbox (94.90776pt too wide) in paragraph at lines 65--66
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]
[]
@@ -677,7 +690,7 @@ Overfull \hbox (101.95775pt too wide) in paragraph at lines 84--85
Underfull \vbox (badness 10000) has occurred while \output is active []
- [41]
+ [45]
Overfull \hbox (66.70781pt too wide) in paragraph at lines 114--116
[][][][][][][][][][][][][][][][][][][][][][][][]
[]
@@ -690,7 +703,7 @@ Overfull \hbox (109.00774pt too wide) in paragraph at lines 134--135
Underfull \vbox (badness 10000) has occurred while \output is active []
- [42]
+ [46]
Overfull \hbox (45.55785pt too wide) in paragraph at lines 150--151
[][][][][][][][][][][][][][][][][][][][][]
[]
@@ -708,7 +721,7 @@ Overfull \hbox (17.3579pt too wide) in paragraph at lines 164--165
Underfull \vbox (badness 10000) has occurred while \output is active []
- [43]
+ [47]
Overfull \hbox (66.70781pt too wide) in paragraph at lines 198--199
[][][][][][][][][][][][][][][][][][][][][]
[]
@@ -726,7 +739,7 @@ Overfull \hbox (17.3579pt too wide) in paragraph at lines 220--221
Underfull \vbox (badness 10000) has occurred while \output is active []
- [44]
+ [48]
Overfull \hbox (87.85777pt too wide) in paragraph at lines 244--245
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][
]
@@ -744,14 +757,14 @@ LaTeX Font Info: Font shape `OMS/cmr/m/it' in size <12> not available
(./chapters/three/state-statelessness-continuations.tex
Underfull \vbox (badness 10000) has occurred while \output is active []
- [45])
-[46])
+ [49])
+[50])
\openout2 = `chapters/four/ch.aux'.
(./chapters/four/ch.tex
Chapter 4.
(./chapters/four/parsing.tex) (./chapters/four/obligatory-parsing-monad.tex)
-(./chapters/four/parser-combinators.tex) (./chapters/four/EBNF.tex) [47
+(./chapters/four/parser-combinators.tex) (./chapters/four/EBNF.tex) [51
@@ -759,7 +772,7 @@ Chapter 4.
\openout2 = `chapters/five/ch.aux'.
-(./chapters/five/ch.tex [48
+(./chapters/five/ch.tex [52
@@ -767,10 +780,10 @@ Chapter 4.
Chapter 5.
(./chapters/five/domain-model.tex) (./chapters/five/abstract-syntax.tex)
(./chapters/five/application-domain-model.tex)
-(./chapters/five/transform-pipeline.tex) [49])
+(./chapters/five/transform-pipeline.tex) [53])
\openout2 = `chapters/six/ch.aux'.
- (./chapters/six/ch.tex [50
+ (./chapters/six/ch.tex [54
@@ -783,21 +796,21 @@ Overfull \hbox (3.44252pt too wide) in paragraph at lines 1--1
[]\OT1/cmr/bx/n/17.28 Mapping URIs to zipper-based paths and back
[]
-) [51])
+) [55])
\openout2 = `chapters/seven/ch.aux'.
- (./chapters/seven/ch.tex [52
+ (./chapters/seven/ch.tex [56
]
Chapter 7.
(./chapters/seven/collections-as-monads.tex) (./chapters/seven/container.tex)
-(./chapters/seven/monad-and-comonad.tex) [53])
+(./chapters/seven/monad-and-comonad.tex) [57])
\openout2 = `chapters/eight/ch.aux'.
(./chapters/eight/ch.tex
-[54
+[58
@@ -805,11 +818,11 @@ Chapter 7.
Chapter 8.
(./chapters/eight/domain-state-storage.tex)
(./chapters/eight/model-to-store.tex) (./chapters/eight/storage-LINQ.tex)
-(./chapters/eight/continuations-revisited.tex) [55])
+(./chapters/eight/continuations-revisited.tex) [59])
\openout2 = `chapters/nine/ch.aux'.
(./chapters/nine/ch.tex
-[56
+[60
@@ -817,17 +830,17 @@ Chapter 8.
Chapter 9.
(./chapters/nine/putting-it-all-together.tex) (./chapters/nine/end-to-end.tex)
(./chapters/nine/deployment.tex) (./chapters/nine/application-to-framework.tex)
-[57])
+[61])
\openout2 = `chapters/ten/ch.aux'.
- (./chapters/ten/ch.tex [58
+ (./chapters/ten/ch.tex [62
]
Chapter 10.
(./chapters/ten/semantic-web.tex) (./chapters/ten/new-queries.tex)
-(./chapters/ten/search-for-behavior.tex) [59])
+(./chapters/ten/search-for-behavior.tex) [63])
\openout2 = `bibliography/monadic.aux'.
@@ -841,16 +854,16 @@ LaTeX Font Warning: Some font shapes were not available, defaults substituted.
)
Here is how much of TeX's memory you used:
- 7110 strings out of 94500
- 98547 string characters out of 1174972
- 186572 words of memory out of 1000000
- 9257 multiletter control sequences out of 10000+50000
+ 7249 strings out of 94500
+ 100554 string characters out of 1174972
+ 189625 words of memory out of 1000000
+ 9295 multiletter control sequences out of 10000+50000
18278 words of font info for 70 fonts, out of 500000 for 2000
580 hyphenation exceptions out of 1000
31i,20n,43p,360b,1553s stack positions out of 1500i,500n,5000p,200000b,5000s
PDF statistics:
- 1256 PDF objects out of 300000
- 729 named destinations out of 131072
+ 1370 PDF objects out of 300000
+ 830 named destinations out of 131072
456 words of extra memory for PDF output out of 65536
</opt/local/share/texmf-dist/fonts/type1/bluesky/cm/cmsy8.pfb></opt/local/sha
re/texmf-dist/fonts/type1/bluesky/cm/cmmib10.pfb></opt/local/share/texmf-dist/f
@@ -867,4 +880,4 @@ cmti10.pfb></opt/local/share/texmf-dist/fonts/type1/bluesky/cm/cmsy10.pfb></opt
/local/share/texmf-dist/fonts/type1/bluesky/cm/cmr10.pfb></opt/local/share/texm
f-dist/fonts/type1/bluesky/cm/cmr12.pfb></opt/local/share/texmf-dist/fonts/type
1/bluesky/cm/cmr17.pfb>
-Output written on monadic.pdf (68 pages, 704442 bytes).
+Output written on monadic.pdf (72 pages, 726258 bytes).
View
BIN  src/main/book/content/monadic.pdf
Binary file not shown
View
132 src/main/book/content/monadic.toc
@@ -1,7 +1,7 @@
\contentsline {chapter}{Contents}{i}{section*.1}
\contentsline {chapter}{Preface}{1}{chapter*.5}
\contentsline {chapter}{\numberline {1}Motivation and Background}{3}{chapter.1}
-\contentsline {paragraph}{With apologies to Italo Calvino}{3}{section*.6}
+\contentsline {paragraph}{If on a winter's night a programmer (with apologies to Italo Calvino)}{3}{section*.6}
\contentsline {section}{\numberline {1.1}Where are we}{4}{section.1.1}
\contentsline {subsection}{\numberline {1.1.1}The concurrency squeeze: from the hardware up, from the web down}{4}{subsection.1.1.1}
\contentsline {subsection}{\numberline {1.1.2}Ubiquity of robust, high-performance virtual machines}{5}{subsection.1.1.2}
@@ -16,70 +16,70 @@
\contentsline {paragraph}{A simple-minded representation}{17}{section*.9}
\contentsline {paragraph}{Type parametrization and quotation}{18}{section*.10}
\contentsline {paragraph}{Some syntactic sugar}{19}{section*.11}
-\contentsline {paragraph}{Digression: complexity management principle}{19}{section*.12}
+\contentsline {paragraph}{Digression: complexity management principle}{20}{section*.12}
\contentsline {paragraph}{Concrete syntax}{20}{section*.13}
\contentsline {paragraph}{Translating concrete syntax to abstract syntax}{20}{section*.14}
-\contentsline {paragraph}{Structural equivalence and Relations or What makes abstract syntax abstract}{20}{section*.15}
-\contentsline {paragraph}{Digression: the internal structure of the type of variables}{25}{section*.16}
-\contentsline {paragraph}{Evaluation -- aka operational semantics}{25}{section*.17}
-\contentsline {subsubsection}{What goes into a language definition}{27}{section*.18}
-\contentsline {paragraph}{Syntax}{28}{section*.19}
-\contentsline {paragraph}{Structural equivalence}{28}{section*.20}
-\contentsline {paragraph}{Operational semantics}{28}{section*.21}
-\contentsline {paragraph}{Discussion}{28}{section*.22}
-\contentsline {chapter}{\numberline {2}Toolbox}{29}{chapter.2}
-\contentsline {section}{\numberline {2.1}Introduction to notation and terminology}{29}{section.2.1}
-\contentsline {section}{\numberline {2.2}Introduction to core design patterns}{29}{section.2.2}
-\contentsline {section}{\numberline {2.3}Variations in presentation}{29}{section.2.3}
-\contentsline {subsection}{\numberline {2.3.1}A little history}{29}{subsection.2.3.1}
-\contentsline {paragraph}{Haskell's monad API}{30}{section*.23}
-\contentsline {paragraph}{Do-notation}{30}{section*.24}
-\contentsline {paragraph}{for-comprehensions}{31}{section*.25}
-\contentsline {subsection}{\numberline {2.3.2}A little more history}{32}{subsection.2.3.2}
-\contentsline {subsubsection}{Intuition: Monad as container}{33}{section*.26}
-\contentsline {paragraph}{Shape of the container}{33}{section*.27}
-\contentsline {paragraph}{Putting things into the container}{33}{section*.28}
-\contentsline {paragraph}{Flattening nested containers}{33}{section*.29}
-\contentsline {subsubsection}{Preserving connection to existing structure: Monad as generalization of monoid}{33}{section*.30}
-\contentsline {paragraph}{Associativity as flattening}{36}{section*.31}
-\contentsline {paragraph}{Syntax and containers}{36}{section*.32}
-\contentsline {paragraph}{Bracing for \texttt {XML}}{36}{section*.33}
-\contentsline {paragraph}{The connection with set-comprehensions}{37}{section*.34}
-\contentsline {subsubsection}{Decomposition of monad requirements}{38}{section*.35}
-\contentsline {subsubsection}{A categorical way to look at monads}{38}{section*.36}
-\contentsline {chapter}{\numberline {3}An IO-monad for http streams}{39}{chapter.3}
-\contentsline {section}{\numberline {3.1}Code first, questions later}{39}{section.3.1}
-\contentsline {subsection}{\numberline {3.1.1}An HTTP-request processor}{46}{subsection.3.1.1}
-\contentsline {subsection}{\numberline {3.1.2}What we did}{46}{subsection.3.1.2}
-\contentsline {section}{\numberline {3.2}Synchrony, asynchrony and buffering}{46}{section.3.2}
-\contentsline {section}{\numberline {3.3}State, statelessness and continuations}{46}{section.3.3}
-\contentsline {chapter}{\numberline {4}Parsing requests, monadically}{47}{chapter.4}
-\contentsline {section}{\numberline {4.1}Obligatory parsing monad}{47}{section.4.1}
-\contentsline {section}{\numberline {4.2}Your parser combinators are showing}{47}{section.4.2}
-\contentsline {section}{\numberline {4.3}EBNF and why higher levels of abstraction are better}{47}{section.4.3}
-\contentsline {chapter}{\numberline {5}The domain model as abstract syntax}{49}{chapter.5}
-\contentsline {section}{\numberline {5.1}Our abstract syntax}{49}{section.5.1}
-\contentsline {section}{\numberline {5.2}Our application domain model}{49}{section.5.2}
-\contentsline {section}{\numberline {5.3}A transform pipeline}{49}{section.5.3}
-\contentsline {chapter}{\numberline {6}Zippers and contexts and URI's, oh my!}{51}{chapter.6}
-\contentsline {section}{\numberline {6.1}Zippers are not just for Bruno anymore}{51}{section.6.1}
-\contentsline {section}{\numberline {6.2}Constructing contexts and zippers from data types}{51}{section.6.2}
-\contentsline {section}{\numberline {6.3}Mapping URIs to zipper-based paths and back}{51}{section.6.3}
-\contentsline {chapter}{\numberline {7}A review of collections as monads}{53}{chapter.7}
-\contentsline {section}{\numberline {7.1}Monad as container}{53}{section.7.1}
-\contentsline {section}{\numberline {7.2}Monads and take-out}{53}{section.7.2}
-\contentsline {chapter}{\numberline {8}Domain model, storage and state}{55}{chapter.8}
-\contentsline {section}{\numberline {8.1}Mapping our domain model to storage}{55}{section.8.1}
-\contentsline {section}{\numberline {8.2}Storage and language-integrated query}{55}{section.8.2}
-\contentsline {section}{\numberline {8.3}Continuations revisited}{55}{section.8.3}
-\contentsline {chapter}{\numberline {9}Putting it all together}{57}{chapter.9}
-\contentsline {section}{\numberline {9.1}Our web application end-to-end}{57}{section.9.1}
-\contentsline {section}{\numberline {9.2}Deploying our application}{57}{section.9.2}
-\contentsline {subsection}{\numberline {9.2.1}Why we are not deploying on GAE}{57}{subsection.9.2.1}
-\contentsline {section}{\numberline {9.3}From one web application to web framework}{57}{section.9.3}
-\contentsline {chapter}{\numberline {10}The semantic web}{59}{chapter.10}
-\contentsline {section}{\numberline {10.1}How our web framework enables different kinds of application queries}{59}{section.10.1}
-\contentsline {section}{\numberline {10.2}Searching for programs}{59}{section.10.2}
-\contentsline {subsection}{\numberline {10.2.1}A new foundation for search}{59}{subsection.10.2.1}
-\contentsline {subsubsection}{Monad composition via distributive laws}{59}{section*.37}
-\contentsline {subsection}{\numberline {10.2.2}Examples}{59}{subsection.10.2.2}
+\contentsline {paragraph}{Structural equivalence and Relations or What makes abstract syntax abstract}{23}{section*.15}
+\contentsline {paragraph}{Digression: the internal structure of the type of variables}{27}{section*.16}
+\contentsline {paragraph}{Evaluation -- aka operational semantics}{27}{section*.17}
+\contentsline {subsubsection}{What goes into a language definition}{29}{section*.18}
+\contentsline {paragraph}{Syntax}{30}{section*.19}
+\contentsline {paragraph}{Structural equivalence}{30}{section*.20}
+\contentsline {paragraph}{Operational semantics}{30}{section*.21}
+\contentsline {paragraph}{Discussion}{30}{section*.22}
+\contentsline {chapter}{\numberline {2}Toolbox}{31}{chapter.2}
+\contentsline {section}{\numberline {2.1}Introduction to notation and terminology}{31}{section.2.1}
+\contentsline {section}{\numberline {2.2}Introduction to core design patterns}{31}{section.2.2}
+\contentsline {section}{\numberline {2.3}Variations in presentation}{31}{section.2.3}
+\contentsline {subsection}{\numberline {2.3.1}A little history}{31}{subsection.2.3.1}
+\contentsline {paragraph}{Haskell's monad API}{32}{section*.23}
+\contentsline {paragraph}{Do-notation}{32}{section*.24}
+\contentsline {paragraph}{for-comprehensions}{33}{section*.25}
+\contentsline {subsection}{\numberline {2.3.2}A little more history}{34}{subsection.2.3.2}
+\contentsline {subsubsection}{Intuition: Monad as container}{35}{section*.26}
+\contentsline {paragraph}{Shape of the container}{35}{section*.27}
+\contentsline {paragraph}{Putting things into the container}{35}{section*.28}
+\contentsline {paragraph}{Flattening nested containers}{35}{section*.29}
+\contentsline {subsubsection}{Preserving connection to existing structure: Monad as generalization of monoid}{35}{section*.30}
+\contentsline {paragraph}{Associativity as flattening}{38}{section*.31}
+\contentsline {paragraph}{Syntax and containers}{38}{section*.32}
+\contentsline {paragraph}{Bracing for \texttt {XML}}{38}{section*.33}
+\contentsline {paragraph}{The connection with set-comprehensions}{39}{section*.34}
+\contentsline {subsubsection}{Decomposition of monad requirements}{40}{section*.35}
+\contentsline {subsubsection}{A categorical way to look at monads}{40}{section*.36}
+\contentsline {chapter}{\numberline {3}An IO-monad for http streams}{43}{chapter.3}
+\contentsline {section}{\numberline {3.1}Code first, questions later}{43}{section.3.1}
+\contentsline {subsection}{\numberline {3.1.1}An HTTP-request processor}{50}{subsection.3.1.1}
+\contentsline {subsection}{\numberline {3.1.2}What we did}{50}{subsection.3.1.2}
+\contentsline {section}{\numberline {3.2}Synchrony, asynchrony and buffering}{50}{section.3.2}
+\contentsline {section}{\numberline {3.3}State, statelessness and continuations}{50}{section.3.3}
+\contentsline {chapter}{\numberline {4}Parsing requests, monadically}{51}{chapter.4}
+\contentsline {section}{\numberline {4.1}Obligatory parsing monad}{51}{section.4.1}
+\contentsline {section}{\numberline {4.2}Your parser combinators are showing}{51}{section.4.2}
+\contentsline {section}{\numberline {4.3}EBNF and why higher levels of abstraction are better}{51}{section.4.3}
+\contentsline {chapter}{\numberline {5}The domain model as abstract syntax}{53}{chapter.5}
+\contentsline {section}{\numberline {5.1}Our abstract syntax}{53}{section.5.1}
+\contentsline {section}{\numberline {5.2}Our application domain model}{53}{section.5.2}
+\contentsline {section}{\numberline {5.3}A transform pipeline}{53}{section.5.3}
+\contentsline {chapter}{\numberline {6}Zippers and contexts and URI's, oh my!}{55}{chapter.6}
+\contentsline {section}{\numberline {6.1}Zippers are not just for Bruno anymore}{55}{section.6.1}
+\contentsline {section}{\numberline {6.2}Constructing contexts and zippers from data types}{55}{section.6.2}
+\contentsline {section}{\numberline {6.3}Mapping URIs to zipper-based paths and back}{55}{section.6.3}
+\contentsline {chapter}{\numberline {7}A review of collections as monads}{57}{chapter.7}
+\contentsline {section}{\numberline {7.1}Monad as container}{57}{section.7.1}
+\contentsline {section}{\numberline {7.2}Monads and take-out}{57}{section.7.2}
+\contentsline {chapter}{\numberline {8}Domain model, storage and state}{59}{chapter.8}
+\contentsline {section}{\numberline {8.1}Mapping our domain model to storage}{59}{section.8.1}
+\contentsline {section}{\numberline {8.2}Storage and language-integrated query}{59}{section.8.2}
+\contentsline {section}{\numberline {8.3}Continuations revisited}{59}{section.8.3}
+\contentsline {chapter}{\numberline {9}Putting it all together}{61}{chapter.9}
+\contentsline {section}{\numberline {9.1}Our web application end-to-end}{61}{section.9.1}
+\contentsline {section}{\numberline {9.2}Deploying our application}{61}{section.9.2}
+\contentsline {subsection}{\numberline {9.2.1}Why we are not deploying on GAE}{61}{subsection.9.2.1}
+\contentsline {section}{\numberline {9.3}From one web application to web framework}{61}{section.9.3}
+\contentsline {chapter}{\numberline {10}The semantic web}{63}{chapter.10}
+\contentsline {section}{\numberline {10.1}How our web framework enables different kinds of application queries}{63}{section.10.1}
+\contentsline {section}{\numberline {10.2}Searching for programs}{63}{section.10.2}
+\contentsline {subsection}{\numberline {10.2.1}A new foundation for search}{63}{subsection.10.2.1}
+\contentsline {subsubsection}{Monad composition via distributive laws}{63}{section*.37}
+\contentsline {subsection}{\numberline {10.2.2}Examples}{63}{subsection.10.2.2}
Please sign in to comment.
Something went wrong with that request. Please try again.