scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Compiler plugins in REPL

Open rossabaker opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

I'm trying to use kind-projector in a REPL. It downloads, but does not seem to take effect.

$ scala-cli repl --compiler-plugin org.typelevel:::kind-projector:0.13.3 --scala 2.13.14 --dep org.typelevel::cats-core:2.10.0
Welcome to Scala 2.13.14 (OpenJDK 64-Bit Server VM, Java 17.0.10).
Type in expressions for evaluation. Or try :help.

scala> cats.Functor[Either[String, *]]
                                   ^
       error: not found: type *
                    ^
       error: Either[String,<error>] takes no type parameters, expected: 1

Describe the solution you'd like

I would like compiler plugins to work inside the repl. The above example should find the instance.

Describe alternatives you've considered

Print a warning or fail with an error if compiler plugins are provided to a REPL that can't honor them.

Additional context

Compiler plugins appear to be honored outside the repl:

$ echo 'println(cats.Functor[Either[String,*]])' | scala-cli run --compiler-plugin org.typelevel:::kind-projector:0.13.3 --scala 2.13.14 --dep org.typelevel::cats-core:2.10.0 -
Compiling project (Scala 2.13.14, JVM (17))
Compiled project (Scala 2.13.14, JVM (17))
cats.instances.EitherInstances$$anon$2@6276ae34

rossabaker avatar May 14 '24 01:05 rossabaker