
-----Original Message----- From: Jeff Newbern [mailto:jnewbern@nomaware.com]
Alistair,
Hhhmmm. That is an interesting issue, and I am unsure how to treat it in the tutorial. I did attempt to explain the ability of the monad to isolate impure computations, but I think I need to make a better explanation of what an action is and how it is used.
As for the question of whether using a monad in this way casts Haskell out of the ranks of the functionally pure, I don't know. This feels to me like a debate over personal interpretation, with decent arguments on both sides. I think the most accurate thing to say is that it enables Haskell to incorporate non-pure features without destroying the purity of the core of the language.
The interesting point for me is: you can't escape from the IO monad, but you can from others. You can use non-IO functions from IO functions, but you can't use IO functions from non-IO functions. AFAICT, this is not true of all monads; as Wolfgang said, you can write a function that uses monadic values but returns a non-monadic ("pure") value. You (sort of) explain this in the first two paragraphs of "No way out", but things that might help are: - two example lists: of one-way monads (IO), and others (List, Maybe) - non-monadic function using monadic values ( http://www.nomaware.com/monads/html/listmonad.html#example )
Any suggestions for how best to present this issue to a reader who may be new to the world of FP? Should we mention it at all?
I think you should mention it in a monad tutorial, hence the request. It will help (has helped) me understand a little more about monads. ***************************************************************** The information in this email and in any attachments is confidential and intended solely for the attention and use of the named addressee(s). This information may be subject to legal professional or other privilege or may otherwise be protected by work product immunity or other legal rules. It must not be disclosed to any person without our authority. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are not authorised to and must not disclose, copy, distribute, or retain this message or any part of it. *****************************************************************