Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei.winitzki committed Nov 8, 2020
1 parent 9cda9f5 commit 281e2be
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 14 deletions.
Binary file modified sofp-src/sofp-draft.pdf
Binary file not shown.
35 changes: 35 additions & 0 deletions sofp-src/sofp-nameless-functions.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -8806,6 +8806,21 @@ map
\end_inset

) is created in Scala with this code:
\end_layout

\begin_layout Standard
\begin_inset Wrap figure
lines 0
placement l
overhang 0in
width "38col%"
status open

\begin_layout Plain Layout
\begin_inset VSpace -80baselineskip%
\end_inset


\begin_inset listings
inline false
status open
Expand All @@ -8817,6 +8832,23 @@ Map("a" -> 1, "b" -> 2, "c" -> 3)

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset VSpace -120baselineskip%
\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Standard
\noindent
This is a nameless expression whose value is a dictionary.
In programming languages that do not have such a construction, programmers
have to write repetitive code that creates an initially empty dictionary
Expand Down Expand Up @@ -8934,6 +8966,7 @@ status open
\begin_layout Plain Layout

\series bold
\size small
Language
\end_layout

Expand All @@ -8945,6 +8978,7 @@ Language
\begin_layout Plain Layout

\series bold
\size small
Year
\end_layout

Expand All @@ -8956,6 +8990,7 @@ Year
\begin_layout Plain Layout

\series bold
\size small
Code for
\series default

Expand Down
17 changes: 12 additions & 5 deletions sofp-src/sofp-nameless-functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1387,13 +1387,20 @@ \subsection{Named and nameless expressions and their uses}
It is similarly useful if data structures can be created without names.
For instance, a \textbf{dictionary}\index{dictionary} (also called
a \textsf{``}map\textsf{''}) is created in Scala with this code:
\begin{wrapfigure}{l}{0.38\columnwidth}%
\vspace{-0.8\baselineskip}
\begin{lstlisting}
Map("a" -> 1, "b" -> 2, "c" -> 3)
\end{lstlisting}
This is a nameless expression whose value is a dictionary. In programming
languages that do not have such a construction, programmers have to
write repetitive code that creates an initially empty dictionary and
then fills it step by step with values:
\vspace{-1.2\baselineskip}
\end{wrapfigure}%
\noindent This is a nameless expression whose value is a dictionary.
In programming languages that do not have such a construction, programmers
have to write repetitive code that creates an initially empty dictionary
and then fills it step by step with values:
\begin{wrapfigure}{l}{0.38\columnwidth}%
\vspace{-0.7\baselineskip}
Expand All @@ -1416,7 +1423,7 @@ \subsection{Named and nameless expressions and their uses}
\vspace{-8\baselineskip}
\begin{tabular}{|c|c|c|}
\hline
\textbf{Language} & \textbf{Year} & \textbf{Code for }$k\rightarrow k+1$\tabularnewline
\textbf{\small{}Language} & \textbf{\small{}Year} & \textbf{\small{}Code for }{\small{}$k\rightarrow k+1$}\tabularnewline
\hline
\hline
{\footnotesize{}$\lambda$-calculus} & {\footnotesize{}1936} & $\lambda k.~add~k~1$\tabularnewline
Expand Down
6 changes: 1 addition & 5 deletions sofp-src/sofp-typeclasses.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -37637,7 +37637,7 @@ HasDefault
\end_inset

typeclasses.
We may want to express inheritance relations between typeclasses, so that
We may want to express inheritance relations between typeclasses, so that,
e.g., a
\begin_inset listings
inline true
Expand Down Expand Up @@ -38193,10 +38193,6 @@ object TC2 { implicit def toTC[A](implicit x: TC2[A]): TC[A] = x.tc }

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

// The function f requires A to have both TC1 and TC2 instances and then
wants to access TC instance.
\end_layout
Expand Down
3 changes: 1 addition & 2 deletions sofp-src/sofp-typeclasses.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5923,7 +5923,7 @@ \subsection{Inheritance and automatic conversions of typeclasses\label{subsec:In
typeclasses. One says that the \lstinline!Monoid! typeclass \textbf{inherits}\index{typeclass!inheritance}
from the \lstinline!Semigroup! and \lstinline!HasDefault! typeclasses.
We may want to express inheritance relations between typeclasses,
so that e.g., a \lstinline!Monoid! instance should automatically
so that, e.g., a \lstinline!Monoid! instance should automatically
imply the presence of a \lstinline!Semigroup! instance, without extra
code.
Expand Down Expand Up @@ -6006,7 +6006,6 @@ \subsection{Inheritance and automatic conversions of typeclasses\label{subsec:In
object TC1 { implicit def toTC[A](implicit x: TC1[A]): TC[A] = x.tc }
final case class TC2[A]()(implicit val tc: TC[A]) // TC2 inherits TC.
object TC2 { implicit def toTC[A](implicit x: TC2[A]): TC[A] = x.tc }
// The function f requires A to have both TC1 and TC2 instances and then wants to access TC instance.
def f[A: TC1 : TC2]() = {
import TC1._ // Can import TC1._ or TC2._ but not both. If the next line is uncommented,
Expand Down
Binary file modified sofp-src/sofp.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions sofp-src/sofp.tex
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@
~\\
ISBN: 978-0-359-76877-6\\
\\
{\scriptsize{}Source hash: 3515c69cb444b87f936718c788552de2c08f6770282e8efc9ac274deecac4799}\\
{\scriptsize{}Git commit: c1f1b28b34ff90d02ac51ba7313a0234de2b46be}\\
{\scriptsize{}Source hash: 0b6314be48493c4785d3049162e147d8bf855fb7c13434baec80cd6beb76e2dd}\\
{\scriptsize{}Git commit: 9cda9f594d97030fb053e2e52ceeb3647d24c2a9}\\
~\\
{\scriptsize{}Permission is granted to copy, distribute and/or modify
this document under the terms of the GNU Free Documentation License,
Expand Down

0 comments on commit 281e2be

Please sign in to comment.