Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit 750d617

Browse files
committed
Complete updates to Functor chapter
1 parent 642320a commit 750d617

3 files changed

Lines changed: 15 additions & 18 deletions

File tree

src/pages/functors/contravariant-invariant.typ

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "../stdlib.typ": info, warning, solution, exercise
1+
#import "../stdlib.typ": href, info, warning, solution, exercise
22
== Contravariant and Invariant Functors
33
<sec:functors:contravariant-invariant>
44

@@ -256,10 +256,10 @@ a pair of bidirectional transformations.
256256

257257
The most intuitive examples of this are a type class
258258
that represents encoding and decoding as some data type,
259-
such as Circe's [`Codec`][link-circe-codec]
260-
and Play JSON's [`Format`][link-play-json-format].
259+
such as Circe's #href("https://github.com/circe/circe/blob/series/0.14.x/modules/core/shared/src/main/scala/io/circe/Codec.scala")[`Codec`]
260+
and Play JSON's #href("https://www.playframework.com/documentation/2.6.x/ScalaJsonCombinators#Format")[`Format`].
261261
We can build our own `Codec` by enhancing `Display`
262-
to support encoding and decoding to/from a `String`:
262+
to support encoding and decoding to and from a `String`:
263263

264264
```scala mdoc:silent
265265
trait Codec[A] {
@@ -333,9 +333,8 @@ If we want to model more sophisticated relationships
333333
we can move beyond functors
334334
to look at _lenses_ and _optics_.
335335

336-
Optics are beyond the scope of this book.
337-
However, Julien Truffaut's library
338-
[Monocle][link-monocle] provides a great
336+
Optics are beyond the scope of this book. However, the
337+
#href("https://github.com/optics-dev/Monocle")[Monocle] provides a great
339338
starting point for further investigation.
340339
]
341340

@@ -426,14 +425,12 @@ encode(Box(123.4))
426425
decode[Box[Double]]("123.4")
427426
```
428427

429-
#warning[
430-
*What's With the Names?*
431-
428+
#info(title: [What's With the Names?])[
432429
What's the relationship between the terms
433430
"contravariance", "invariance", and "covariance"
434431
and these different kinds of functor?
435432

436-
If you recall from @sec:variance,
433+
As we discussed in @sec:variance,
437434
variance affects subtyping,
438435
which is essentially our ability to use a value of one type
439436
in place of a value of another type

src/pages/functors/partial-unification.typ

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "../stdlib.typ": info, warning, solution
1+
#import "../stdlib.typ": href, info, warning, solution
22
== Aside: Partial Unification
33
<sec:functors:partial-unification>
44

@@ -44,7 +44,7 @@ type F[A] = Int => A
4444
type F[A] = A => Double
4545
```
4646

47-
*We* know that the former of these is the correct choice.
47+
_We_ know that the first one is the correct choice.
4848
However the compiler doesn't understand what the code means.
4949
Instead it relies on a simple rule,
5050
implementing what is called "partial unification".
@@ -83,7 +83,7 @@ In sbt we would add the compiler flag in `build.sbt`:
8383
scalacOptions += "-Ypartial-unification"
8484
```
8585

86-
The rationale behind this change is discussed in [SI-2712][link-si2712].
86+
The rationale behind this change is discussed in #href("https://issues.scala-lang.org/browse/SI-2712")[SI-2712].
8787
]
8888

8989

@@ -93,7 +93,7 @@ The rationale behind this change is discussed in [SI-2712][link-si2712].
9393

9494
There are situations where
9595
left-to-right elimination is not the correct choice.
96-
One example is the `Or` type in [Scalactic][link-scalactic],
96+
One example is the `Or` type in #href("http://scalactic.org")[Scalactic],
9797
which is a conventionally left-biased equivalent of `Either`:
9898

9999
```scala

src/pages/functors/summary.typ

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "../stdlib.typ": info, warning, solution
1+
#import "../stdlib.typ": href, info, warning, solution
22
== Summary
33

44

@@ -27,13 +27,13 @@ but even then it is rare to use them on their own.
2727
Functors form a foundational building block of
2828
several more interesting abstractions that we use all the time.
2929
In the following chapters we will look at two of these abstractions:
30-
*monads_ and _applicative functors*.
30+
*monads* and *applicative functors*.
3131

3232
Functors for collections are extremely important, as they transform each element independently of the rest.
3333
This allows us to parallelise or distribute
3434
transformations on large collections,
3535
a technique leveraged heavily in
36-
"map-reduce" frameworks like [Hadoop][link-hadoop].
36+
"map-reduce" frameworks popularized by #href("http://hadoop.apache.org")[Hadoop].
3737
We will investigate this approach in more detail in the
3838
map-reduce case study later in @sec:map-reduce.
3939

0 commit comments

Comments
 (0)