Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find used implicits in the Scala REPL

Tags:

scala

scalaz

I often find a neat solution to a problem by using Scalaz pimps. Usually the solution works like

import scalaz._
import Scalaz._
foobar frobnicate quux
// magic

Now, I would like to be able to see what implicits I have actually used to add to my Foobar a frobnicate method. In this way I can make a more refined import and learn something new about the tool I have implicitly used.

Is there some way to find out what implicit conversions the compiler actually used to compile some expression?

like image 467
Andrea Avatar asked Feb 20 '23 02:02

Andrea


1 Answers

You can also see the fully expanded version of your code using the -Xprint:typer option to scalac. In a sbt project, one can add the line

scalacOptions += "-Xprint:typer"

to build.sbt and see the result with the compile commmand.

(taken from the answer linked by retronym)

like image 51
Andrea Avatar answered Feb 23 '23 01:02

Andrea