4 ms·
What is the point of implementing monads in Python? I thought the point of monads was that they provide a mechanism for introducing side effects gracefully int
by ddellacosta 12y ago
What is the point of implementing monads in Python? I thought the point of monads was that they provide a mechanism for introducing side effects gracefully into a pure language (like, say, Haskell) while still allowing for type safety, per correspondences between category theory and type theory. Python is not strictly typed and makes side effects pretty easy, if I recall from the last time I wrote Python.
Seriously, what is this constant obsession with monads that has infected the programmers?
Why not be obsessed with, say, functors? I can then make statements like, "A functor is a wrapper. Anyone who tells you otherwise is being obtuse" and be just as correct, and sound just as smart.
wanders off grumbling to himself...
- zak_mc_kracken 12y agoMonads are not just about effects: encoding effects in the type system is just one of the benefits. Monads are mostly about enabling composition between operations returning different types.
- freyrs3 12y ago> I thought the point of monads was that they provide a mechanism for introducing side effects gracefully into a pure language That's roughly a description of the IO monad, which is a specific monad. The IO monad is really a degenerate case, and most monads ( List, Cont, Maybe, Writer, State, ... ) have nothing to do with effects. Half the problem of talking about monads is that in their full generality they're really just a description of a trivial algebraic structure that doesn't really impart much intuition. Monads just get a lot of press because they're one of the simplest examples of a structure that can't be compressed easily in terms of common experience. There's nothing I can point to in our our everyday experience and say "monad" is like this.