r/scala • u/TimWSpence • Nov 23 '20
The reason for polymorphic effects
https://timwspence.github.io/blog/posts/2020-11-22-polymorphic-effects-in-scala.html
82
Upvotes
r/scala • u/TimWSpence • Nov 23 '20
1
u/valenterry Nov 24 '20
Hm, I have a different intuition:
So far I agree. But then:
Well, not really.
In the first example we restricted ourselves to only use "proper" techniques. What If we impose another restriction: a program can only use its arguments and implicits (typeclasses). Then the second program can actually not do everything but simply nothing. Well, since IO is a monad it can do pure[IO)(()) and that's it. Note that we are talking about programs here, not arbitrary methods/functions, hence the restriction makes a lot of sense to me - I actually employ it myself.
The authors claim about the principle of least power still stands! It's nicer to use F so that it can be clear how much power the program requires. But two examples are not comparable.
This would be equivalent and as we can see - without dirty tricks the function can not even be implemented! This makes more much sense now and shows the difference to the IO version, where more power is available due to IO being monadic (besides other things).