Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 解构单一类型到其组成部分的统一_Scala_Types_Shapeless_Type Level Computation - Fatal编程技术网

Scala 解构单一类型到其组成部分的统一

Scala 解构单一类型到其组成部分的统一,scala,types,shapeless,type-level-computation,Scala,Types,Shapeless,Type Level Computation,我正在使用单例类型,根据Miles Sabin的一段代码片段,我有以下内容: scala> trait Param[K] { self => | type V | } defined trait Param scala> def param[V0](key: String): Param[key.type] { type V = V0 } = new Param[key.type] { type V = V0 } param: [V0](key:

我正在使用单例类型,根据Miles Sabin的一段代码片段,我有以下内容:

scala> trait Param[K] { self =>
     |   type V
     | }
defined trait Param

scala> def param[V0](key: String): Param[key.type] { type V = V0 } = new    Param[key.type] { type V = V0 }
param: [V0](key: String)Param[key.type]{type V = V0}


scala>   val r = param[Int]("q")
r: Param[String("q")]{type V = Int} = $anon$1@770c789a

scala>   val s = param[String]("s")
s: Param[String("s")]{type V = String} = $anon$1@9e77ebd
到目前为止还不错,但现在我有一个表达:

scala>   val ff = if (true) {
    |     r
    |   } else {
    |     s
    |   }
ff: Param[_ >: String("q") with String("s") <: String]{type V >: Int with String} = $anon$1@770c789a
我在寻找一些纯粹的类型级别的东西。有没有可能有一种机制来解构统一类型

Param[K0 with K1] { type V: V0 with V1 } -> (Param[K0] { type V: V0}, Param[K1] { type V: V1})