@@ -84,7 +84,8 @@ is more general than this.
8484Let's investigate the behaviour of some other functors
8585that apply the pattern in different ways.
8686
87- *Futures*
87+
88+ === Futures
8889
8990`Future` is a functor that
9091sequences asynchronous computations by queueing them
@@ -129,12 +130,10 @@ val future: Future[String] =
129130Await.result(future, 1.second)
130131```
131132
132- # info [
133- *Futures and Referential Transparency*
134-
133+ # info (title : " Futures and Referential Transparency" )[
135134Note that Scala's `Futures` aren't a great example
136135of pure functional programming
137- because they aren't _referentially transparent_ .
136+ because they aren't *referentially transparent* .
138137`Future` always computes and caches a result
139138and there's no way for us to tweak this behaviour.
140139This means we can get unpredictable results
@@ -197,7 +196,8 @@ If `Future` isn't referentially transparent,
197196perhaps we should look at another similar data-type that is.
198197You should recognise this one...
199198
200- *Functions (?!)*
199+
200+ === Functions (?!)
201201
202202It turns out that single argument functions are also functors.
203203To see this we have to tweak the types a little.
@@ -266,9 +266,7 @@ val func =
266266func(123)
267267```
268268
269- # warning [
270- *Partial Unification*
271-
269+ # warning (title : " Partial Unification" )[
272270For the above examples to work,
273271in versions of Scala before 2.13,
274272we need to add the following compiler option to `build.sbt` :
@@ -323,11 +321,9 @@ trait Functor[F[_]] {
323321
324322If you haven't seen syntax like `F[_]` before,
325323it's time to take a brief detour to discuss
326- *type constructors_ and _ higher kinded types* .
327-
328- # warning [
329- *Functor Laws*
324+ *type constructors* and *higher kinded types* .
330325
326+ # warning (title : " Functor Laws" )[
331327Functors guarantee the same semantics
332328whether we sequence many small operations one by one,
333329or combine them into a larger function before `mapping` .
@@ -348,17 +344,17 @@ fa.map(g(f(_))) == fa.map(f).map(g)
348344```
349345]
350346
351- == Aside: Higher Kinds and Type Constructors
352347
348+ == Higher Kinds and Type Constructors
353349
354350Kinds are like types for types.
355351They describe the number of "holes" in a type.
356352We distinguish between regular types that have no holes
357- and " type constructors" that have
353+ and * type constructors* that have
358354holes we can fill to produce types.
359355
360356For example, `List` is a type constructor with one hole.
361- We fill that hole by specifying a parameter to produce
357+ We fill that hole with a type to produce
362358a regular type like `List[Int]` or `List[A]` .
363359The trick is not to confuse type constructors with generic types.
364360`List` is a type constructor, `List[A]` is a type:
0 commit comments