diff --git a/sofp-src/sofp-draft.pdf b/sofp-src/sofp-draft.pdf index d68be643d..cd648f104 100644 Binary files a/sofp-src/sofp-draft.pdf and b/sofp-src/sofp-draft.pdf differ diff --git a/sofp-src/sofp-nameless-functions.lyx b/sofp-src/sofp-nameless-functions.lyx index da6cb6b14..f6a0c7313 100644 --- a/sofp-src/sofp-nameless-functions.lyx +++ b/sofp-src/sofp-nameless-functions.lyx @@ -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 @@ -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 @@ -8934,6 +8966,7 @@ status open \begin_layout Plain Layout \series bold +\size small Language \end_layout @@ -8945,6 +8978,7 @@ Language \begin_layout Plain Layout \series bold +\size small Year \end_layout @@ -8956,6 +8990,7 @@ Year \begin_layout Plain Layout \series bold +\size small Code for \series default diff --git a/sofp-src/sofp-nameless-functions.tex b/sofp-src/sofp-nameless-functions.tex index 94ebcd294..478c78d60 100644 --- a/sofp-src/sofp-nameless-functions.tex +++ b/sofp-src/sofp-nameless-functions.tex @@ -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} @@ -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 diff --git a/sofp-src/sofp-typeclasses.lyx b/sofp-src/sofp-typeclasses.lyx index 6ad618ea4..0910c5913 100644 --- a/sofp-src/sofp-typeclasses.lyx +++ b/sofp-src/sofp-typeclasses.lyx @@ -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 @@ -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 diff --git a/sofp-src/sofp-typeclasses.tex b/sofp-src/sofp-typeclasses.tex index 08c967051..436e55f17 100644 --- a/sofp-src/sofp-typeclasses.tex +++ b/sofp-src/sofp-typeclasses.tex @@ -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. @@ -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, diff --git a/sofp-src/sofp.pdf b/sofp-src/sofp.pdf index c6166812a..2b5afaf1a 100644 Binary files a/sofp-src/sofp.pdf and b/sofp-src/sofp.pdf differ diff --git a/sofp-src/sofp.tex b/sofp-src/sofp.tex index 94057d478..6681e1e1a 100644 --- a/sofp-src/sofp.tex +++ b/sofp-src/sofp.tex @@ -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,