Chris Angelico wrote:
You can take your original set-builder monad and turn it into genuinely functional code; show me that you can do the same with I/O. Otherwise, what you're really saying is "we can cheat until we can do I/O", not "we can do I/O in a functional way".
I don't think I'm saying either of those things. What I'm saying is, monads provide a way of reasoning algebraically about sequential programs. The things being reasoned about -- the actions -- are not themselves functions, but that doesn't mean there's any cheating going on. Would you say it was cheating to perform algebraic manipulations on an expression involving numbers or strings? Why should it be any different when the things being manipulated represent actions that affect the world? I may not have brought this point out as clearly as I could have in the essay. Looking back, I can see that the phrase "perform I/O in a functional way" is open to misinterpretation. I didn't mean to say that we can write a function (in the mathematical sense) that performs I/O, only that we can apply functional techniques if we represent I/O in a particular way. If you still want to call that "cheating" I can't stop you, but I think you're directing your scorn at an imagined claim that functional programmers are not actually making. In so doing you risk missing potential benefits of what they actually are claiming. -- Greg -- https://mail.python.org/mailman/listinfo/python-list