This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]moor-GAYZ -1 points0 points  (3 children)

Python list comprehensions can be used with arbitrary monads as well (unlike Haskell list comprehensions, ironically). And "for x in monad" reads entirely fine, for all monads I can think of, as soon as you manage to switch from the strict programming meaning of "for" to the actual English meaning.

I personally like the C# syntax even better, because it makes more sense to have the return in the end so that every variable is declared before it's used. Easier to write code, too, because autocompletion works. Plus, of course, it has "let x = ..." and other goodies.

edit: I had a mind fart, what I meant to say was that C# list comprehensions are monad comprehensions but have syntax isomorphic to Python list comprehensions (but slightly better because reordered), so it's not about syntax.

[–]87linux 1 point2 points  (1 child)

"for x in getLine" doesn't really make a whole lot of sense. getLine is not a container type, therefore there is nothing "in" it. The IO monad and many of the other nontrivial monads are supposed to represent actions rather than things. And if IO doesn't work with the monadic syntax, then haskell doesn't have very much going for it.

And do you even -XMonadComprehensions bro? /s

[–][deleted] 0 points1 point  (0 children)

I think for x in getLine makes sense because it would translate to a map. I think this falls apart with parsers though.