dotty

Scala 3 - Extract Tuple of wrappers and InverseMap on First Order Type

帅比萌擦擦* 提交于 2021-02-05 06:10:23
问题 I am trying to create a function, which takes a tuple of higher-kinded types and applies a function to the types within the higher-kinded types. In the example below, there is a trait Get[A] which is our higher-kinded type. There is also a tuple of Get's: (Get[String],Get[Int]) as well as function from (String,Int) => Person . Scala-3 has a Match-Type called InverseMap which converts the type (Get[String], Get[Int]) into what is essentially the type (String,Int). So the ultimate goal is to

Scala 3 - Extract Tuple of wrappers and InverseMap on First Order Type

非 Y 不嫁゛ 提交于 2021-02-05 06:10:15
问题 I am trying to create a function, which takes a tuple of higher-kinded types and applies a function to the types within the higher-kinded types. In the example below, there is a trait Get[A] which is our higher-kinded type. There is also a tuple of Get's: (Get[String],Get[Int]) as well as function from (String,Int) => Person . Scala-3 has a Match-Type called InverseMap which converts the type (Get[String], Get[Int]) into what is essentially the type (String,Int). So the ultimate goal is to

Type lambda with higher kind

限于喜欢 提交于 2021-01-28 06:09:37
问题 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] = client.domains } } case class Domain(id: String) class CrudService[F[_], Model, Create] final class Domains[F[_]] extends CrudService[F, Domain, Domain.Create] class KeystoneClient[F[_]] { val domains = new Domains[F] } trait BaseCreate[Create <: BaseCreate[Create]]

Does Dotty support refinements?

狂风中的少年 提交于 2021-01-28 03:13:30
问题 I am reading in dread what will come with Scala 3, paying particular attention to changes to compound types. They were always somewhat of a hack, so clean, true intersection types are certainly an improvement. I couldn't find though anything about what happens to the actual refinement part of the compound type. I rely heavily in my current project on strongly interwoven types in an attempt to have every returned value be as narrow as possible. So, for example, having trait Thing { thisThing =

Wrap function implementations returning a specific type into another function programatically

北战南征 提交于 2020-12-29 08:19:07
问题 I would like to wrap all the user defined functions in a scala project that return a certain type T , into a function that accepts a T and the function name as parameters. eg. given this function is in scope: def withMetrics[T](functionName: String)(f: => Try[T]): Try[T] = { f match { case _: Success[T] => println(s"send metric: success for $functionName") case _: Failure[T] => println(s"send metric: failure for $functionName") } f } the user can send metrics for their functions which return

Wrap function implementations returning a specific type into another function programatically

℡╲_俬逩灬. 提交于 2020-12-29 08:11:29
问题 I would like to wrap all the user defined functions in a scala project that return a certain type T , into a function that accepts a T and the function name as parameters. eg. given this function is in scope: def withMetrics[T](functionName: String)(f: => Try[T]): Try[T] = { f match { case _: Success[T] => println(s"send metric: success for $functionName") case _: Failure[T] => println(s"send metric: failure for $functionName") } f } the user can send metrics for their functions which return

Wrap function implementations returning a specific type into another function programatically

℡╲_俬逩灬. 提交于 2020-12-29 08:07:32
问题 I would like to wrap all the user defined functions in a scala project that return a certain type T , into a function that accepts a T and the function name as parameters. eg. given this function is in scope: def withMetrics[T](functionName: String)(f: => Try[T]): Try[T] = { f match { case _: Success[T] => println(s"send metric: success for $functionName") case _: Failure[T] => println(s"send metric: failure for $functionName") } f } the user can send metrics for their functions which return

Scala 3 - Extract Tuple of wrappers and InverseMap on First Order Type

点点圈 提交于 2020-12-29 07:59:59
问题 I am trying to create a function, which takes a tuple of higher-kinded types and applies a function to the types within the higher-kinded types. In the example below, there is a trait Get[A] which is our higher-kinded type. There is also a tuple of Get's: (Get[String],Get[Int]) as well as function from (String,Int) => Person . Scala-3 has a Match-Type called InverseMap which converts the type (Get[String], Get[Int]) into what is essentially the type (String,Int). So the ultimate goal is to

How to make implicits available to inner function

[亡魂溺海] 提交于 2020-12-06 07:07:05
问题 I would like to define implicit value in a wrapper function and make it available to inner function, so far I managed to do that by passing implicit variable from wrapper: case class B() trait Helper { def withImplicit[A]()(block: => A): A = { implicit val b: B = B() block } } class Test extends Helper { def useImplicit()(implicit b: B): Unit = {...} def test = { withImplicit() { implicit b: B => useImplicit() } } } Is it possible to avoid implicit b: B => and make implicit val b: B = B()