I have a function that takes a typed sort function as a parameter, and I want this sort function to have a default parameter:
def foo[T](sort: MyObject => T = _.position)(implicit o: Ordering[T])
MyObject.position returns an Int.
Understandably, I am getting this error:
Expression of type (MyObject) => Int doesn't conform to expected type (MyObject) => T
OK, but I was hoping that the compiler would figure out that in the default case T is Int and check that an Ordering[Int] is available in implicit scope.
How can I help the compiler resolve this?