dotty

In scala 2 or 3, is it possible to debug implicit resolution process in runtime?

偶尔善良 提交于 2020-02-23 06:27:51
问题 In scala language, implicit resolution is often done in compile-time and sometimes throws obfuscating error information, one famous example of such error is when shapeless Generic throws error information like: error: could not find implicit value for parameter encoder: CsvEncoder[Foo] (see https://books.underscore.io/shapeless-guide/shapeless-guide.html for detail) A solution to this problem is to run implicit resolution algorithm (should be a graph query algorithm internally) in runtime,

What does Dotty offer to replace type projections?

ぐ巨炮叔叔 提交于 2020-01-24 17:52:19
问题 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 really useful. For example: trait Contents class Foo extends Contents class Bar extends Contents trait Container[T <: Contents] { type ContentType = T } class FooContainer extends Container[Foo] class BarContainer extends Container[Bar] trait

What does Dotty offer to replace type projections?

喜你入骨 提交于 2020-01-24 17:52:05
问题 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 really useful. For example: trait Contents class Foo extends Contents class Bar extends Contents trait Container[T <: Contents] { type ContentType = T } class FooContainer extends Container[Foo] class BarContainer extends Container[Bar] trait

How to execute dotty code from Visual Studio Code UI

我们两清 提交于 2019-12-24 02:51:21
问题 I'm trying to use Visual Studio Code to run dotty code. I started IDE using sbt launchIDE according to the instruction from this page, and I also installed Dotty Language Server and Code Runner extensions. Dotty is installed using brew and I can compile and execute dotty code from CMD. The problem is that I cannot run this code from Visual Studio Code because Code Runner is trying to execute it using scala instead of dotty. Can't find any useful configuration to adjust this plugin to use

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

北战南征 提交于 2019-12-20 08:36:57
问题 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 backward-compatibility issues. But if it happens, how should we program in Scala today to be forward-compatible with Dotty? I didn't get all the ideas from the talk so I'd like someone more profound to summarize the changes and describe how can we prepare

Generate functions based on type parameter

巧了我就是萌 提交于 2019-12-11 04:06:20
问题 I would like to generate functions for a class accepting 1 type parameter, which wraps a by name value. class C[T](_t: => T) { def t: T = _t } The functions I would like to generate are derived by the functions available on T . What I would like exactly, is to get all the functions available for T , change their contract and implementation in a programmatic way, and make them available for C . By changing their contract, I mean changing their signature so they return C[R] , where R stands for

Generate functions at macros expansion time

 ̄綄美尐妖づ 提交于 2019-12-06 05:13:29
问题 I would like to generate functions for a class accepting 1 type parameter case class C[T] (t: T) depending on the T type parameter. The functions I would like to generate are derived by the functions available on T . What I would like exactly, is to make all the functions available for T , also available for C . As an example for C[Int] , I would like to be able to call on C any function available on Int and dispatch the function call to the Int contained in C . val c1 = new C(1) assert(c1 +

Generate functions at macros expansion time

陌路散爱 提交于 2019-12-04 09:43:28
I would like to generate functions for a class accepting 1 type parameter case class C[T] (t: T) depending on the T type parameter. The functions I would like to generate are derived by the functions available on T . What I would like exactly, is to make all the functions available for T , also available for C . As an example for C[Int] , I would like to be able to call on C any function available on Int and dispatch the function call to the Int contained in C . val c1 = new C(1) assert(c1 + 1 == 2) How can I achieve this by using Scala 2 or dotty macros? Or, can this be achieved in another

Case class constructor argument type depending on the previous argument value

倾然丶 夕夏残阳落幕 提交于 2019-11-30 17:43:37
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 state depends on (the value of) system . That, however, is not supported: illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one With function arguments, I could split the arguments into two argument lists, which is not possible with a case class constructor: def f(system: Stateful)(state: system.State): Unit = {} // compiles The best I can do is: case class

Case class constructor argument type depending on the previous argument value

孤街浪徒 提交于 2019-11-30 01:16:26
问题 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 state depends on (the value of) system . That, however, is not supported: illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one With function arguments, I could split the arguments into two argument lists, which is not possible with a case class constructor: def f