3 ms·
Did you ever work with a list? Did you ever do things like foo = [bar(x) for x in quux] Or did you ever flatten a nested list? Congratulations, you've bee
by nine_k 12y ago
Did you ever work with a list? Did you ever do things like
foo = [bar(x) for x in quux]
Or did you ever flatten a nested list?
Congratulations, you've been using one of the most widespread monads.
Monads are not artificial constructs. Monads, like functions, or loops, or conditional statements, emerge naturally when you try to describe a computation, even a simple one. This is like speaking prose without knowing that.
- AnimalMuppet 12y agoNo, actually, I don't do things like that (see my parallel reply to codygman). The Haskell types often seem to think that the computing they do is the same as the computing that everybody else does, and therefore that the problems that they want to solve are the ones that everybody else wants to solve. That's not a very accurate assumption.
- nine_k 12y agoJust for reference: what are the kinds of problems you solve? Note that the code I quoted above is Python, and I have lots of stuff like that in my mundane production code (processing files, tracking transactions, counting money, etc).
- codygman 12y ago> The Haskell types often seem to think that the computing they do is the same as the computing that everybody else does Seeing as Haskell is used for general computing (including embedded software) the computing is the same. I know what you ate getting at, but I don't think it is based on facts or anything rational.
- dllthomas 12y agofoo = [bar(x) for x in quux] This is effectively a map, so it's strange to call it "using monads". "Using functors" would be more accurate. You can get "monad" out of list comprehensions though, when you have multiple "for" clauses. foo = [y for x in quux for y in bar(x)] seems equivalent to foo = quux >>= bar