4 ms·
Re: implicits - just try doing anything in cats. The whole thing is hugely based on implicits, which you need to import with magical import invocations (which o
by killtimeatwork 6y ago
Re: implicits - just try doing anything in cats. The whole thing is hugely based on implicits, which you need to import with magical import invocations (which of course the compiler has no way of suggesting to you).
- sideeffffect 6y ago> the compiler has no way of suggesting to you Of course it does. And since Scala 3, it does suggest to you the imports you need for implicits. And IntelliJ does recommend imports even for Scala 2. Regarding cats, the codebase has been restructured, so that you won't need the implicit imports (or not as much at least): https://meta.plasm.us/posts/2019/09/30/implicit-scope-and-cats/ https://meta.plasm.us/posts/2019/09/30/implicit-scope-and-ca... The trick there is that the Type class instances were moved to appropriate companion objects which are searched by the compiler by default and thus the used doesn't need to do any manual imports.
- hocuspocus 6y agoHere you go: `import cats.implicits._` Done. And once you start understanding the typeclass hierarchy a little bit, finding the specific syntax and instances comes pretty naturally.
- vvillena 6y agoThinking of "implicits" as one single feature can be extremely confusing. OP is talking about "implicit conversions", which transform values from one type to another automatically just by being in scope. Cats imports bring in "implicit classes", which are a way to extend existing types with new methods, in a way that works even with parametric types in a type-safe way. That's the way to get ad-hoc polymorphism (aka typeclasses) in Scala.