Re:Scala Days Recap and Why the Free Monad Isn’t Free
by platz on Wednesday July 27, 2016 @11:14AM
(#12173472)
> Type class instance parameters must be explicit in Scala
In Scala, wouldn't this be solved with implicits? i.e. implicit 'instances' are in Singleton Objects that one simply brings into scope with an import.
Re:Scala Days Recap and Why the Free Monad Isn’t Free
by roberthensing on Tuesday August 09, 2016 @11:26AM
(#12255216)
In Scala, the implicit arguments are implicit, yes, but the parameter is not. You will have to declare the implicit parameter, even if you omit a type signature.
I think I forgot to mention the lack of type class coherence. That's also something you should be aware of when you start using type classes.
However, if you really want to introduce this complexity in Scala, you will probably first write some nice high-level code, then discover that it causes a stack overflow, then have to learn about the TailRec monad, figure out how to stack your (free-like) monad on top of it, therefore learn monad transformers, which you probably wanted to avoid by using a free-like monad. A library may solve part of the problem for you, but you will have to be aware of your own stack usage all the time. And when it works you should tune your JVM garbage collector for many (many) short-lived objects.
I would either keep it simple in Scala or choose a language that supports this kind of abstraction in a less painful way.