Skip to content

Commit cf9db16

Browse files
committed
Polishing
1 parent 6006650 commit cf9db16

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

docs/blog/_posts/2018-03-05-seventh-dotty-milestone-release.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,14 @@ sealed trait Exp[T]
126126
case class IntLit(n: Int) extends Exp[Int]
127127

128128
case class GenLit[T](t: T) extends Exp[T]
129-
case class Plus(e1: Exp[Int], e2: Exp[Int]) extends Exp[Int]
130129
case class Fun[S, T](f: Exp[S] => Exp[T]) extends Exp[S => T]
131130
case class App[T, U](f: Exp[T => U], e: Exp[T]) extends Exp[U]
132131
```
133132

134-
where different constructors, such as `IntLit` and `Fun`, pass different type argument to the super trait. Hence, typechecking a pattern match on `v: Exp[T]` requires special care: for instance, if `v = IntLit(5)` then the typechecker must realize that `T` must be `Int`. This enables writing a typed interpreter `eval[T](e: Exp[T]): T`, where say the `IntLit` branch can return an `Int`:
133+
where different constructors, such as `IntLit` and `Fun`, pass different type argument to the super
134+
trait. Hence, typechecking a pattern match on `v: Exp[T]` requires special care. For instance, if
135+
`v = IntLit(5)` then the typechecker must realize that `T` must be `Int`. This enables writing a
136+
typed interpreter `eval[T](e: Exp[T]): T`, where say the `IntLit` branch can return an `Int`:
135137

136138
```scala
137139
object Interpreter {
@@ -140,17 +142,12 @@ object Interpreter {
140142
n
141143

142144
case gl: GenLit[_] => // Here in fact gl: GenLit[T]
143-
144-
// the next line was incorrectly allowed before the fix to https://github.com/lampepfl/dotty/issues/1754:
145-
//val gl1: GenLit[Nothing] = gl
145+
// the next line was incorrectly allowed before the fix to https://github.com/lampepfl/dotty/issues/1754
146+
// val gl1: GenLit[Nothing] = gl
146147

147148
gl.t
148149

149-
case Plus(e1, e2) =>
150-
// Here T = Int and e1, e2: Exp[Int]
151-
eval(e1) + eval(e2)
152-
153-
// The next cases triggered warnings before the fix to
150+
// The next cases triggered spurious warnings before the fix to
154151
// https://github.com/lampepfl/dotty/issues/3666
155152

156153
case f: Fun[s, t] => // Here T = s => t
@@ -163,13 +160,13 @@ object Interpreter {
163160
```
164161

165162
Earlier Scalac and Dotty releases had issues typechecking such interpreters.
166-
We have fixed multiple bugs about GADT type checking and exhaustiveness checking, especially for invariant GADTs, including
163+
We fixed multiple bugs about GADT type checking and exhaustiveness checking, including
167164
[#3666](https://github.com/lampepfl/dotty/issues/3666),
168165
[#1754](https://github.com/lampepfl/dotty/issues/1754),
169166
[#3645](https://github.com/lampepfl/dotty/issues/3645),
170-
and improved handling of matches using repeated type variables
171167
[#4030](https://github.com/lampepfl/dotty/issues/4030).
172-
We have also made error messages more informative [#3990](https://github.com/lampepfl/dotty/pull/3990).
168+
Error messages are now more informative [#3990](https://github.com/lampepfl/dotty/pull/3990).
169+
173170
Fixes to covariant GADTs ([#3989](https://github.com/lampepfl/dotty/issues/3989)/
174171
[#4013](https://github.com/lampepfl/dotty/pull/4013)) have been deferred to next release.
175172

0 commit comments

Comments
 (0)