OlivierBlanvillain
OlivierBlanvillain

Reputation: 7768

Type-class/implicit discoverability in Scala

In Scala, is there a way to "discover" all the type classes in scope; or more generally, all the implicits in scope? In ghci, :info Monad shows all the available Monads, and :info Maybe shows all the available type classes for Maybe, I wonder if something similar exists in the Scala.

Upvotes: 1

Views: 61

Answers (1)

dth
dth

Reputation: 2337

No, Scala does not have something like that. There are a few compiler options as "-Xlog-implicits" that print a bit more information, if implicits are not applicable. But there is nothing to list all implicits available in a certain context.

One could try to do this via macros, but even the macro api does not provide a direct way to do that. There is access to the typer via the compiler API and implicit search. But this API is very complicated.

Upvotes: 1

Related Questions