Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> But Python doesn't have any concept of a monad, so what would do-notation even be in Python?

It could work on the same things that Python's current list comprehensions work on. I'm just suggesting a different syntax. Comprehensions in Haskell originally worked for all monads too.

> And who is the "everyone" using do-notation? I don't see any analogous syntax in Lua, Javascript, Ruby, or Perl.

I meant that within Haskell, everyone uses do notation rather than comprehensions.

> The existing syntax is meant to mirror the syntax of a nested for loop. I agree that maybe it's confusing, but if you want to go from a multi-for comprehension to an actual nested for loop, then you don't have to invert the order.

You have to invert half of it, which I find more confusing than having to completely invert it. do-notation style syntax (e.g. Scala-style for/yield) would keep the order completely aligned.



> Comprehensions in Haskell originally worked for all monads too.

And that behaviour is still accessible via a compiler extension.


Idris 2 still has both "monad comprehensions" and an applicative equivalent called "idiom brackets".

https://idris2.readthedocs.io/en/latest/tutorial/interfaces....

https://idris2.readthedocs.io/en/latest/tutorial/interfaces....




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

Search: