Skip to content

Release Dotty 0.13.0-RC1 #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ You will need to make the following adjustments to your build:

### project/plugins.sbt
```scala
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.6")
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.3.0")
```

### project/build.properties
```scala
sbt.version=1.2.3
sbt.version=1.2.7
```

Older versions of sbt are not supported.
Expand All @@ -43,13 +43,13 @@ Any version number that starts with `0.` is automatically recognized as Dotty by
the `sbt-dotty` plugin, you don't need to set up anything:

```scala
scalaVersion := "0.12.0-RC1"
scalaVersion := "0.13.0-RC1"
```

#### Nightly builds
If the latest release of Dotty is missing a bugfix or feature you need, you may
wish to use a nightly build. Look at the bottom of
https://repo1.maven.org/maven2/ch/epfl/lamp/dotty_0.13/ to find the version
https://repo1.maven.org/maven2/ch/epfl/lamp/dotty_0.14/ to find the version
number for the latest nightly build. Alternatively, you can set `scalaVersion :=
dottyLatestNightlyBuild.get` to always use the latest nightly build of dotty.

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ lazy val root = project
description := "Example sbt project that compiles using Dotty",
version := "0.1.0",

scalaVersion := "0.12.0-RC1"
scalaVersion := "0.13.0-RC1"
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.3
sbt.version=1.2.7
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.6")
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.3.0")
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@ import scala.concurrent.{ExecutionContext, Future}
import scala.util.Try

/**
* Implicit Function Types:
* - http://dotty.epfl.ch/docs/reference/implicit-function-types.html,
* Context Queries:
* - http://dotty.epfl.ch/docs/reference/contextual/query-types.html,
* - https://www.scala-lang.org/blog/2016/12/07/implicit-function-types.html
*/
object ImplicitFunctions {
object ContextQueries /* Formerly known as Implicit Function Types */ {

object context {
// type alias Contextual
type Contextual[T] = implicit ExecutionContext => T
type Contextual[T] = given ExecutionContext => T

// sum is expanded to sum(x, y)(ctx)
def asyncSum(x: Int, y: Int): Contextual[Future[Int]] = Future(x + y)

def asyncMult(x: Int, y: Int) = { implicit ctx: ExecutionContext =>
Future(x * y)
}
def asyncMult(x: Int, y: Int) given (ctx: ExecutionContext) = Future(x * y)
}

object parse {

type Parseable[T] = implicit ImplicitParams.StringParser[T] => Try[T]
type Parseable[T] = given ImplicitParams.StringParser[T] => Try[T]

def sumStrings(x: String, y: String): Parseable[Int] = {
val parser = implicitly[ImplicitParams.StringParser[Int]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import scala.language.implicitConversions

/**
* Implicit Conversions: http://dotty.epfl.ch/docs/reference/changed-features/implicit-conversions.html
* Conversions: http://dotty.epfl.ch/docs/reference/contextual/conversions.html
*/
object ImplicitConversion {
object Conversion {

case class IntWrapper(a: Int) extends AnyVal
case class DoubleWrapper(b: Double) extends AnyVal

def convert[T, U](x: T)(implicit converter: ImplicitConverter[T, U]): U = converter(x)
def convert[T, U](x: T) given (converter: Conversion[T, U]): U = converter(x)

implicit val IntWrapperToDoubleWrapper: ImplicitConverter[IntWrapper, DoubleWrapper] = new ImplicitConverter[IntWrapper, DoubleWrapper] {
implied IntWrapperToDoubleWrapper for Conversion[IntWrapper, DoubleWrapper] = new Conversion[IntWrapper, DoubleWrapper] {
override def apply(i: IntWrapper): DoubleWrapper = new DoubleWrapper(i.a.toDouble)
}

def useConversion(implicit f: ImplicitConverter[IntWrapper, DoubleWrapper]) = {
def useConversion given (f: Conversion[IntWrapper, DoubleWrapper]) = {
val y: IntWrapper = new IntWrapper(4)
val x: DoubleWrapper = y
x
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ object Main {

runExample("Enum Types")(EnumTypes.test)

runExample("Implicit Functions")(ImplicitFunctions.test)
runExample("Context Queries")(ContextQueries.test)

runExample("Implicit Params")(ImplicitParams.test)

runExample("Implicit Conversion")(ImplicitConversion.test)
runExample("Conversion")(Conversion.test)

runExample("Union Types")(UnionTypes.test)

Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/MultiversalEquality.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import scala.language.strictEquality

/**
* Multiversal Equality: http://dotty.epfl.ch/docs/reference/multiversal-equality.html
* scala.Eq definition: https://github.com/lampepfl/dotty/blob/master/library/src/scala/Eq.scala
* Multiversal Equality: https://dotty.epfl.ch/docs/reference/contextual/multiversal-equality.html
* scala.Eq definition: https://github.com/lampepfl/dotty/blob/master/library/src/scala/Eql.scala
*/
object MultiversalEquality {

def test: Unit = {

// Values of types Int and String cannot be compared with == or !=,
// unless we add a custom implicit like:
implicit def eqIntString: Eq[Int, String] = Eq
implicit def eqIntString: Eql[Int, String] = Eql.derived
println(3 == "3")

// By default, all numbers are comparable, because of;
Expand All @@ -29,8 +29,8 @@ object MultiversalEquality {

// scala.language.strictEquality is enabled, therefore we need some extra implicits
// to compare instances of A and B.
implicit def eqAB: Eq[A, B] = Eq
implicit def eqBA: Eq[B, A] = Eq
implicit def eqAB: Eql[A, B] = Eql.derived
implicit def eqBA: Eql[B, A] = Eql.derived

println(a != b)
println(b == a)
Expand Down