
On Thu, May 17, 2007 at 07:25:03PM +0100, Adrian Hey wrote:
The above hack is not actually Haskell. It's a hack, and it depends on the particular implementation characteristics of GHC. It is not unreasonable to imagine that a future GHC might contain different compilation techniques (I hesitate to use the word 'optimisations' because that sounds like something easy to turn off) which invalidate the technique in other ways or make it dangerous.
Well of course, that's why something needs to be done about this. Just being in a state of complete denial regarding the reality of this problem won't make it go away.
Indeed, I made a proposal a while ago to allow top level IO actions, foo <- newIORef "foo" which are quite straigtforward, and would not even be inconsistant in the view of the type system, as <- bindings are always monomorphic anyway. Others pointed out that if we allow arbitrary IO actions, it could cause undesirable things like causing importing a mobule to change program behavior, or expose implementatino details, like when these are executed, right away or lazily. The solution was to have a special restricted version of IO containing only those actions that are "safe". like newMVar etc.. where safe means more or less commutative and omittable. this doesn't require any special support, just a newtype ACIO a = ACIO (IO a) deriving(Monad,Functor) and then have a module only export the trusted things in the ACIO monad. John -- John Meacham - ⑆repetae.net⑆john⑈