我想知道如何使用 Shapeless 库修复这个 Scala 代码,以便它编译:
object boo {
import shapeless._
sealed trait Bibby
case class LittleBibby(i: Int) extends Bibby
case class BigBibby(s: String) extends Bibby
type Bibbies = LittleBibby :: BigBibby :: HNil
val defaultBibbies: Bibbies = LittleBibby(1) :: BigBibby("beep") :: HNil
def update(b: Bibby, bibbies: Bibbies) : Bibbies = bibbies.updatedElem(b)
val demo: Bibbies = update(LittleBibby(3), defaultBibbies)
}
我收到以下错误消息:
could not find implicit value for parameter replacer:shapeless.Replacer[boo.Bibbies,boo.Bibby,boo.Bibby]
def update(b: Bibby, bibbies: Bibbies) : Bibbies = bibbies.updatedElem(b)
我试图查看无形的源代码以找到创建丢失的隐式的解决方案Replacer
,但无济于事:/