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: docs/blog/_posts/2020-02-05-22nd-dotty-milestone-release.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ This syntax is a completely separate one from the `given` syntax and hence is ai
58
58
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).
59
59
60
60
# 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.
62
62
63
63
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).
Copy file name to clipboardExpand all lines: docs/docs/reference/changed-features/main-functions.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ This would generate a main program `happyBirthday` that could be called like thi
30
30
Happy 23rd Birthday, Lisa and Peter!
31
31
```
32
32
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
34
34
that is used to convert an argument string to the required parameter type.
35
35
The parameter list of a main method can end in a repeated parameter that then
36
36
takes all remaining arguments given on the command line.
Copy file name to clipboardExpand all lines: docs/docs/reference/contextual/motivation.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Scala's implicits are its most distinguished feature. They are _the_ fundamental
10
10
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)
11
11
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.
12
12
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.
14
14
15
15
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.
16
16
@@ -27,7 +27,7 @@ Particular criticisms are:
27
27
28
28
2. Another widespread abuse is over-reliance on implicit imports. This often leads to inscrutable typeerrors that go away with the right importincantation, leavingafeelingoffrustration. Conversely, itishardtoseewhatimplicitsaprogramusessinceimplicitscanhideanywhereinalonglistofimports.
29
29
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 withthisfor newcomers is that it conveys mechanism instead of intent. For instance, a typeclass instance is an implicitobjectorvalif unconditional and an implicitdefwithimplicit parameters referring to some classif 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, asdemonstrated 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 withthisfor newcomers is that it conveys mechanism instead of intent. For instance, a typeclass instance is an implicitobjectorvalif unconditional and an implicitdefwithimplicit parameters referring to some classif 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, asdemonstrated by the definitions of `i1` and `i2` above.
31
31
32
32
4. The syntax of implicit parameters also has shortcomings. Whileimplicit _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
33
33
```scala
@@ -59,10 +59,10 @@ The following pages introduce a redesign of contextual abstractions in Scala. Th
59
59
This section also contains pages describing other language features that are related to context abstraction. Theseare:
60
60
61
61
- [ContextBounds](./context-bounds.md), which carry over unchanged.
62
-
- [ExtensionMethods](./extension-methods.md) replace implicit classes in a way that integrates better withtypeclasses.
63
-
- [ImplementingTypeclasses](./typeclasses.md) demonstrates how some common typeclasses can be implemented using the new constructs.
64
-
- [TypeclassDerivation](./derivation.md) introduces constructs to automatically derive typeclass instances forADTs.
65
-
- [MultiversalEquality](./multiversal-equality.md) introduces a special typeclass to support typesafe equality.
62
+
- [ExtensionMethods](./extension-methods.md) replace implicit classes in a way that integrates better withtypeclasses.
63
+
- [ImplementingType classes](type-classes.md) demonstrates how some common typeclasses can be implemented using the new constructs.
64
+
- [TypeclassDerivation](./derivation.md) introduces constructs to automatically derive typeclass instances forADTs.
65
+
- [MultiversalEquality](./multiversal-equality.md) introduces a special typeclass to support typesafe equality.
66
66
- [ContextFunctions](./context-functions.md) provide a way to abstract over context parameters.
67
67
- [By-NameContextParameters](./by-name-context-parameters.md) are an essential tool to define recursive synthesized values without looping.
68
68
- [RelationshipwithScala2Implicits](./relationship-implicits.md) discusses the relationship between old-style implicits and new-style givens and how to migrate from one to the other.
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.
123
123
124
-
### Typeclass Derivation
124
+
### Type class Derivation
125
125
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.
0 commit comments