Skip to content

Release Dotty 0.13.0-RC1 for mill #26

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 15 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ Any version number that starts with `0.` is automatically recognized as Dotty,
you don't need to set up anything:

```scala
def scalaVersion = "0.12.0-RC1"
def 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.

## Getting your project to compile with Dotty
Expand Down
2 changes: 1 addition & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import mill._, scalalib._

object root extends SbtModule {
def millSourcePath = ammonite.ops.pwd
def scalaVersion = "0.12.0-RC1"
def scalaVersion = "0.13.0-RC1"
def publishVersion = "0.1.0"
}
4 changes: 2 additions & 2 deletions src/main/scala/AutoParamTupling.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

/**
* Automatic Tupling of Function Params: http://dotty.epfl.ch/docs/reference/auto-parameter-tupling.html
* Automatic Tupling of Function Params: https://dotty.epfl.ch/docs/reference/other-new-features/auto-parameter-tupling.html
*/
object AutoParamTupling {

def test: Unit = {

/**
* In order to get thread safety, you need to put @volatile before lazy vals.
* http://dotty.epfl.ch/docs/reference/changed/lazy-vals.html
* https://dotty.epfl.ch/docs/reference/changed-features/lazy-vals.html
*/
@volatile lazy val xs: List[String] = List("d", "o", "t", "t", "y")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,28 @@ 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 ImpliedInstances.StringParser[T] => Try[T]

def sumStrings(x: String, y: String): Parseable[Int] = {
val parser = implicitly[ImplicitParams.StringParser[Int]]
val parser = implicitly[ImpliedInstances.StringParser[Int]]
val tryA = parser.parse(x)
val tryB = parser.parse(y)

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/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
2 changes: 1 addition & 1 deletion src/main/scala/EnumTypes.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Enum Types: http://dotty.epfl.ch/docs/reference/adts.html
* Enum Types: http://dotty.epfl.ch/docs/reference/enums/adts.html
*/
object EnumTypes {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import scala.util.{Success, Try}

/**
* Implicit By-Name Parameters:
* - http://dotty.epfl.ch/docs/reference/implicit-by-name-parameters.html
* Implied Instances:
* - https://dotty.epfl.ch/docs/reference/contextual/instance-defs.html
*/
object ImplicitParams {
object ImpliedInstances {

sealed trait StringParser[A] {
def parse(s: String): Try[A]
}

object StringParser {

def apply[A](implicit parser: StringParser[A]): StringParser[A] = parser
def apply[A] given (parser: StringParser[A]): StringParser[A] = parser

private def baseParser[A](f: String ⇒ Try[A]): StringParser[A] = new StringParser[A] {
override def parse(s: String): Try[A] = f(s)
}

implicit val stringParser: StringParser[String] = baseParser(Success(_))
implicit val intParser: StringParser[Int] = baseParser(s ⇒ Try(s.toInt))
implied stringParser for StringParser[String] = baseParser(Success(_))
implied intParser for StringParser[Int] = baseParser(s ⇒ Try(s.toInt))

implicit def optionParser[A](implicit parser: => StringParser[A]): StringParser[Option[A]] = new StringParser[Option[A]] {
implied optionParser[A] given (parser: => StringParser[A]) for StringParser[Option[A]] = new StringParser[Option[A]] {
override def parse(s: String): Try[Option[A]] = s match {
case "" ⇒ Success(None) // implicit parser not used.
case str ⇒ parser.parse(str).map(x ⇒ Some(x)) // implicit parser is evaluated at here
Expand All @@ -34,6 +34,6 @@ object ImplicitParams {
println(implicitly[StringParser[Option[Int]]].parse(""))
println(implicitly[StringParser[Option[Int]]].parse("21a"))

println(implicitly[StringParser[Option[Int]]](StringParser.optionParser[Int](StringParser.intParser)).parse("42"))
println(implicitly[StringParser[Option[Int]]](StringParser.optionParser[Int]).parse("42"))
}
}
2 changes: 1 addition & 1 deletion src/main/scala/IntersectionTypes.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Intersection Types: http://dotty.epfl.ch/docs/reference/intersection-types.html
* Intersection Types: https://dotty.epfl.ch/docs/reference/new-types/intersection-types.html
*/
object IntersectionTypes {

Expand Down
6 changes: 3 additions & 3 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("Implied Instances")(ImpliedInstances.test)

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

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

Expand Down
18 changes: 9 additions & 9 deletions src/main/scala/MultiversalEquality.scala
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
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
// unless we add the derived implied instance like:
implied for Eql[Int, String] = Eql.derived
println(3 == "3")

// By default, all numbers are comparable, because of;
// implicit def eqNumber : Eq[Number, Number] = Eq
// implicit def eqlNumber: Eql[Number, Number] = derived
println(3 == 5.1)

// By default, all Sequences are comparable, because of;
// implicit def eqSeq[T, U](implicit eq: Eq[T, U]): Eq[Seq[T], Seq[U]] = Eq
// implicit def eqlSeq[T, U](implicit eq: Eql[T, U]): Eql[GenSeq[T], GenSeq[U]] = derived
println(List(1, 2) == Vector(1, 2))

class A(a: Int)
Expand All @@ -27,10 +27,10 @@ object MultiversalEquality {
val a = new A(4)
val b = new B(4)

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

println(a != b)
println(b == a)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/NamedTypeArguments.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/**
* Named Type Arguments: http://dotty.epfl.ch/docs/reference/named-typeargs.html
* Named Type Arguments: https://dotty.epfl.ch/docs/reference/other-new-features/named-typeargs.html
*/
object NamedTypeArguments {

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/PatternMatching.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/**
* Pattern Matching: http://dotty.epfl.ch/docs/reference/changed/pattern-matching.html
* Pattern Matching: https://dotty.epfl.ch/docs/reference/changed-features/pattern-matching.html
*/
object PatternMatching {

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/StructuralTypes.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/**
* Structural Types: http://dotty.epfl.ch/docs/reference/changed/structural-types.html
* Structural Types: https://dotty.epfl.ch/docs/reference/changed-features/structural-types.html
*/
object StructuralTypes {

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/TraitParams.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Trait Parameters: http://dotty.epfl.ch/docs/reference/trait-parameters.html
* Trait Parameters: https://dotty.epfl.ch/docs/reference/other-new-features/trait-parameters.html
*/
object TraitParams {

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/TypeLambdas.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Type Lambdas: http://dotty.epfl.ch/docs/reference/type-lambdas.html
* Type Lambdas: https://dotty.epfl.ch/docs/reference/new-types/type-lambdas.html
*/
object TypeLambdas {

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/UnionTypes.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Union Types: http://dotty.epfl.ch/docs/reference/union-types.html
* Union Types: https://dotty.epfl.ch/docs/reference/new-types/union-types.html
*/
object UnionTypes {

Expand Down