Skip to content

Commit

Permalink
Small fixes + version bump!
Browse files Browse the repository at this point in the history
This fixes several issues:
fixes #42
fixes #45
fixes #53
fixes #60
fixes #69
fixes #70
fixes #36
  • Loading branch information
hmemcpy committed Oct 16, 2017
1 parent 51a71ee commit ee59574
Show file tree
Hide file tree
Showing 26 changed files with 214 additions and 224 deletions.
8 changes: 4 additions & 4 deletions src/content/0.0/Preface.tex
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

\begin{figure}
\centering
\fbox{\includegraphics[width=3.12500in]{images/img_1299.jpg}}
\includegraphics[width=70mm]{images/img_1299.jpg}
\end{figure}

One of the forces that are driving the big change is the multicore
Expand Down Expand Up @@ -131,7 +131,7 @@
us to rethink the foundations of programming. Just like the builders of
Europe's great gothic cathedrals we've been honing our craft to the
limits of material and structure. There is an unfinished gothic
\href{http://en.wikipedia.org/wiki/Beauvais_Cathedral}{cathedral in
\urlref{http://en.wikipedia.org/wiki/Beauvais_Cathedral}{cathedral in
Beauvais}, France, that stands witness to this deeply human struggle
with limitations. It was intended to beat all previous records of height
and lightness, but it suffered a series of collapses. Ad hoc measures
Expand All @@ -148,6 +148,6 @@

\begin{figure}
\centering
\fbox{\includegraphics[totalheight=8cm]{images/beauvais_interior_supports.jpg}}
\includegraphics[totalheight=8cm]{images/beauvais_interior_supports.jpg}
\caption{Ad hoc measures preventing the Beauvais cathedral from collapsing.}
\end{figure}
\end{figure}
29 changes: 14 additions & 15 deletions src/content/1.1/Category - The Essence of Composition.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
why categories are so easy to represent pictorially. An object can be
drawn as a circle or a point, and an arrow\ldots{} is an arrow. (Just
for variety, I will occasionally draw objects as piggies and arrows as
fireworks.) But the essence of a category is \newterm{composition}. Or, if you
fireworks.) But the essence of a category is \emph{composition}. Or, if you
prefer, the essence of composition is a category. Arrows compose, so
if you have an arrow from object $A$ to object $B$, and another arrow from
object $B$ to object $C$, then there must be an arrow --- their composition
Expand All @@ -17,17 +17,17 @@
category because it’s missing identity morphisms (see later).}
\end{figure}

\section{Arrows as Functions}\label{arrows-as-functions}
\section{Arrows as Functions}

Is this already too much abstract nonsense? Do not despair. Let's talk
concretes. Think of arrows, which are also called \newterm{morphisms}, as
functions. You have a function \code{f} that takes an argument of type $A$ and
returns a $B$. You have another function \code{g} that takes a $B$ and returns a $C$.
functions. You have a function $f$ that takes an argument of type $A$ and
returns a $B$. You have another function $g$ that takes a $B$ and returns a $C$.
You can compose them by passing the result of $f$ to $g$. You have just
defined a new function that takes an $A$ and returns a $C$.

In math, such composition is denoted by a small circle between
functions: \ensuremath{g \circ f}. Notice the right to left order of composition. For some
functions: $g \circ f$. Notice the right to left order of composition. For some
people this is confusing. You may be familiar with the pipe notation in
Unix, as in:

Expand All @@ -36,7 +36,7 @@ \section{Arrows as Functions}\label{arrows-as-functions}
\end{Verbatim}
or the chevron \code{>>} in F\#, which both
go from left to right. But in mathematics and in Haskell functions
compose right to left. It helps if you read \(g \circ f\) as ``g \emph{after} f.''
compose right to left. It helps if you read $g \circ f$ as ``g \emph{after} f.''

Let's make this even more explicit by writing some C code. We have one
function \code{f} that takes an argument of type \code{A} and
Expand Down Expand Up @@ -83,12 +83,12 @@ \section{Arrows as Functions}\label{arrows-as-functions}
straightforward functional concepts in C++ is a little embarrassing. In
fact, Haskell will let you use Unicode characters so you can write
composition as:

% don't 'mathify' this block
\begin{Verbatim}
g ◦ f
\end{Verbatim}
You can even use Unicode double colons and arrows:

% don't 'mathify' this block
\begin{Verbatim}[commandchars=\\\{\}]
f \ensuremath{\Colon} A → B
\end{Verbatim}
Expand All @@ -97,7 +97,7 @@ \section{Arrows as Functions}\label{arrows-as-functions}
two types. You compose two functions by inserting a period between them
(or a Unicode circle).

\section{Properties of Composition}\label{properties-of-composition}
\section{Properties of Composition}

There are two extremely important properties that the composition in any
category must satisfy.
Expand All @@ -108,7 +108,7 @@ \section{Properties of Composition}\label{properties-of-composition}
that can be composed (that is, their objects match end-to-end), you
don't need parentheses to compose them. In math notation this is
expressed as:
\[h\circ{}(g\circ{}f) = (h\circ{}g)\circ{}f = h\circ{}g\circ{}f\]
\[h \circ (g \circ f) = (h \circ g) \circ f = h \circ g \circ f\]
In (pseudo) Haskell:

\begin{Verbatim}
Expand Down Expand Up @@ -186,7 +186,7 @@ \section{Properties of Composition}\label{properties-of-composition}
Romans had a number system without a zero and they were able to build
excellent roads and aqueducts, some of which survive to this day.

Neutral values like zero or \code{id} are extremely useful when
Neutral values like zero or $\id$ are extremely useful when
working with symbolic variables. That's why Romans were not very good at
algebra, whereas the Arabs and the Persians, who were familiar with the
concept of zero, were. So the identity function becomes very handy as an
Expand All @@ -198,8 +198,7 @@ \section{Properties of Composition}\label{properties-of-composition}
Arrows can be composed, and the composition is associative. Every object
has an identity arrow that serves as a unit under composition.

\section{Composition is the Essence of
Programming}\label{composition-is-the-essence-of-programming}
\section{Composition is the Essence of Programming}

Functional programmers have a peculiar way of approaching problems. They
start by asking very Zen-like questions. For instance, when designing an
Expand All @@ -223,7 +222,7 @@ \section{Composition is the Essence of
imposed on us by computers. It reflects the limitations of the human
mind. Our brains can only deal with a small number of concepts at a
time. One of the most cited papers in psychology,
\href{http://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two}{The
\urlref{http://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two}{The
Magical Number Seven, Plus or Minus Two}, postulated that we can only
keep $7 \pm 2$ ``chunks'' of information in our minds. The details of our
understanding of the human short-term memory might be changing, but we
Expand Down Expand Up @@ -263,7 +262,7 @@ \section{Composition is the Essence of
understand how to compose it with other objects, you've lost the
advantages of your programming paradigm.

\section{Challenges}\label{challenges}
\section{Challenges}

\begin{enumerate}
\tightlist
Expand Down
18 changes: 9 additions & 9 deletions src/content/1.10/Natural Transformations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

\begin{wrapfigure}[13]{R}{0pt}
\raisebox{0pt}[\dimexpr\height-0.75\baselineskip\relax]{
\fbox{\includegraphics[width=60mm]{images/1_functors.jpg}}}%
\includegraphics[width=60mm]{images/1_functors.jpg}}%
\end{wrapfigure}

\noindent
Expand All @@ -29,7 +29,7 @@

\begin{figure}[H]
\centering
\fbox{\includegraphics[width=80mm]{images/2_natcomp.jpg}}
\includegraphics[width=80mm]{images/2_natcomp.jpg}
\end{figure}

\noindent
Expand Down Expand Up @@ -131,7 +131,7 @@
a natural transformation whose components are all isomorphisms
(invertible morphisms).

\section{Polymorphic Functions}\label{polymorphic-functions}
\section{Polymorphic Functions}

We talked about the role of functors (or, more specifically,
endofunctors) in programming. They correspond to type constructors that
Expand Down Expand Up @@ -355,7 +355,7 @@ \section{Polymorphic Functions}\label{polymorphic-functions}
\end{Verbatim}
There are only two of these, \code{dumb} and \code{obvious}:

\begin{Verbatim}[commandchars=\\\{\}]
\begin{Verbatim}
dumb (Reader _) = Nothing
\end{Verbatim}
and
Expand All @@ -371,7 +371,7 @@ \section{Polymorphic Functions}\label{polymorphic-functions}
and \code{Just ()}. We'll come back to the Yoneda lemma later ---
this was just a little teaser.

\section{Beyond Naturality}\label{beyond-naturality}
\section{Beyond Naturality}

A parametrically polymorphic function between two functors (including
the edge case of the \code{Const} functor) is always a natural
Expand Down Expand Up @@ -441,7 +441,7 @@ \section{Beyond Naturality}\label{beyond-naturality}
transformations, called dinatural transformations, that deals with such
cases. We'll get to them when we discuss ends.

\section{Functor Category}\label{functor-category}
\section{Functor Category}

Now that we have mappings between functors --- natural transformations
--- it's only natural to ask the question whether functors form a
Expand Down Expand Up @@ -550,7 +550,7 @@ \section{Functor Category}\label{functor-category}
$\cat{D^C}$ is a category, which we can identify with the
functor category between $\cat{C}$ and $\cat{D}$.

\section{2-Categories}\label{categories}
\section{2-Categories}

With that out of the way, let's have a closer look at $\Cat$. By
definition, any Hom-set in $\Cat$ is a set of functors. But, as we
Expand Down Expand Up @@ -748,7 +748,7 @@ \section{Conclusion}
they become sources and targets of morphisms: natural transformations. A
natural transformation is a special type of polymorphic function.

\section{Challenges}\label{challenges}
\section{Challenges}

\begin{enumerate}
\tightlist
Expand Down Expand Up @@ -780,7 +780,7 @@ \section{Challenges}\label{challenges}
\end{Verbatim}
and

\begin{Verbatim}[commandchars=\\\{\}]
\begin{Verbatim}
f :: String -> Int
f x = read x
\end{Verbatim}
Expand Down
24 changes: 11 additions & 13 deletions src/content/1.2/Types and Functions.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
\lettrine[lhang=0.17]{T}{he category of types and functions} plays an important role in
programming, so let's talk about what types are and why we need them.

\section{Who Needs Types?}\label{who-needs-types}
\section{Who Needs Types?}

There seems to be some controversy about the advantages of static vs.
dynamic and strong vs. weak typing. Let me illustrate these choices with
Expand Down Expand Up @@ -35,8 +35,7 @@ \section{Who Needs Types?}\label{who-needs-types}
once Romeo is declared a human being, he doesn't sprout leaves or trap
photons in his powerful gravitational field.

\section{Types Are About
Composability}\label{types-are-about-composability}
\section{Types Are About Composability}

Category theory is about composing arrows. But not any two arrows can be
composed. The target object of one arrow must be the same as the source
Expand Down Expand Up @@ -95,7 +94,7 @@ \section{Types Are About
almost always a probabilistic rather than a deterministic process.
Testing is a poor substitute for proof.

\section{What Are Types?}\label{what-are-types}
\section{What Are Types?}

The simplest intuition for types is that they are sets of values. The
type \code{Bool} (remember, concrete types start with a capital letter
Expand Down Expand Up @@ -147,7 +146,7 @@ \section{What Are Types?}\label{what-are-types}
scientists came up with a brilliant idea, or a major hack, depending on
your point of view, to extend every type by one more special value
called the \newterm{bottom} and denoted by \code{\_|\_}, or
Unicode \ensuremath{\bot}. This ``value'' corresponds to a non-terminating computation.
Unicode $\bot$. This ``value'' corresponds to a non-terminating computation.
So a function declared as:

\begin{Verbatim}
Expand Down Expand Up @@ -180,7 +179,7 @@ \section{What Are Types?}\label{what-are-types}
functions, which return valid results for every possible argument.

Because of the bottom, you'll see the category of Haskell types and
functions referred to as \textbf{Hask} rather than $\Set$. From
functions referred to as $\cat{Hask}$ rather than $\Set$. From
the theoretical point of view, this is the source of never-ending
complications, so at this point I will use my butcher's knife and
terminate this line of reasoning. From the pragmatic point of view, it's
Expand All @@ -189,8 +188,7 @@ \section{What Are Types?}\label{what-are-types}
John Hughes, Patrik Jansson, Jeremy Gibbons, \href{http://www.cs.ox.ac.uk/jeremy.gibbons/publications/fast+loose.pdf}{
Fast and Loose Reasoning is Morally Correct}. This paper provides justification for ignoring bottoms in most contexts.}

\section{Why Do We Need a Mathematical
Model?}\label{why-do-we-need-a-mathematical-model}
\section{Why Do We Need a Mathematical Model?}

As a programmer you are intimately familiar with the syntax and grammar
of your programming language. These aspects of the language are usually
Expand Down Expand Up @@ -283,7 +281,7 @@ \section{Why Do We Need a Mathematical
appreciate the thought that functions and algorithms from the Haskell
standard library come with proofs of correctness.

\section{Pure and Dirty Functions}\label{pure-and-dirty-functions}
\section{Pure and Dirty Functions}

The things we call functions in C++ or any other imperative language,
are not the same things mathematicians call functions. A mathematical
Expand Down Expand Up @@ -311,7 +309,7 @@ \section{Pure and Dirty Functions}\label{pure-and-dirty-functions}
all kinds of effects using only pure functions. So we really don't lose
anything by restricting ourselves to mathematical functions.

\section{Examples of Types}\label{examples-of-types}
\section{Examples of Types}

Once you realize that types are sets, you can think of some rather
exotic types. For instance, what's the type corresponding to an empty
Expand Down Expand Up @@ -384,8 +382,8 @@ \section{Examples of Types}\label{examples-of-types}
mathematical sense of the word. A pure function that returns unit does
nothing: it discards its argument.

Mathematically, a function from a set A to a singleton set maps every
element of A to the single element of that singleton set. For every A
Mathematically, a function from a set $A$ to a singleton set maps every
element of $A$ to the single element of that singleton set. For every $A$
there is exactly one such function. Here's this function for
\code{Integer}:

Expand Down Expand Up @@ -458,7 +456,7 @@ \section{Examples of Types}\label{examples-of-types}
have the form \code{ctype::is(alpha, c)},
\code{ctype::is(digit, c)}, etc.

\section{Challenges}\label{challenges}
\section{Challenges}

\begin{enumerate}
\tightlist
Expand Down
Loading

0 comments on commit ee59574

Please sign in to comment.