Skip to content

Commit c62f5d4

Browse files
alvinjb-studios
authored andcommitted
Starting to resolve my TODO tags
1 parent 0573bbf commit c62f5d4

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

_overviews/scala3-book/ca-context-bounds.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ next-page: ca-given-imports
1313
- TODO: define "synthesized" and "synthesized arguments"
1414
{% endcomment %}
1515

16-
17-
In many situations the name of a *context parameter* doesn’t have to be mentioned explicitly, since it’s only used in synthesized arguments for other context parameters.
16+
In many situations the name of a _context parameter_ doesn’t have to be mentioned explicitly, since it’s only used in synthesized arguments for other context parameters.
1817
In that case you don’t have to define a parameter name, and can just provide the parameter type.
1918

2019

2120
## Background
2221

23-
For example, this `maximum` method takes a *context parameter* of type `Ord`, only to pass it on as an argument to `max`:
22+
For example, this `maximum` method takes a _context parameter_ of type `Ord`, only to pass it on as an argument to `max`:
2423

2524
```scala
2625
def maximum[T](xs: List[A])(using ord: Ord[A]): A =
@@ -37,7 +36,7 @@ def maximum[T](xs: List[A])(using Ord[A]): A =
3736

3837
## Context bounds
3938

40-
Given that background, a *context bound* is a shorthand syntax for expressing the pattern of, “a context parameter that depends on a type parameter.”
39+
Given that background, a _context bound_ is a shorthand syntax for expressing the pattern of, “a context parameter that depends on a type parameter.”
4140

4241
Using a context bound, the `maximum` method can be written like this:
4342

_overviews/scala3-book/ca-type-classes.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ next-page: ca-multiversal-equality
88
---
99

1010

11-
A *type class* is an abstract, parameterized type that lets you add new behavior to any closed data type without using sub-typing.
11+
A _type class_ is an abstract, parameterized type that lets you add new behavior to any closed data type without using sub-typing.
1212
This is useful in multiple use-cases, for example:
1313

1414
- Expressing how a type you don’t own---from the standard library or a third-party library---conforms to such behavior
@@ -17,9 +17,6 @@ This is useful in multiple use-cases, for example:
1717
In Scala 3, type classes are just traits with one or more parameters whose implementations are provided by `given` instances.
1818

1919

20-
{% comment %}
21-
TODO: As background, discuss where the name "type class" comes from.
22-
{% endcomment %}
2320

2421
## Example
2522

_overviews/scala3-book/collections-classes.md

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ next-page: collections-methods
99

1010

1111
{% comment %}
12-
TODO: add a correct hierarchy image
1312
TODO: mention Array, ArrayDeque, ListBuffer, Queue, Stack, StringBuilder?
1413
LATER: note that methods like `+`, `++`, etc., are aliases for other methods
1514
LATER: add links to the Scaladoc for the major types shown here
@@ -29,19 +28,38 @@ When you need more flexibility, see these pages at the end of this section for m
2928

3029
Looking at Scala collections from a high level, there are three main categories to choose from:
3130

32-
- Sequences
33-
- Maps
34-
- Sets
31+
- **Sequences** are a linear collection of elements and may be _indexed_ (like an array) or _linear_ (like a linked list)
32+
- **Maps** contain a collection of key/value pairs, like a Java `Map`, Python dictionary, or Ruby `Hash`
33+
- **Sets** are an unordered sequence of unique elements
3534

36-
A _sequence_ is a linear collection of elements and may be _indexed_ (like an array) or _linear_ (like a linked list).
37-
A _map_ contains a collection of key/value pairs, like a Java `Map`, Python dictionary, or Ruby `Hash`.
38-
A _set_ is an unordered sequence of unique elements.
3935
All of those are basic types, and have subtypes for specific purposes, such as concurrency, caching, and streaming.
36+
In addition to those three main categories, there are other useful collection types, including ranges, stacks, and queues.
4037

41-
In addition to these three main categories, there are other useful collection types, including ranges, stacks, and queues.
42-
Ranges are demonstrated later in this section.
4338

44-
The following sections introduce the common types you’ll use on a regular basis.
39+
### Collections hierarchy
40+
41+
As a brief overview, the next three figures show the hierarchy of classes and traits in the Scala collections.
42+
43+
This first figure shows the collections types in package
44+
_scala.collection_.
45+
These are all high-level abstract classes or traits, which
46+
generally have _immutable_ and _mutable_ implementations.
47+
48+
![General collection hierarchy][collections1]
49+
50+
This figure shows all collections in package _scala.collection.immutable_:
51+
52+
![Immutable collection hierarchy][collections2]
53+
54+
And this figure shows all collections in package _scala.collection.mutable_:
55+
56+
![Mutable collection hierarchy][collections3]
57+
58+
Having seen that detailed view of all of the collections types, the following sections introduce some of the common types you’ll use on a regular basis.
59+
60+
{% comment %}
61+
NOTE: those images come from this page: https://docs.scala-lang.org/overviews/collections-2.13/overview.html
62+
{% endcomment %}
4563

4664

4765

@@ -617,3 +635,6 @@ When you need more information about specialized collections, see the following
617635

618636

619637
[strict]: {% link _overviews/core/architecture-of-scala-213-collections.md %}
638+
[collections1]: /resources/images/tour/collections-diagram-213.svg
639+
[collections2]: /resources/images/tour/collections-immutable-diagram-213.svg
640+
[collections3]: /resources/images/tour/collections-mutable-diagram-213.svg

_overviews/scala3-book/domain-modeling-oop.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ Protected members are also visible to subclasses of the class.
171171
In the following, we illustrate some advanced features of Scala and show how they can be used to structure larger software components.
172172
The examples are adapted from the paper ["Scalable Component Abstractions"][scalable] by Martin Odersky and Matthias Zenger.
173173
Don’t worry if you don’t understand all the details of the example; it’s primarily intended to demonstrate how to use several type features to construct larger components.
174-
{% comment %}
175-
TODO: I’m not sure what I added in that last sentence is accurate or helpful, but I wanted to add a note about why readers shouldn’t worry about understanding the example.
176-
{% endcomment %}
177174

178175
Our goal is to define a software component with a _family of types_ that can be refined later in implementations of the component.
179176
Concretely, the following code defines the component `SubjectObserver` as a trait with two abstract type members, `S` (for subjects) and `O` (for observers):

0 commit comments

Comments
 (0)