Can We Wean Scala Off Implicit Conversions?

I absolutely agree. I have personally converted the doobie library from using HLists + typeclasses for its SQL string interpolation to using magnet pattern (aka implicit constructors)

PRs: #1035 #1045

The resulting diff

+45 −155

Tells a lot about the benefits of these two approaches. And all that code was removed while the library gained more features than it had before – e.g. ability to nest SQL interpolations – and became much easier to understand.

Also, everyone again forgets the elephant in the room – implicit macro conversions. They can never be replaced by typeclasses, even dependently-typed, because they transform (trees of) values, not types. They are used by many libraries and DSLs, like sbt, quill, shapeless, refined, logstage and distage. I have written before and again on this forum how the not well thought-out introduction of Conversion typeclass may harm this pattern. Obviously removing conversions outright will harm it much more.

4 Likes