From 6efa5c4c818d5218602dff90edcf0681a7b15c03 Mon Sep 17 00:00:00 2001 From: "sergei.winitzki" Date: Sun, 21 Mar 2021 22:59:24 +0100 Subject: [PATCH] minor correction --- sofp-src/sofp-applicative.lyx | 52 ++++++++++++++--------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/sofp-src/sofp-applicative.lyx b/sofp-src/sofp-applicative.lyx index af2827923..27601e1f5 100644 --- a/sofp-src/sofp-applicative.lyx +++ b/sofp-src/sofp-applicative.lyx @@ -276,18 +276,10 @@ Motivation for applicative functors \end_layout \begin_layout Standard -\begin_inset ERT -status open - -\begin_layout Plain Layout - - -\backslash -vspace{-0.25cm} +We would like to parallelize independent computations \end_layout -\end_inset - +\begin_layout Standard Monads are inconvenient for expressing \emph on independent @@ -452,10 +444,6 @@ Future { c1 }.flatMap { x \end_layout -\begin_layout Standard -We would like to parallelize independent computations -\end_layout - \begin_layout Standard We would like to accumulate \emph on @@ -634,7 +622,10 @@ for { \end_layout \begin_layout Standard -We would like to express a computation where effects are unordered +We would like to express a computation where effects are unordered and / + or do not depend on previous results. + flatMap cannot express independent effects even if we use flatMap(_ => + ...) \end_layout \begin_layout Standard @@ -721,18 +712,6 @@ map3 \end_layout \begin_layout Standard -\begin_inset ERT -status open - -\begin_layout Plain Layout - - -\backslash -vspace{-0.15cm} -\end_layout - -\end_inset - Consider 1, 2, 3, ... commutative and independent \begin_inset Quotes eld @@ -1104,6 +1083,10 @@ status open \end_inset +\family default +\size default +\color inherit + \begin_inset ERT status open @@ -1116,6 +1099,13 @@ hrule \end_inset +Note that the map2 function defined via flatMap will have the right type + signature and will work. + But sometimes we need a different implementation, not equivalent to an + implementation via flatMap. +\family typewriter +\size footnotesize +\color blue \begin_inset VSpace defskip \end_inset @@ -5332,7 +5322,7 @@ contramap Examples of profunctors: \size footnotesize -\begin_inset Formula $P^{A}\triangleq\bbnum1+\text{Int}\times A\rightarrow A$ +\begin_inset Formula $P^{A}\triangleq\bbnum 1+\text{Int}\times A\rightarrow A$ \end_inset ; @@ -6231,7 +6221,7 @@ pure \begin_layout Enumerate Show that -\begin_inset Formula $F^{A}\triangleq\left(A\rightarrow Z\right)\rightarrow\bbnum 1+A$ +\begin_inset Formula $F^{A}\triangleq\left(A\rightarrow Z\right)\rightarrow\bbnum1+A$ \end_inset is a functor but not applicative. @@ -6255,7 +6245,7 @@ Show that \begin_layout Enumerate Implement an applicative instance for -\begin_inset Formula $F^{A}=\bbnum 1+\text{Int}\times A+A\times A\times A$ +\begin_inset Formula $F^{A}=\bbnum1+\text{Int}\times A+A\times A\times A$ \end_inset . @@ -6297,7 +6287,7 @@ For any contrafunctor \begin_layout Enumerate Show that the recursive functor -\begin_inset Formula $F^{A}\triangleq\bbnum 1+G^{A\times F^{A}}$ +\begin_inset Formula $F^{A}\triangleq\bbnum1+G^{A\times F^{A}}$ \end_inset is applicative if