Skip to content

Commit 3c28893

Browse files
authored
Merge pull request #9059 from asakaev/type-class
Make the spelling of "type class" consistent
2 parents 5e9d927 + 6db3a6c commit 3c28893

32 files changed

+92
-92
lines changed

compiler/src/dotty/tools/dotc/typer/Deriving.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import transform.TypeUtils._
1818
import transform.SymUtils._
1919
import ErrorReporting.errorTree
2020

21-
/** A typer mixin that implements typeclass derivation functionality */
21+
/** A typer mixin that implements type class derivation functionality */
2222
trait Deriving {
2323
this: Typer =>
2424

@@ -49,7 +49,7 @@ trait Deriving {
4949
private def addDerivedInstance(clsName: Name, info: Type, pos: SourcePosition): Unit = {
5050
val instanceName = s"derived$$$clsName".toTermName
5151
if (ctx.denotNamed(instanceName).exists)
52-
ctx.error(i"duplicate typeclass derivation for $clsName", pos)
52+
ctx.error(i"duplicate type class derivation for $clsName", pos)
5353
else
5454
// If we set the Synthetic flag here widenGiven will widen too far and the
5555
// derived instance will have too low a priority to be selected over a freshly
@@ -71,7 +71,7 @@ trait Deriving {
7171
*
7272
* See detailed descriptions in deriveSingleParameter and deriveEql below.
7373
*
74-
* If it passes the checks, enter a typeclass instance for it in the current scope.
74+
* If it passes the checks, enter a type class instance for it in the current scope.
7575
*
7676
* See test run/typeclass-derivation2, run/poly-kinded-derives and pos/derive-eq
7777
* for examples that spell out what would be generated.
@@ -210,12 +210,12 @@ trait Deriving {
210210

211211
// Procedure:
212212
// We construct a two column matrix of the deriving class type parameters
213-
// and the Eql typeclass parameters.
213+
// and the Eql type class parameters.
214214
//
215215
// Rows: parameters of the deriving class
216-
// Columns: parameters of the Eql typeclass (L/R)
216+
// Columns: parameters of the Eql type class (L/R)
217217
//
218-
// Running example: typeclass: class Eql[L, R], deriving class: class A[T, U, V]
218+
// Running example: type class: class Eql[L, R], deriving class: class A[T, U, V]
219219
// clsParamss =
220220
// T_L T_R
221221
// U_L U_R

docs/blog/_posts/2019-03-05-13th-dotty-milestone-release.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ communicated more clearly syntactically. Furthermore, the `implicit` keyword is
107107
ascribed too many overloaded meanings in the language (implicit vals, defs,
108108
objects, parameters). For instance, a newcomer can easily confuse the two
109109
examples above, although they demonstrate completely different things, a
110-
typeclass instance is an implicit object or val if unconditional and an implicit
110+
type class instance is an implicit object or val if unconditional and an implicit
111111
def with implicit parameters if conditional; arguably all of them are
112112
surprisingly similar (syntactically). Another consideration is that the
113113
`implicit` keyword annotates a whole parameter section instead of a single
@@ -231,8 +231,8 @@ PR chain that originated from
231231
implicits are summarized in
232232
[#5825](https://github.com/lampepfl/dotty/pull/5825).
233233

234-
This release offers the support for _typeclass derivation_ as a language
235-
feature. Typeclass derivation is a way to generate instances of certain type
234+
This release offers the support for _type class derivation_ as a language
235+
feature. Type class derivation is a way to generate instances of certain type
236236
classes automatically or with minimal code hints, and is now supported natively
237237
with *dedicated language support*. A type class in this sense is any trait or
238238
class with a type parameter that describes the type being operated on. Commonly
@@ -267,7 +267,7 @@ which replaces:
267267
A extends B with C { ... }
268268
```
269269

270-
With typeclass derivation we can also derive types. A trait or class can appear
270+
With type class derivation we can also derive types. A trait or class can appear
271271
in a derives clause if its companion object defines a method named `derived`.
272272
The type and implementation of a `derived` method are arbitrary, but typically
273273
it has a definition like this:
@@ -276,7 +276,7 @@ it has a definition like this:
276276
def derived[T] given Generic[T] = ...
277277
```
278278

279-
**You can read more about** [Typeclass
279+
**You can read more about** [Type class
280280
Derivation](https://dotty.epfl.ch/docs/reference/contextual/derivation.html) or
281281
have a deep dive at the relevant PRs:
282282
[#5540](https://github.com/lampepfl/dotty/pull/5540) and
@@ -291,7 +291,7 @@ provide a derived implicit instance:
291291
implied for Eql[Int, String] = Eql.derived
292292
```
293293

294-
**You can read more about** how we based multiversal equality on typeclass derivation through
294+
**You can read more about** how we based multiversal equality on type class derivation through
295295
the relevant PR [#5843](https://github.com/lampepfl/dotty/pull/5843).
296296

297297
_Implicit conversions_ are now defined by implied instances of the

docs/blog/_posts/2019-06-11-16th-dotty-milestone-release.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,14 @@ import delegate Delegates.{for Ordering[_], ExecutionContext}
194194
would import the `intOrd`, `listOrd`, and `ec` instances but leave out the `im`
195195
instance, since it fits none of the specified bounds.
196196

197-
## New typeclass derivation scheme
197+
## New type class derivation scheme
198198

199199
Summary of measured differences with the old scheme:
200200

201201
- About 100 lines more compiler code - the rest of the lines changed diff is
202202
tests.
203-
- About 13-15% more code generated for typeclass instances
204-
- About 3-4% slower to compile typeclass instances
203+
- About 13-15% more code generated for type class instances
204+
- About 3-4% slower to compile type class instances
205205

206206
Advantages of new scheme:
207207

docs/blog/_posts/2020-02-05-22nd-dotty-milestone-release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ This syntax is a completely separate one from the `given` syntax and hence is ai
5858
For the discussion, see [PR #7917](https://github.com/lampepfl/dotty/pull/7917). For more information on how to use extension methods in general and collective extension methods in particular, see the [documentation](https://dotty.epfl.ch/docs/reference/contextual/extension-methods.html).
5959

6060
# Kind projector syntax support
61-
[Kind projector](https://github.com/typelevel/kind-projector) is a popular compiler plugin for Scala 2. It is especially useful in the context of purely functional programming and typeclass derivation – everywhere where you need to work extensively with types.
61+
[Kind projector](https://github.com/typelevel/kind-projector) is a popular compiler plugin for Scala 2. It is especially useful in the context of purely functional programming and type class derivation – everywhere where you need to work extensively with types.
6262

6363
As of this release, a subset of the kind projector syntax is now supported in Dotty. Credits for this contribution go to [Travis Brown](https://github.com/travisbrown).
6464

docs/docs/reference/changed-features/main-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This would generate a main program `happyBirthday` that could be called like thi
3030
Happy 23rd Birthday, Lisa and Peter!
3131
```
3232
A `@main` annotated method can be written either at the top-level or in a statically accessible object. The name of the program is in each case the name of the method, without any object prefixes. The `@main` method can have an arbitrary number of parameters.
33-
For each parameter type there must be an instance of the `scala.util.FromString` typeclass
33+
For each parameter type there must be an instance of the `scala.util.FromString` type class
3434
that is used to convert an argument string to the required parameter type.
3535
The parameter list of a main method can end in a repeated parameter that then
3636
takes all remaining arguments given on the command line.

docs/docs/reference/changed-features/numeric-literals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ gives a type error, since without an expected type `-10_000_000_000` is treated
5555
### The FromDigits Trait
5656

5757
To allow numeric literals, a type simply has to define a `given` instance of the
58-
`scala.util.FromDigits` typeclass, or one of its subclasses. `FromDigits` is defined
58+
`scala.util.FromDigits` type class, or one of its subclasses. `FromDigits` is defined
5959
as follows:
6060
```scala
6161
trait FromDigits[T] {

docs/docs/reference/contextual/motivation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Scala's implicits are its most distinguished feature. They are _the_ fundamental
1010
Following Haskell, Scala was the second popular language to have some form of implicits. Other languages have followed suit. E.g Rust's traits or Swift's protocol extensions. Design proposals are also on the table for Kotlin as [compile time dependency resolution](https://github.com/Kotlin/KEEP/blob/e863b25f8b3f2e9b9aaac361c6ee52be31453ee0/proposals/compile-time-dependency-resolution.md), for C# as [Shapes and Extensions](https://github.com/dotnet/csharplang/issues/164)
1111
or for F# as [Traits](https://github.com/MattWindsor91/visualfsharp/blob/hackathon-vs/examples/fsconcepts.md). Implicits are also a common feature of theorem provers such as Coq or Agda.
1212

13-
Even though these designs use widely different terminology, they are all variants of the core idea of _term inference_. Given a type, the compiler synthesizes a "canonical" term that has that type. Scala embodies the idea in a purer form than most other languages: An implicit parameter directly leads to an inferred argument term that could also be written down explicitly. By contrast, typeclass based designs are less direct since they hide term inference behind some form of type classification and do not offer the option of writing the inferred quantities (typically, dictionaries) explicitly.
13+
Even though these designs use widely different terminology, they are all variants of the core idea of _term inference_. Given a type, the compiler synthesizes a "canonical" term that has that type. Scala embodies the idea in a purer form than most other languages: An implicit parameter directly leads to an inferred argument term that could also be written down explicitly. By contrast, type class based designs are less direct since they hide term inference behind some form of type classification and do not offer the option of writing the inferred quantities (typically, dictionaries) explicitly.
1414

1515
Given that term inference is where the industry is heading, and given that Scala has it in a very pure form, how come implicits are not more popular? In fact, it's fair to say that implicits are at the same time Scala's most distinguished and most controversial feature. I believe this is due to a number of aspects that together make implicits harder to learn than necessary and also make it harder to prevent abuses.
1616

@@ -27,7 +27,7 @@ Particular criticisms are:
2727

2828
2. Another widespread abuse is over-reliance on implicit imports. This often leads to inscrutable type errors that go away with the right import incantation, leaving a feeling of frustration. Conversely, it is hard to see what implicits a program uses since implicits can hide anywhere in a long list of imports.
2929

30-
3. The syntax of implicit definitions is too minimal. It consists of a single modifier, `implicit`, that can be attached to a large number of language constructs. A problem with this for newcomers is that it conveys mechanism instead of intent. For instance, a typeclass instance is an implicit object or val if unconditional and an implicit def with implicit parameters referring to some class if conditional. This describes precisely what the implicit definitions translate to -- just drop the `implicit` modifier, and that's it! But the cues that define intent are rather indirect and can be easily misread, as demonstrated by the definitions of `i1` and `i2` above.
30+
3. The syntax of implicit definitions is too minimal. It consists of a single modifier, `implicit`, that can be attached to a large number of language constructs. A problem with this for newcomers is that it conveys mechanism instead of intent. For instance, a type class instance is an implicit object or val if unconditional and an implicit def with implicit parameters referring to some class if conditional. This describes precisely what the implicit definitions translate to -- just drop the `implicit` modifier, and that's it! But the cues that define intent are rather indirect and can be easily misread, as demonstrated by the definitions of `i1` and `i2` above.
3131

3232
4. The syntax of implicit parameters also has shortcomings. While implicit _parameters_ are designated specifically, arguments are not. Passing an argument to an implicit parameter looks like a regular application `f(arg)`. This is problematic because it means there can be confusion regarding what parameter gets instantiated in a call. For instance, in
3333
```scala
@@ -59,10 +59,10 @@ The following pages introduce a redesign of contextual abstractions in Scala. Th
5959
This section also contains pages describing other language features that are related to context abstraction. These are:
6060

6161
- [Context Bounds](./context-bounds.md), which carry over unchanged.
62-
- [Extension Methods](./extension-methods.md) replace implicit classes in a way that integrates better with typeclasses.
63-
- [Implementing Typeclasses](./typeclasses.md) demonstrates how some common typeclasses can be implemented using the new constructs.
64-
- [Typeclass Derivation](./derivation.md) introduces constructs to automatically derive typeclass instances for ADTs.
65-
- [Multiversal Equality](./multiversal-equality.md) introduces a special typeclass to support type safe equality.
62+
- [Extension Methods](./extension-methods.md) replace implicit classes in a way that integrates better with type classes.
63+
- [Implementing Type classes](type-classes.md) demonstrates how some common type classes can be implemented using the new constructs.
64+
- [Type class Derivation](./derivation.md) introduces constructs to automatically derive type class instances for ADTs.
65+
- [Multiversal Equality](./multiversal-equality.md) introduces a special type class to support type safe equality.
6666
- [Context Functions](./context-functions.md) provide a way to abstract over context parameters.
6767
- [By-Name Context Parameters](./by-name-context-parameters.md) are an essential tool to define recursive synthesized values without looping.
6868
- [Relationship with Scala 2 Implicits](./relationship-implicits.md) discusses the relationship between old-style implicits and new-style givens and how to migrate from one to the other.

docs/docs/reference/contextual/multiversal-equality.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ the program will still typecheck, since values of all types can be compared with
2424
But it will probably give unexpected results and fail at runtime.
2525

2626
Multiversal equality is an opt-in way to make universal equality
27-
safer. It uses a binary typeclass `Eql` to indicate that values of
27+
safer. It uses a binary type class `Eql` to indicate that values of
2828
two given types can be compared with each other.
2929
The example above would not typecheck if `S` or `T` was a class
3030
that derives `Eql`, e.g.
@@ -94,7 +94,7 @@ Instead of defining `Eql` instances directly, it is often more convenient to der
9494
```scala
9595
class Box[T](x: T) derives Eql
9696
```
97-
By the usual rules of [typeclass derivation](./derivation.md),
97+
By the usual rules of [type class derivation](./derivation.md),
9898
this generates the following `Eql` instance in the companion object of `Box`:
9999
```scala
100100
given [T, U](using Eql[T, U]) as Eql[Box[T], Box[U]] = Eql.derived

docs/docs/reference/contextual/relationship-implicits.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ implicit class CircleDecorator(c: Circle) extends AnyVal {
121121
```
122122
Abstract extension methods in traits that are implemented in given instances have no direct counterpart in Scala-2. The only way to simulate these is to make implicit classes available through imports. The Simulacrum macro library can automate this process in some cases.
123123

124-
### Typeclass Derivation
124+
### Type class Derivation
125125

126-
Typeclass derivation has no direct counterpart in the Scala 2 language. Comparable functionality can be achieved by macro-based libraries such as Shapeless, Magnolia, or scalaz-deriving.
126+
Type class derivation has no direct counterpart in the Scala 2 language. Comparable functionality can be achieved by macro-based libraries such as Shapeless, Magnolia, or scalaz-deriving.
127127

128128
### Implicit Function Types
129129

0 commit comments

Comments
 (0)