4 ms·
I mean if you write something like: (for { x <- List(1, 1, 1) y <- Set(x) z <- List(y, y) } yield z).length the answer will be rathe
by lmm 9y ago
I mean if you write something like:
(for {
x <- List(1, 1, 1)
y <- Set(x)
z <- List(y, y)
} yield z).length
the answer will be rather surprising, because in Scala for/yield is not necessarily monadic.
- ionforce 9y agoIt's only surprising if you ascribe monadic properties to that syntax versus understanding it as literal syntactic sugar and absolutely nothing else.
- clhodapp 9y agoI would say: it is `Set` and `List` that are wrong in that example, not `for`. That said, `for` really does have some issues (enter https://github.com/oleg-py/better-monadic-for/blob/master/README.md https://github.com/oleg-py/better-monadic-for/blob/master/RE...)