Hacker News new | past | comments | ask | show | jobs | submit login

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.



It's only surprising if you ascribe monadic properties to that syntax versus understanding it as literal syntactic sugar and absolutely nothing else.


I 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/RE...)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: