Skip to content

Commit 1b2bac1

Browse files
committed
Update intro
1 parent 9702227 commit 1b2bac1

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,7 @@ renderWebsite("/home")
150150
// again no argument
151151
```
152152

153+
A detailed guide to where Scala looks for canonical values can be found in [the FAQ]({% link _overviews/FAQ/index.md %}#where-does-scala-look-for-implicits).
154+
153155
[reference]: {{ site.scala3ref }}/overview.html
154156
[blog-post]: /2020/11/06/explicit-term-inference-in-scala-3.html

_overviews/scala3-book/ca-contextual-abstractions-intro.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ next-page: ca-extension-methods
1111

1212
## Background
1313

14-
Implicits in Scala 2 were a major distinguishing design feature.
15-
They are *the* fundamental way to abstract over context.
14+
Contextual abstractions are a way to abstract over context.
1615
They represent a unified paradigm with a great variety of use cases, among them:
1716

1817
- Implementing type classes
@@ -21,36 +20,36 @@ They represent a unified paradigm with a great variety of use cases, among them:
2120
- Expressing capabilities
2221
- Computing new types, and proving relationships between them
2322

24-
Since then, other languages have followed suit, e.g., Rust’s traits or Swift’s protocol extensions.
23+
Other languages have been influenced by Scala in this regard. E.g., Rust’s traits or Swift’s protocol extensions.
2524
Design proposals are also on the table for Kotlin as compile time dependency resolution, for C# as Shapes and Extensions or for F# as Traits.
26-
Implicits are also a common feature of theorem provers such as Coq or Agda.
25+
Contextual abstractions are also a common feature of theorem provers such as Coq or Agda.
2726

28-
Even though these designs use different terminology, they’re all variants of the core idea of *term inference*:
29-
Given a type, the compiler synthesizes a “canonical” term that has that type.
27+
Even though these designs use different terminology, they’re all variants of the core idea of **term inference**: given a type, the compiler synthesizes a “canonical” term that has that type.
3028

29+
## Scala 3 Redesign
3130

32-
## Redesign
31+
In Scala 2, contextual abstractions are supported by marking definitions (methods and values) or parameters as `implicit` (see [Context Parameters]({% link _overviews/scala3-book/ca-context-parameters.md %})).
3332

34-
Scala 3 includes a redesign of contextual abstractions in Scala.
33+
Scala 3 includes a redesign of contextual abstractions.
3534
While these concepts were gradually “discovered” in Scala 2, they’re now well known and understood, and the redesign takes advantage of that knowledge.
3635

3736
The design of Scala 3 focuses on **intent** rather than **mechanism**.
3837
Instead of offering one very powerful feature of implicits, Scala 3 offers several use-case oriented features:
3938

4039
- **Retroactively extending classes**.
41-
In Scala 2, extension methods had to be encoded using implicit conversions or implicit classes.
40+
In Scala 2, extension methods are encoded by using [implicit conversions][implicit-conversions] or [implicit classes]({% link _overviews/core/implicit-classes.md %}).
4241
In contrast, in Scala 3 [extension methods][extension-methods] are now directly built into the language, leading to better error messages and improved type inference.
4342

4443
- **Abstracting over contextual information**.
4544
[Using clauses][givens] allow programmers to abstract over information that is available in the calling context and should be passed implicitly.
4645
As an improvement over Scala 2 implicits, using clauses can be specified by type, freeing function signatures from term variable names that are never explicitly referred to.
4746

4847
- **Providing Type-class instances**.
49-
[Given instances][type-classes] allow programmers to define the _canonical value_ of a certain type.
50-
This makes programming with type-classes more straightforward without leaking implementation details.
48+
[Given instances][givens] allow programmers to define the _canonical value_ of a certain type.
49+
This makes programming with [type-classes][type-classes] more straightforward without leaking implementation details.
5150

5251
- **Viewing one type as another**.
53-
Implicit conversion have been [redesigned][implicit-conversions] from the ground up as instances of a type-class `Conversion`.
52+
Implicit conversions have been [redesigned][implicit-conversions] from the ground up as instances of a type-class `Conversion`.
5453

5554
- **Higher-order contextual abstractions**.
5655
The _all-new_ feature of [context functions][contextual-functions] makes contextual abstractions a first-class citizen.
@@ -85,4 +84,4 @@ This chapter introduces many of these new features in the following sections.
8584
[context-bounds]: {% link _overviews/scala3-book/ca-context-bounds.md %}
8685
[type-classes]: {% link _overviews/scala3-book/ca-type-classes.md %}
8786
[equality]: {% link _overviews/scala3-book/ca-multiversal-equality.md %}
88-
[contextual-functions]: {% link _overviews/scala3-book/types-dependent-function.md %}
87+
[contextual-functions]: {{ site.scala3ref }}/contextual/context-functions.html

_overviews/scala3-book/ca-summary.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@ next-page: concurrency
1010

1111
This chapter provides an introduction to most Contextual Abstractions topics, including:
1212

13-
- Given Instances and Using Clauses
14-
- Context Bounds
15-
- Given Imports
16-
- Extension Methods
17-
- Implementing Type Classes
18-
- Multiversal Equality
19-
- Implicit Conversions
13+
- [Extension Methods]({% link _overviews/scala3-book/ca-extension-methods.md %})
14+
- [Given Instances and Using Clauses]({% link _overviews/scala3-book/ca-context-parameters.md %})
15+
- [Context Bounds]({% link _overviews/scala3-book/ca-context-bounds.md %})
16+
- [Given Imports]({% link _overviews/scala3-book/ca-given-imports.md %})
17+
- [Type Classes]({% link _overviews/scala3-book/ca-type-classes.md %})
18+
- [Multiversal Equality]({% link _overviews/scala3-book/ca-multiversal-equality.md %})
19+
- [Implicit Conversions]({% link _overviews/scala3-book/ca-implicit-conversions.md %})
20+
21+
These features are all variants of the core idea of **term inference**: given a type, the compiler synthesizes a “canonical” term that has that type.
2022

2123
A few more advanced topics aren’t covered here, including:
2224

25+
- Conditional Given Instances
2326
- Type Class Derivation
2427
- Context Functions
2528
- By-Name Context Parameters

0 commit comments

Comments
 (0)