Open
Description
minimized code
trait List2Option{
def apply[A](list: List[A]): Option[A]
}
val l2o: List2Option = [A] => (lst: List[A]) => lst.headOption
This code does not compile, with the error message
Found: Object with PolyFunction {...}
Required: List2Option
expectation
Would expect the compiler to accept it as a SAM implementation of List2Option, the same way it does with other irregular function types (as it does with dependant functions for example).
I will add that the following (quite unsuprisingly) does work, but this way forces you to use a pair of brackets on the apply method in List2Option
trait List2Option{
def apply(): [A] => List[A] => Option[A]
}
val l2o: List2Option = () => [A] => (lst: List[A]) => lst.headOption