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
1
vote
1 answer

Extend with dependent type

Here is the minimal reproduction of my problem: trait Superclass[T] class A(val key: Any) extends Superclass[key.type] val x: Superclass["123"] = A("123") As you can see, I'm trying to encode the statically known type of Key into the…
Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
1
vote
1 answer

How to get match type to work correctly in Scala 3

I was very curious to see if I could port my untyped project to be typed with Scala 3. Here was my start: object Main { type HtmlNodeRecord[X]= X match { case "tag" => String case "attrs" => List[(String, String)] case "children" =>…
Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
1
vote
1 answer

Curried type "does not take type parameters"

I wanted to make a type that I could use to verify if a tuple is homogenous. I wrote this, which should ensure that all elements of T are equal to X (Scastie): type Homogenous[X] = [T <: Tuple] =>> T match { case EmptyTuple => DummyImplicit case…
user
  • 7,435
  • 3
  • 14
  • 44
1
vote
1 answer

How to translate type projections into PDTs in implicits?

Here is one idiomatic scala 2 example: trait Box { type Content val content :Content } implicit class BoxExtension[B <: Box](private val self :B) extends AnyVal { def map[O](f :self.Content => O)(implicit mapper :Mapper[B, O])…
Turin
  • 2,208
  • 15
  • 23
1
vote
1 answer

Type lambda with higher kind

In Dotty given the following: object Domain { final case class Create(name: String) extends BaseCreate[Create] { override type Model = Domain override def service[F[_]](client: KeystoneClient[F]): CrudService[F, Domain, Create] =…
Simão Martins
  • 1,210
  • 11
  • 22
1
vote
1 answer

What means this exception 'dotc: Bad symbolic reference.'

I want to work with Scala 3 and use some existing Libraries. The example works with Scala 2.13. When compiling I get this exception: dotc: Bad symbolic reference. A signature in ../dmn-engine-1.4.0.jar(org/camunda/dmn/parser/ParsedDmn.class) refers…
pme
  • 14,156
  • 3
  • 52
  • 95
1
vote
0 answers

Can I reuse a macro code in both modes, runtime and compile-time?

Can I use dottymacro staging to parse a string, generate code and run it at runtime? I was thinking about build a schema and web query language that can be used in different ways: passed via REST, or statically constructed and verified at…
shumy
  • 343
  • 1
  • 2
  • 10
1
vote
2 answers

IntelliJ suddenly stops highlighting errors in Scala/Dotty project

TLDR; IntelliJ isn't highlighting any errors (syntax/type mismatch) in my Scala project. I've tried type-aware highlighting, setting highlighting level to "Inspections", and enabling "Experimental Features" according to StackOverflow answers, and…
user
  • 7,435
  • 3
  • 14
  • 44
1
vote
1 answer

dotty seq mapping to union

I cant get the following code to compile with the latest dotty (0.9.0-RC1), and at first glance it looks like it should... object UnionMapping { private def parse(string: String): Int | Double = { if(string.contains(".")) …
aepurniet
  • 1,719
  • 16
  • 24
1
vote
0 answers

Consume Scala syntax-trees from external tool

I would like to develop a tool that would consume scala syntax-trees (as the title suggests). More specifically it would be great if I could consume the trees after each compilation phase. My research led me to Dotty's TASTY interchange format which…
Than21
  • 321
  • 1
  • 2
  • 10
1
vote
1 answer

Scala Dotty Union Type?

Using the sbt dotty plugin: addSbtPlugin("com.felixmulder" % "sbt-dotty" % "0.1.9") And running sbt console, I try out the new union type feature: Starting dotty interpreter... Welcome to Scala.next (pre-alpha, git-hash: 606e36b) (Java HotSpot(TM)…
clay
  • 18,138
  • 28
  • 107
  • 192
1
vote
1 answer

Union type subtyping in Scala

I can do following easily with Dotty: trait Ex {type T <: Int | Seq[Int]; def f:T} trait Ex2 extends Ex {override type T = Seq[Int]; override def f = Seq(2)} trait Ex3 extends Ex {override type T = Int; override def f = 2} How can I do union…
0
votes
0 answers

In Scala 3 (dotty) or Scala 2, how to make dependent types transitive?

Here is a simple example: { // dependent type in function def dep[B](a: Any, bs: Seq[B]): Seq[(a.type, B)] = { val result: Seq[(a.type, B)] = bs.map { b => (a: a.type) -> (b: B) } result } val ss = dep(3,…
tribbloid
  • 4,026
  • 14
  • 64
  • 103
0
votes
1 answer

In Scala 3, what's the canonical method for pattern match that uses an erased type?

Here is a simple example: object MatchErasedType { trait Supe { self: Singleton => type T1 lazy val default: T1 def process(v: Any): T1 = { v match { case vv: T1 => vv case _ => default } } …
tribbloid
  • 4,026
  • 14
  • 64
  • 103
0
votes
1 answer

How to write curried polymorphic function & its higher kind in Scala 3?

In Scala 3, I'm able to write a poly-function of type 1: val y = [C <: Int] => (x: C) => x * 2 When I try to generalise it into type 2: val z = [C <: Int] => ([D <: Int] => (x: C, y: D) = x * y) I got the following…
tribbloid
  • 4,026
  • 14
  • 64
  • 103