(discussed briefly with @smarter at scalasphere)
Fundamentally, the reason why Scala FP has gone down the route of using implicit classes for syntax is because it is not possible to import two symbols from different import statements, that have the same name. Consider:
trait Applicative[F[_]]
object Applicative {
def map[F[_]: Applicative, A, B](fa: F[A])(f: A => B): F[B]
}
trait Monad[F[_]]
object Monad {
def map[F[_]: Monad, A, B](fa: F[A])(f: A => B): F[B]
}
import Monad.map
import Applicative.map
bang, symbol shadowing.
But it is possible to explicitly define
def map[F[_]: Applicative, A, B](fa: F[A])(f: A => B): F[B]
def map[F[_]: Monad, A, B](fa: F[A])(f: A => B): F[B]
and use them within the same compilation unit.
I think it would be very beneficial if imports allowed method overloading and shadowing only occurs for exact matches.
FWIW, there should be a scalac issue (that I can't find sadly) about the same proposal for scalac where this was rejected because. But this might be feasible in Dotty's design maybe? At least, it seems a MultiDenotation can represent an overload of symbols from different prefixes.
Any reason for closing this? If not interested, there鈥檚 an unsubscribe button.
@Blaisorblade yes I am closing all my tickets that I no longer plan to work on to clean up searches for my open tickets. Please copy this ticket to a fresh one if you plan to pick this up.
I am also blocked from the scala/contributors gitter room, without explanation. I do not feel welcome contributing to Scala anymore, despite the many years I have put into it, and hence feel it is inappropriate for any of my tickets to remain open.
Most helpful comment
FWIW, there should be a scalac issue (that I can't find sadly) about the same proposal for scalac where this was rejected because. But this might be feasible in Dotty's design maybe? At least, it seems a
MultiDenotationcan represent an overload of symbols from different prefixes.