[Haskell-cafe] Re: Yet another IO initializer: Effectful declarations and an ACIO monad

George Russell ger at informatik.uni-bremen.de
Fri Nov 26 02:20:43 EST 2004


Ian Stark wrote (snipped):
 > Way back in this thread, Koen Claessen mentioned the idea of a commutative
 > version of the IO monad for handling things with identity.  That doesn't quite
 > do it, but I have a refinement that might.  The thing is to focus on IO
 > computations that are:
 >
 >  a) central -- their effect commutes with every other IO action
 >  b) affine  -- their effect is not directly observable, and can be discarded.

Unfortunately I have a number of examples where I use global variables with
initialisation actions which cannot conceivably be proven to be central & affine
by the compiler.  For example, where I want to call up an external program (such
as wish) which I will later use for doing graphics.

The Haskell libraries would run into a similar problem when they tried to
open stdin/stdout/stderr.  Or indeed when they tried to implement RandomGen,
which I presume is going to want to get at the system clock to seed the
random number generator.

My guess is that if we were to have top-level <- actions where the actions were
restricted to those certified to be ACIO, it would not be very long before GHC
would implement an unsafeForceACIO function ...



More information about the Haskell-Cafe mailing list