I thought of type fields as a more powerful syntax for type parameters, but a come across an example in which I can express my intent via the latter but not the former.
The thing is that trait A compiles, while trait B does not.
trait Box[T]
trait A[T] extends (Box[T] => Box[T]) {
override def apply(box: Box[T]): Box[T] = identity(box)
}
trait B extends (Box[T] => Box[T]) {
type T
override def apply(box: Box[T]): Box[T] = identity(box)
}
Is there a way to express what is expressed in A using type field as in B?
EDIT: Error message:
not found: type T
trait B extends (Box[T] => Box[T]) {
not found: type T
trait B extends (Box[T] => Box[T]) {