dependent-method-type

Exposing a path-dependent type coming from a singleton type

放肆的年华 提交于 2019-12-06 02:40:55
问题 I'm trying to make Scala find the right type for a path-dependent type coming from a singleton type. First, here is the type container for the example, and one instance: trait Container { type X def get(): X } val container = new Container { type X = String def get(): X = "" } I can see the String in this first attempt (so I already have a working scenario): class WithTypeParam[C <: Container](val c: C) { def getFromContainer(): c.X = c.get() } val withTypeParam = new WithTypeParam[container

Exposing a path-dependent type coming from a singleton type

别等时光非礼了梦想. 提交于 2019-12-04 08:51:13
I'm trying to make Scala find the right type for a path-dependent type coming from a singleton type. First, here is the type container for the example, and one instance: trait Container { type X def get(): X } val container = new Container { type X = String def get(): X = "" } I can see the String in this first attempt (so I already have a working scenario): class WithTypeParam[C <: Container](val c: C) { def getFromContainer(): c.X = c.get() } val withTypeParam = new WithTypeParam[container.type](container) // good, I see the String! val foo: String = withTypeParam.getFromContainer() But when

What are some compelling use cases for dependent method types?

妖精的绣舞 提交于 2019-11-26 19:17:56
Dependent method types, which used to be an experimental feature before, has now been enabled by default in the trunk , and apparently this seems to have created some excitement in the Scala community. At first look, it's not immediately obvious what this could be useful for. Heiko Seeberger posted a simple example of dependent method types here , which as can be seen in the comment there can easily be reproduced with type parameters on methods. So that wasn't a very compelling example. (I might be missing something obvious. Please correct me if so.) What are some practical and useful examples

What are some compelling use cases for dependent method types?

房东的猫 提交于 2019-11-26 06:54:37
问题 Dependent method types, which used to be an experimental feature before, has now been enabled by default in the trunk, and apparently this seems to have created some excitement in the Scala community. At first look, it\'s not immediately obvious what this could be useful for. Heiko Seeberger posted a simple example of dependent method types here, which as can be seen in the comment there can easily be reproduced with type parameters on methods. So that wasn\'t a very compelling example. (I