|
1 | | -#import "../stdlib.typ": info, warning, solution, exercise |
| 1 | +#import "../stdlib.typ": href, info, warning, solution, exercise |
2 | 2 | == Contravariant and Invariant Functors |
3 | 3 | <sec:functors:contravariant-invariant> |
4 | 4 |
|
@@ -256,10 +256,10 @@ a pair of bidirectional transformations. |
256 | 256 |
|
257 | 257 | The most intuitive examples of this are a type class |
258 | 258 | 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`]. |
261 | 261 | 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`: |
263 | 263 |
|
264 | 264 | ```scala mdoc:silent |
265 | 265 | trait Codec[A] { |
@@ -333,9 +333,8 @@ If we want to model more sophisticated relationships |
333 | 333 | we can move beyond functors |
334 | 334 | to look at _lenses_ and _optics_. |
335 | 335 |
|
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 |
339 | 338 | starting point for further investigation. |
340 | 339 | ] |
341 | 340 |
|
@@ -426,14 +425,12 @@ encode(Box(123.4)) |
426 | 425 | decode[Box[Double]]("123.4") |
427 | 426 | ``` |
428 | 427 |
|
429 | | -#warning[ |
430 | | -*What's With the Names?* |
431 | | - |
| 428 | +#info(title: [What's With the Names?])[ |
432 | 429 | What's the relationship between the terms |
433 | 430 | "contravariance", "invariance", and "covariance" |
434 | 431 | and these different kinds of functor? |
435 | 432 |
|
436 | | -If you recall from @sec:variance, |
| 433 | +As we discussed in @sec:variance, |
437 | 434 | variance affects subtyping, |
438 | 435 | which is essentially our ability to use a value of one type |
439 | 436 | in place of a value of another type |
|
0 commit comments