一些背景代码 -
trait forall[P[_]] {
def apply[A]: P[A]
}
// though writing this here I have half a mind to define –
trait `for all`[P[_]] extends (Id ~> P)
// sub^10 (like - sub sub sub...) question does `for all` have any advantages over it's simpler cousin?
trait Pi[B[_]] {
type P[_]
type A
def apply(a:A): P[B[A]]
}
def instanceOf[TC[_], X] : TC[X] = { (implicit x: TC[X]) =>
val f =
new Pi[({type l[x] = TC[x] })#l] {
type P[_] = ??? // maybe ..= forall[({type l[x] = Iso[X, TC[X]]})#l]
type A = X
def apply(x: A): P[B[A]] = ???
}
f(x)
}
现在我有了一个想法,"一个为类型构造函数TC和类型X返回TC [X]实例的函数?" 现在我已经看过像喜鹊和斯卡拉兹这样的图书馆,莱布尼茨平等,我想知道这是必要的吗?类似iso的东西?
trait Iso[A, B] {
def to(x: A): B
def from(x: B): A
}
我觉得我接近某种类似答案的东西,但是我认为它拖延了过多的机器?反正
怎么做?