You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2020-10-21-explicit-term-inference-in-scala-3.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -8,17 +8,17 @@ title: Explicit term inference with Scala 3
8
8
# Explicit term inference with Scala 3
9
9
10
10
One of the most striking changes for developers adopting Scala 3 is the introduction
11
-
of new syntaxes to replace the implicit mechanism used in previous Scala versions.
11
+
of a new syntax to replace the implicit mechanism used in previous Scala versions.
12
12
13
13
The motivation behind the new syntax is that the same `implicit` keyword was
14
14
used for different purposes and patterns and thus it became a way to express *how* to implement
15
15
patterns. This means that when encountering this ambiguous incantation, users need to decipher what
16
-
the intent of the developer was: is this a conversion? Does this avoid parameter repetition?
17
-
Is this an extension of a type? Is this a typeclass? How do I import this?
16
+
the intent of the developer was: is this a conversion? Does this avoid parameter repetition?
17
+
Is this an extension of a type? Is this a typeclass? How do I import this?
18
18
19
19
Seeing how pervasive implicits became in libraries and projects, Scala 3 aims at reducing confusion and cognitive load by using new keywords that convey the intent of the developer.
20
20
21
-
This post briefly introduces the new syntaxes and semantics available to Scala 3 programmers by analysing the
21
+
This post briefly introduces the new syntax and semantics available to Scala 3 programmers by analysing the
22
22
most common use cases and patterns: extension methods, implicit parameters, implicit conversions and typeclasses.
23
23
24
24
## Compatibility disclaimer
@@ -103,7 +103,7 @@ add a couple of methods to `List[Try[A]]`.
103
103
### Find out more
104
104
105
105
You can find more information about extension methods on [the dedicated documentation page](http://dotty.epfl.ch/docs/reference/contextual/extension-methods.html).
106
-
I also suggest that you read how they complement another new Scala 3 feature: [opaque types](https://dotty.epfl.ch/docs/reference/other-new-features/opaques.html).
106
+
We also suggest that you read how they complement another new Scala 3 feature: [opaque types](https://dotty.epfl.ch/docs/reference/other-new-features/opaques.html).
107
107
Later in this post we will see how they simplify a very common pattern: typeclasses.
108
108
109
109
## Avoiding repetition with contextual parameters
@@ -196,7 +196,7 @@ import Context.given
196
196
```
197
197
Or by making the type that you are bringing in scope explicit:
198
198
```
199
-
Import Context.{given ExecutionContext}
199
+
import Context.{given ExecutionContext}
200
200
```
201
201
This allows you to have more control over imports without relying on instance names.
202
202
@@ -349,7 +349,7 @@ import Show.{_, given}
349
349
caseclassMountain(name: String, height: Int)
350
350
351
351
givenShow[Mountain] =
352
-
Show.from((m: Mountain) =>s"The ${m.name} is ${m.height} meters high")
352
+
Show.from((m: Mountain) =>s"${m.name} is ${m.height} meters high")
0 commit comments