Skip to content

Commit 0dca4ce

Browse files
committed
Draft a blogpost for the Scala Days release
1 parent c540de0 commit 0dca4ce

File tree

1 file changed

+107
-31
lines changed

1 file changed

+107
-31
lines changed

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

Lines changed: 107 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
layout: blog-page
3-
title: Announcing Dotty 0.16.0-RC1 – the Scala Days 2019 release
3+
title: Announcing Dotty 0.16.0-RC1 – the Scala Days 2019 Release
44
author: Aggelos Biboudis
55
authorImg: /images/aggelos.png
66
date: 2019-06-11
77
---
88

9-
Hello again! Today, we are super excited to announce the 16th release of Dotty.
10-
The development of Dotty continues according to our schedule but today, Tuesday
11-
June the 11th, we are extra excited as it is the first day of [Scala Days 2019](https://scaladays.org/)
12-
which marks the 10th anniversary of Scala Days. With this release we bring
13-
improvements and a few new features getting closer to the envelop of the new
14-
features that Dotty plans to offer.
9+
Hello again! Today, we are excited to announce the 16th release of Dotty. The
10+
development of Dotty continues according to our schedule but today, Tuesday June
11+
the 11th, we are electrified as it is the first day of [Scala Days 2019](https://scaladays.org/)
12+
which marks the *10th* anniversary of Scala Days.
13+
With this release we are getting closer to the _envelop_ of the new features
14+
that Dotty plans to offer.
1515

1616
![]({{ site.baseurl }}/images/others/scala-days-logo.png "Scala Days 2019")
1717

@@ -41,22 +41,112 @@ This is our 16th scheduled release according to our
4141

4242
<!-- https://github.com/lampepfl/dotty/pulls?q=is%3Apr+closed%3A%3E2019-05-23+is%3Aclosed+sort%3Acomments-desc -->
4343

44+
## Syntax Change: Type Lambdas
45+
46+
We reconsider the syntax of type lambdas in an effort to provide an improved
47+
visual cue for two categories of types: types that relate to normal function
48+
types and types that operate on a higher level. The _fat_ arrow `=>` definitely
49+
relates to the first, while we reserve now `->` to mean _pure function_ in the
50+
future. As a result, we disengage `=>` from type lambdas, whice are now
51+
represented by `=>>`. As a result a function from types to types is written as
52+
`[X] =>> F[X]`.
53+
54+
For those who are interested in the discussions,
55+
[#6558](https://github.com/lampepfl/dotty/pull/6558) introduced the new syntax.
56+
57+
## Syntax Change: Wildcard Arguments in Types
58+
59+
The syntax of wildcard arguments in types has changed from `_` to `?`. Example:
60+
61+
```scala
62+
List[?]
63+
Map[? <: AnyRef, ? >: Null]
64+
```
65+
66+
Again, in an effort to fine-tune our syntax we put two features, from the world
67+
of terms and types, side-by-side and drew parallels at the syntactic level.
68+
Consequently, as `f(_)` is a shorthand for the lambda `x => f(x)` and as we plan
69+
ahead for making `C[_]` to be a shorthand for the type lambda `[X] =>> C[X]` in
70+
the future we pick `?` as a replacement syntax for wildcard types, since it
71+
aligns with Java's syntax.
72+
73+
For more information please read our documentation on
74+
[Wildcards](https://dotty.epfl.ch/docs/reference/changed-features/wildcards.html).
75+
4476
## Polymorphic function types
4577

46-
We add support for _polymorphic function types_. Nowadays if we want to write a
47-
universally quantified function over elements of lists of type `T` we write
48-
e.g., `List[T] => List[(T, T)]`.
78+
We add preliminary support for _polymorphic function types_. Nowadays, when we
79+
want to write a universally quantified function over elements of lists of type
80+
`T` we write e.g., `List[T] => List[(T, T)]` where `T` is bound at an enclosing
81+
definition. With polymorphic function types (PFT hereafter) we can quantify the
82+
parametric type locally. For example:
4983

5084
```scala
5185
[T <: AnyVal] => List[T] => List[(T, T)]
5286
```
5387

54-
## Other changes
55-
Some of the other notable changes include the following:
88+
As you notice, this gives us the ability to impose restrictions on the type
89+
variable `T` locally. Assume, you have an identity function with `type id = T => T`.
90+
By writing it as `type id = [T] => T => T` we abstract further the concept
91+
of a _polymorphic function_ and make it a *true* _family of functions_.
92+
93+
The code below (correctly) fails to type check because `T` needs to be bounded
94+
in the enclosing class:
95+
96+
```scala
97+
val id: T => T = t => t
98+
println(s"${id(1)} , ${id(7.0d)}")
99+
```
100+
101+
With PFTs we can now achieve what we want:
102+
103+
```scala
104+
val id = [T] => (t: T) => t
105+
println(s"${id(1)} , ${id(7.0d)}")
106+
```
107+
108+
For those who are interested in the discussions and more test cases,
109+
[#4672](https://github.com/lampepfl/dotty/pull/4672/) introduced PFTs.
110+
111+
## lazy vals are now thread-safe by default
112+
113+
Previously thread-safety was required using `@volatile` but that would not be
114+
consistent with Scala 2. The old behavior of non-volatile lazy vals can be
115+
recovered by using the newly-introduced `@threadUnsafe`.
116+
117+
For more information please read our documentation on the
118+
[threadUnsafe annotation](https://dotty.epfl.ch/docs/reference/other-new-features/threadUnsafe-annotation.html).
119+
120+
## Introducing `for` clauses for importing implied imports by type
121+
122+
Since implied instances can be anonymous it is not always practical to import
123+
them by their name, and wildcard imports are typically used instead. By-type
124+
imports provide a more specific alternative to wildcard imports, which makes it
125+
clearer what is imported. Example:
126+
127+
```scala
128+
import implied A.{for TC}
129+
```
130+
131+
This imports any implied instance in `A` that has a type which conforms tp `TC`.
132+
There can be several bounding types following a `for` and bounding types can
133+
contain wildcards.
134+
For instance, assuming the object
56135

57-
- Singletons are now allowed in union types. E.g. the following is allowed: `object foo; type X = Int | foo.type`.
58-
- A bunch of improvements was made for the type inference system – see, e.g., PRs [#6454](https://github.com/lampepfl/dotty/pull/6454) and [#6467](https://github.com/lampepfl/dotty/pull/6467).
59-
- Improvements to the Scala 2 code support which, in particular, improves Cats support – see PRs [#6494](https://github.com/lampepfl/dotty/pull/6494) and [#6498](https://github.com/lampepfl/dotty/pull/6498).
136+
```scala
137+
object Instances {
138+
implied intOrd for Ordering[Int]
139+
implied [T: Ordering] listOrd for Ordering[List[T]]
140+
implied ec for ExecutionContext = ...
141+
implied im for Monoid[Int]
142+
}
143+
```
144+
the import
145+
```
146+
import implied Instances.{for Ordering[_], ExecutionContext}
147+
```
148+
would import the `intOrd`, `listOrd`, and `ec` instances but leave out the `im`
149+
instance, since it fits none of the specified bounds.
60150

61151
# Let us know what you think!
62152

@@ -68,24 +158,10 @@ If you have questions or any sort of feedback, feel free to send us a message on
68158

69159
Thank you to all the contributors who made this release possible!
70160

71-
According to `git shortlog -sn --no-merges 0.14.0-RC1..0.15.0-RC1` these are:
161+
According to `git shortlog -sn --no-merges 0.15.0-RC1..0.16.0-RC1` these are:
72162

73163
```
74-
191 Martin Odersky
75-
112 Nicolas Stucki
76-
29 Guillaume Martres
77-
25 Olivier Blanvillain
78-
21 Aleksander Boruch-Gruszecki
79-
17 Anatolii Kmetiuk
80-
10 Miles Sabin
81-
9 Liu Fengyun
82-
8 Aggelos Biboudis
83-
8 Jentsch
84-
5 Sébastien Doeraene
85-
2 Anatolii
86-
1 Fengyun Liu
87-
1 Olivier ROLAND
88-
1 phderome
164+
89165
```
90166

91167
If you want to get your hands dirty and contribute to Dotty, now is a good time to get involved!

0 commit comments

Comments
 (0)