我想要一个Order
用于 Scala 的通用 Cats Enumeration
。我试过了
implicit def enumOrder[E <: Enumeration, V <: E#Value]: cats.Order[V] = new cats.Order[V] {
def compare(x: V, y: V): Int = x.compare(y)
}
但我明白了
[error] overloaded method value compare with alternatives:
[error] ((that: _1.Value)Int) forSome { val _1: E } <and>
[error] (that: _1.Value)Int
[error] cannot be applied to (V)
[error] def compare(x: V, y: V): Int = x.compare(y)
[error] ^
有人知道我该如何实现吗?谢谢
注意,我刚刚问了一个类似的问题,我认为这会产生一个我足够聪明地应用于这个问题的答案,但事实并非如此。