小编spa*_*kle的帖子

有没有办法扩展类型声明?

我正在尝试使用无形'Coproduct进行错误类型聚合.以下是尝试隔离我目前的问题:

import shapeless._

case object F1
case object F2
type F12 = F1.type :+: F2.type :+: CNil

case object F3
case object F4
type F34 = F3.type :+: F4.type :+: CNil

type F1234 = F1.type :+: F2.type :+: F3.type :+: F4.type :+: CNil

def custom(f: Either[F12, F34]): F1234 = // how can I declare the resulting type?
  f.fold(_.extendRightBy[F34], _.extendLeftBy[F12])

object F1234Handler extends Poly1 {
  implicit def caseF1 = at[F1.type](_ => "got F1")
  implicit def caseF2 = at[F2.type](_ => "got F2") …
Run Code Online (Sandbox Code Playgroud)

scala shapeless

5
推荐指数
1
解决办法
149
查看次数

标签 统计

scala ×1

shapeless ×1