Questions tagged [dotty]

Please use the [scala-3] tag for new questions about Scala 3. Dotty was a platform to try out new language concepts and compiler technologies for Scala. The theory behind these constructors is researched in DOT, a calculus for dependent object types. Most of these new technologies were incorporated into Scala 3.

Definition:

Dotty is both the name for a new compiler, as well as an umbrella term for new language concepts, that are slated to become Scala 3. The underlying theory is the calculus of dependent object types, or DOT in short. It is under active research.

Example Installation:

brew install lampepfl/brew/dotty

Important Links:

106 questions
38
votes
6 answers

What exactly is Dotty?

I am reading about Scala 3 and discovered dotty. I am trying to understand what it is. Somewhere I read "It is new compiler", somewhere I read "It is part of Scala 3", and somewhere I read "Dotty is new Scala 3". Can somebody please explain to me…
nomadSK25
  • 2,350
  • 3
  • 25
  • 36
30
votes
2 answers

How to program in Scala to be forward-compatible with Dotty

In hist recent talk at Strange Loop Martin Odersky shed the light on his vision of Scala's future version called Dotty. I understand this is work-in-progress and it even may not flow into Scala (at least not very fast) due to many possible…
Tvaroh
  • 6,645
  • 4
  • 51
  • 55
19
votes
1 answer

Can I code in Dotty in German (or at all) in IntelliJ?

Suspicious that at least a part of this post might be an April Fool's joke, I set about installing Dotty on my Linux laptop and was pleased and surprised to discover that it seems to be completely straight - I was able to get the Fibonacci function…
Mark
  • 1,112
  • 8
  • 9
14
votes
1 answer

Case class constructor argument type depending on the previous argument value

I am trying to do the following trait Stateful { type State } case class SystemState(system: Stateful, state: system.State) // does not compile That is, the type of statedepends on (the value of) system. That, however, is not supported: illegal…
Tomas Mikula
  • 6,537
  • 25
  • 39
13
votes
1 answer

How will Dotty change pure functional programming in Scala?

In this question from 2013, Mr. Odersky notes that "it's too early to tell" whether libraries like Scalaz will be able to exist (at least in their current state) under Dotty, due to the castration of higher-kinded and existential types. In the time…
kantianethics
  • 671
  • 5
  • 21
10
votes
1 answer

scala 3 macro how to implement generic trait

I want to implement a proxy of some trait A (e.g. delegates method call to some rpc call), like this def clientProxy[A](using Type[A], Quotes): Expr[A] = { import quotes.reflect._ val defTrees: List[Tree] =…
jilen
  • 5,633
  • 3
  • 35
  • 84
10
votes
1 answer

How to access parameter list of case class in a dotty macro

I am trying to learn meta-programming in dotty. Specifically compile time code generation. I thought learning by building something would be a good approach. So I decided to make a CSV parser which will parse lines into case classes. I want to use…
Bilal Fazlani
  • 6,727
  • 9
  • 44
  • 90
10
votes
1 answer

Is there a simple way to compile an sbt project with Dotty?

Now that Dotty is apparently getting ready to compile larger projects, I wonder if there is a simple way to use it as drop-in replacement for Scalac in sbt projects? Like if I had the following build.sbt: name := "Foo" scalaVersion := "2.11.7" Are…
0__
  • 66,707
  • 21
  • 171
  • 266
8
votes
1 answer

Scala 3 (Dotty) Pattern match a function with a macro quotation

I'm trying to get the function name via macros in Scala 3.0.0-M2 The solution that I came up with uses TreeAccumulator import scala.quoted._ inline def getName[T](inline f: T => Any): String = ${getNameImpl('f)} def getNameImpl[T](f: Expr[T =>…
Yevhenii Melnyk
  • 553
  • 4
  • 16
8
votes
1 answer

What does Dotty offer to replace type projections?

I have been reading about Dotty, since it looks like it is about to become scala 3, and noticed that type projections are deemed "unsound" and removed from the language ... This seems like a bummer, as I have seen several use cases where they were…
Dima
  • 39,570
  • 6
  • 44
  • 70
7
votes
1 answer

How does Dotty decide how to infer/when to widen Union Types?

Widening Union Types have been discussed here but I can't seem to find an answer to the following case Let's start by looking at the following val x = List(1, 2, "a") This heterogeneous list is inferred as List[Any] Just like it would in Scala…
sinanspd
  • 2,589
  • 3
  • 19
  • 37
7
votes
0 answers

Difference between union type LUB and supertype LUB

List of shapes infers to List[Shape] but list of boxed shapes infers to List[Box[Square | Circle]] scala> sealed trait Shape | case class Square() extends Shape | case class Circle() extends Shape | case class Box[+T <: Shape](t: T) …
Mario Galic
  • 47,285
  • 6
  • 56
  • 98
7
votes
1 answer

How does one completely avoid runtime reflection in Scala?

Note this is intended to be a community post, and examples should be added as needed. If you can't directly edit the answer to add examples (either problem examples or solutions), post in a comment with a link to a gist (or similar) or add a…
bbarker
  • 11,636
  • 9
  • 38
  • 62
6
votes
1 answer

2 Extension Methods with the same name in different classes do not work in Scala 3?

I have the following scenario: case class B(v: String) case class A(bs: Seq[B]) extension(a: A) def doit() = a.bs.map(_.doit()) // here is the exception extension(b: B) def doit() = println("OK: ${b.v}") This gives me the following exception…
pme
  • 14,156
  • 3
  • 52
  • 95
6
votes
1 answer

Is there a way to use the Scala 3 compiler (Dotty) from Gradle yet?

I am new to both Gradle and Dotty (and still relatively new to Scala overall). I was able to create a Scala project with Gradle like this: gradle init --dsl kotlin --type scala-library --package com.stackoverflow.example and I know that Dotty can…
Keith Pinson
  • 7,835
  • 7
  • 61
  • 104
1
2 3 4 5 6 7 8