From 6cc005e7571e0fe4c28d941de631511c1912c41d Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 21 Nov 2018 16:45:40 +0100 Subject: [PATCH 1/9] Upgrade sbt-dotty to 0.2.6 --- README.md | 2 +- project/plugins.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 122d972..b819295 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ You will need to make the following adjustments to your build: ### project/plugins.sbt ```scala -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.4") +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.6") ``` ### project/build.properties diff --git a/project/plugins.sbt b/project/plugins.sbt index f488f11..174dbbc 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.4") +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.6") From 4fc51a7e58c127741ae63e56b78facbdf5c803b2 Mon Sep 17 00:00:00 2001 From: Allan Renucci Date: Tue, 27 Nov 2018 18:13:33 +0100 Subject: [PATCH 2/9] Release Dotty 0.11.0-RC1 --- README.md | 4 ++-- build.sbt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b819295..6eff7d1 100644 --- a/README.md +++ b/README.md @@ -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.10.0-RC1" +scalaVersion := "0.11.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.11/ to find the version +https://repo1.maven.org/maven2/ch/epfl/lamp/dotty_0.12/ 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. diff --git a/build.sbt b/build.sbt index 0126c9d..96030d8 100644 --- a/build.sbt +++ b/build.sbt @@ -5,5 +5,5 @@ lazy val root = project description := "Example sbt project that compiles using Dotty", version := "0.1.0", - scalaVersion := "0.10.0-RC1" + scalaVersion := "0.11.0-RC1" ) From f04f0f6f9070bc81e10e19795a8a2300e4d6b5e4 Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Fri, 18 Jan 2019 17:38:34 +0100 Subject: [PATCH 3/9] Release Dotty 0.12.0-RC1 --- README.md | 4 ++-- build.sbt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6eff7d1..6a7c57a 100644 --- a/README.md +++ b/README.md @@ -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.11.0-RC1" +scalaVersion := "0.12.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.12/ to find the version +https://repo1.maven.org/maven2/ch/epfl/lamp/dotty_0.13/ 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. diff --git a/build.sbt b/build.sbt index 96030d8..b1a7d3f 100644 --- a/build.sbt +++ b/build.sbt @@ -5,5 +5,5 @@ lazy val root = project description := "Example sbt project that compiles using Dotty", version := "0.1.0", - scalaVersion := "0.11.0-RC1" + scalaVersion := "0.12.0-RC1" ) From 6a6d5c947867e6f1efe08078c1ee4f4c3e0701c7 Mon Sep 17 00:00:00 2001 From: Selman Date: Wed, 23 Jan 2019 13:36:30 +0300 Subject: [PATCH 4/9] Update README.md Added Guillaume Martres' code which is an answer in https://stackoverflow.com/questions/45342846/scala-play-with-dotty --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 6a7c57a..63127c5 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,12 @@ by: libraryDependencies += ("a" %% "b" % "c").withDottyCompat(scalaVersion.value) ``` +Or you can alternatively use: + +```scala + libraryDependencies := libraryDependencies.value.map(_.withDottyCompat(scalaVersion.value)) +``` + This will have no effect when compiling with Scala 2.x, but when compiling with Dotty this will change the cross-version to a Scala 2.x one. This works because Dotty is currently retro-compatible with Scala 2.x. From 6b4d2a834d963121fd9fd85ec32d6c313b86140a Mon Sep 17 00:00:00 2001 From: Alvin Alexander Date: Wed, 6 Feb 2019 12:34:40 -0700 Subject: [PATCH 5/9] updated url --- src/main/scala/ImplicitConversion.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/ImplicitConversion.scala b/src/main/scala/ImplicitConversion.scala index 25bbd12..97867e3 100644 --- a/src/main/scala/ImplicitConversion.scala +++ b/src/main/scala/ImplicitConversion.scala @@ -1,7 +1,7 @@ import scala.language.implicitConversions /** - * Implicit Conversions: http://dotty.epfl.ch/docs/reference/changed/implicit-conversions.html + * Implicit Conversions: http://dotty.epfl.ch/docs/reference/changed-features/implicit-conversions.html */ object ImplicitConversion { From 7d306d57666e65b17ef96e5caff85e1a2df61814 Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Tue, 26 Feb 2019 14:36:15 +0100 Subject: [PATCH 6/9] Release Dotty 0.13.0-RC1 --- README.md | 4 ++-- build.sbt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 63127c5..e0ce091 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/build.sbt b/build.sbt index b1a7d3f..a519adc 100644 --- a/build.sbt +++ b/build.sbt @@ -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" ) From 0c01817c0373d014afe09da5362bf8271e6f1fe6 Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Tue, 26 Feb 2019 15:37:54 +0100 Subject: [PATCH 7/9] Apply implied changes --- README.md | 4 ++-- project/build.properties | 2 +- project/plugins.sbt | 2 +- ...mplicitFunctions.scala => ContextQueries.scala} | 14 ++++++-------- .../{ImplicitConversion.scala => Conversion.scala} | 10 +++++----- src/main/scala/Main.scala | 4 ++-- src/main/scala/MultiversalEquality.scala | 10 +++++----- 7 files changed, 22 insertions(+), 24 deletions(-) rename src/main/scala/{ImplicitFunctions.scala => ContextQueries.scala} (70%) rename src/main/scala/{ImplicitConversion.scala => Conversion.scala} (56%) diff --git a/README.md b/README.md index e0ce091..860f9fd 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/project/build.properties b/project/build.properties index 0cd8b07..72f9028 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.3 +sbt.version=1.2.7 diff --git a/project/plugins.sbt b/project/plugins.sbt index 174dbbc..b5de60f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.2.6") +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.3.0") diff --git a/src/main/scala/ImplicitFunctions.scala b/src/main/scala/ContextQueries.scala similarity index 70% rename from src/main/scala/ImplicitFunctions.scala rename to src/main/scala/ContextQueries.scala index 749b0b4..b6991ad 100644 --- a/src/main/scala/ImplicitFunctions.scala +++ b/src/main/scala/ContextQueries.scala @@ -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]] diff --git a/src/main/scala/ImplicitConversion.scala b/src/main/scala/Conversion.scala similarity index 56% rename from src/main/scala/ImplicitConversion.scala rename to src/main/scala/Conversion.scala index 97867e3..95b64df 100644 --- a/src/main/scala/ImplicitConversion.scala +++ b/src/main/scala/Conversion.scala @@ -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 diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala index df2d788..9704fcd 100644 --- a/src/main/scala/Main.scala +++ b/src/main/scala/Main.scala @@ -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) diff --git a/src/main/scala/MultiversalEquality.scala b/src/main/scala/MultiversalEquality.scala index 6e837c3..0a6b1dc 100644 --- a/src/main/scala/MultiversalEquality.scala +++ b/src/main/scala/MultiversalEquality.scala @@ -1,8 +1,8 @@ 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 { @@ -10,7 +10,7 @@ object MultiversalEquality { // 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; @@ -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) From 34953cdca950b3dda1f34ee0f14f3048373fd3f1 Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Tue, 26 Feb 2019 19:23:25 +0100 Subject: [PATCH 8/9] Adjust more examples with the new implicits, renames and update doc urls --- src/main/scala/AutoParamTupling.scala | 4 ++-- src/main/scala/ContextQueries.scala | 4 ++-- src/main/scala/EnumTypes.scala | 2 +- ...plicitParams.scala => ImpliedInstances.scala} | 16 ++++++++-------- src/main/scala/IntersectionTypes.scala | 2 +- src/main/scala/Main.scala | 2 +- src/main/scala/MultiversalEquality.scala | 14 +++++++------- src/main/scala/NamedTypeArguments.scala | 2 +- src/main/scala/PatternMatching.scala | 2 +- src/main/scala/StructuralTypes.scala | 2 +- src/main/scala/TraitParams.scala | 2 +- src/main/scala/TypeLambdas.scala | 2 +- src/main/scala/UnionTypes.scala | 2 +- 13 files changed, 28 insertions(+), 28 deletions(-) rename src/main/scala/{ImplicitParams.scala => ImpliedInstances.scala} (59%) diff --git a/src/main/scala/AutoParamTupling.scala b/src/main/scala/AutoParamTupling.scala index 8582dd7..b72bab8 100644 --- a/src/main/scala/AutoParamTupling.scala +++ b/src/main/scala/AutoParamTupling.scala @@ -1,6 +1,6 @@ /** - * 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 { @@ -8,7 +8,7 @@ object AutoParamTupling { /** * 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") diff --git a/src/main/scala/ContextQueries.scala b/src/main/scala/ContextQueries.scala index b6991ad..3048d66 100644 --- a/src/main/scala/ContextQueries.scala +++ b/src/main/scala/ContextQueries.scala @@ -21,10 +21,10 @@ object ContextQueries /* Formerly known as Implicit Function Types */ { object parse { - type Parseable[T] = given 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) diff --git a/src/main/scala/EnumTypes.scala b/src/main/scala/EnumTypes.scala index d1c36b5..9621d59 100644 --- a/src/main/scala/EnumTypes.scala +++ b/src/main/scala/EnumTypes.scala @@ -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 { diff --git a/src/main/scala/ImplicitParams.scala b/src/main/scala/ImpliedInstances.scala similarity index 59% rename from src/main/scala/ImplicitParams.scala rename to src/main/scala/ImpliedInstances.scala index 59329a3..7b143f8 100644 --- a/src/main/scala/ImplicitParams.scala +++ b/src/main/scala/ImpliedInstances.scala @@ -1,10 +1,10 @@ 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] @@ -12,16 +12,16 @@ object ImplicitParams { 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 @@ -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")) } } diff --git a/src/main/scala/IntersectionTypes.scala b/src/main/scala/IntersectionTypes.scala index 2a91725..9ebeed4 100644 --- a/src/main/scala/IntersectionTypes.scala +++ b/src/main/scala/IntersectionTypes.scala @@ -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 { diff --git a/src/main/scala/Main.scala b/src/main/scala/Main.scala index 9704fcd..18aed26 100644 --- a/src/main/scala/Main.scala +++ b/src/main/scala/Main.scala @@ -9,7 +9,7 @@ object Main { runExample("Context Queries")(ContextQueries.test) - runExample("Implicit Params")(ImplicitParams.test) + runExample("Implied Instances")(ImpliedInstances.test) runExample("Conversion")(Conversion.test) diff --git a/src/main/scala/MultiversalEquality.scala b/src/main/scala/MultiversalEquality.scala index 0a6b1dc..d9f87b6 100644 --- a/src/main/scala/MultiversalEquality.scala +++ b/src/main/scala/MultiversalEquality.scala @@ -9,16 +9,16 @@ 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: Eql[Int, String] = Eql.derived + // 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) @@ -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: Eql[A, B] = Eql.derived - implicit def eqBA: Eql[B, A] = Eql.derived + implied for Eql[A, B] = Eql.derived + implied for Eql[B, A] = Eql.derived println(a != b) println(b == a) diff --git a/src/main/scala/NamedTypeArguments.scala b/src/main/scala/NamedTypeArguments.scala index fa4c438..85cee9a 100644 --- a/src/main/scala/NamedTypeArguments.scala +++ b/src/main/scala/NamedTypeArguments.scala @@ -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 { diff --git a/src/main/scala/PatternMatching.scala b/src/main/scala/PatternMatching.scala index 14d9d37..8e64e87 100644 --- a/src/main/scala/PatternMatching.scala +++ b/src/main/scala/PatternMatching.scala @@ -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 { diff --git a/src/main/scala/StructuralTypes.scala b/src/main/scala/StructuralTypes.scala index 3c7499d..4eb60a4 100644 --- a/src/main/scala/StructuralTypes.scala +++ b/src/main/scala/StructuralTypes.scala @@ -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 { diff --git a/src/main/scala/TraitParams.scala b/src/main/scala/TraitParams.scala index 0af162b..5d44099 100644 --- a/src/main/scala/TraitParams.scala +++ b/src/main/scala/TraitParams.scala @@ -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 { diff --git a/src/main/scala/TypeLambdas.scala b/src/main/scala/TypeLambdas.scala index bc1c370..c877c71 100644 --- a/src/main/scala/TypeLambdas.scala +++ b/src/main/scala/TypeLambdas.scala @@ -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 { diff --git a/src/main/scala/UnionTypes.scala b/src/main/scala/UnionTypes.scala index 8d992bf..ab3e365 100644 --- a/src/main/scala/UnionTypes.scala +++ b/src/main/scala/UnionTypes.scala @@ -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 { From c44c9961ec9742c21556667cceb55d625b5b10ea Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Mon, 30 Jul 2018 15:23:43 +0200 Subject: [PATCH 9/9] Build with mill --- .travis.yml | 8 ----- README.md | 64 +++++++++++++++------------------------- build.sbt | 9 ------ build.sc | 7 +++++ project/build.properties | 1 - project/plugins.sbt | 1 - 6 files changed, 30 insertions(+), 60 deletions(-) delete mode 100644 .travis.yml delete mode 100644 build.sbt create mode 100644 build.sc delete mode 100644 project/build.properties delete mode 100644 project/plugins.sbt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f4d92f2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: scala - -jdk: - - oraclejdk8 - -script: - - sbt run - - sbt 'set scalaVersion := dottyLatestNightlyBuild.get' run diff --git a/README.md b/README.md index 860f9fd..50a1550 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,51 @@ -# Example sbt project that compiles using Dotty +# Example mill project that compiles using Dotty -[![Build Status](https://travis-ci.org/lampepfl/dotty-example-project.svg?branch=master)](https://travis-ci.org/lampepfl/dotty-example-project) +**NOTE**: Dotty support in mill is experimental. For now, sbt remains the +preferred option, see http://github.com/lampepfl/dotty-example-project for an +example sbt project. ## Usage -This is a normal sbt project, you can compile code with `sbt compile` and run it -with `sbt run`, `sbt console` will start a Dotty REPL. - -If compiling this example project fails, you probably have a global sbt plugin -that does not work with dotty, try to disable all plugins in -`~/.sbt/1.0/plugins` and `~/.sbt/1.0`. +This is a normal mill project, you can compile code with `mill root.compile` and run it +with `mill root.run`, `mill -i root.console` will start a Dotty REPL. ### IDE support -Dotty comes built-in with IDE support, to try it out see -http://dotty.epfl.ch/docs/usage/ide-support.html - -## Making a new Dotty project -The fastest way to start a new Dotty project is to use one of the following templates: -* [Simple Dotty project](https://github.com/lampepfl/dotty.g8) -* [Dotty project that cross-compiles with Scala 2](https://github.com/lampepfl/dotty-cross.g8) +Dotty comes built-in with IDE support, unfortunately this support is only +available using sbt and not mill for now, see http://dotty.epfl.ch/docs/usage/ide-support.html ## Using Dotty in an existing project -You will need to make the following adjustments to your build: - -### project/plugins.sbt -```scala -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.3.0") -``` - -### project/build.properties -```scala -sbt.version=1.2.7 -``` - -Older versions of sbt are not supported. - - -### build.sbt -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: +### build.sc +Any version number that starts with `0.` is automatically recognized as Dotty, +you don't need to set up anything: ```scala -scalaVersion := "0.13.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.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. +number for the latest nightly build. ## Getting your project to compile with Dotty When porting an existing project, it's a good idea to start out with the Scala 2 compatibility mode (note that this mode affects typechecking and thus may -prevent some valid Dotty code from compiling) by adding to your `build.sbt`: +prevent some valid Dotty code from compiling) by adding to your `build.sc`: ```scala -scalacOptions ++= { if (isDotty.value) Seq("-language:Scala2") else Nil } +def scalacOptions = T { + if (Dep.isDotty(scalaVersion())) + Seq("-language:Scala2") + else + Seq() +} ``` -Using the `isDotty` setting ensures that this option will only be set when +Using the `Dep.isDotty` method ensures that this option will only be set when compiling with Dotty. A tool to port code from Scala 2.x to Dotty is currently in development at @@ -73,13 +55,13 @@ If your build contains dependencies that have only been published for Scala 2.x, you may be able to get them to work on Dotty by replacing: ```scala - libraryDependencies += "a" %% "b" % "c" +ivy"a::b:c" ``` by: ```scala - libraryDependencies += ("a" %% "b" % "c").withDottyCompat(scalaVersion.value) +ivy"a::b:c".withDottyCompat(scalaVersion()) ``` Or you can alternatively use: diff --git a/build.sbt b/build.sbt deleted file mode 100644 index a519adc..0000000 --- a/build.sbt +++ /dev/null @@ -1,9 +0,0 @@ -lazy val root = project - .in(file(".")) - .settings( - name := "dotty-example-project", - description := "Example sbt project that compiles using Dotty", - version := "0.1.0", - - scalaVersion := "0.13.0-RC1" - ) diff --git a/build.sc b/build.sc new file mode 100644 index 0000000..e5f9c2c --- /dev/null +++ b/build.sc @@ -0,0 +1,7 @@ +import mill._, scalalib._ + +object root extends SbtModule { + def millSourcePath = ammonite.ops.pwd + def scalaVersion = "0.13.0-RC1" + def publishVersion = "0.1.0" +} diff --git a/project/build.properties b/project/build.properties deleted file mode 100644 index 72f9028..0000000 --- a/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=1.2.7 diff --git a/project/plugins.sbt b/project/plugins.sbt deleted file mode 100644 index b5de60f..0000000 --- a/project/plugins.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.3.0")