[Haskell-cafe] Current situation regarding global IORefs

Brian Hulley brianh at metamilk.com
Sat Apr 29 14:26:06 EDT 2006

Adrian Hey wrote:
> Brian Hulley wrote:
>> The use of a plain value to initialize the ref rather than a monadic
>> computation would ensure that there would be no problems with trying
>> to work out which order to initialize top level refs that are
>> dependent on values of refs in other modules since there could be no
>> dependencies.
> I'm not sure what problem you see with the ACIO monad proposal. It
> was designed to prevent the kind of ordering dependency problems
> which (I think) you're refering to. You can't read or write
> IORefs/MVars or do any other "real IO" operation from ACIO.
> All you can do is create them (and more complex data structures
> based on them). So they could be evaluated at compile time, in
> principle (AFAICS etc..). I think it should also be possible to
> fork threads from ACIO, provided you arrange that they're initially
> blocked on an empty MVar or something.
> If it turns out that that isn't enough to properly initialise them
> (like you need to do real IO), then you just can't have them as
> top level identifiers. But you can still use something like the
> "oneShot" function to implement "get" actions at the top level (in
> the IO monad).

I was thinking that there would be a problem with polymorphic refs but now I 
think I understand that there would not be a problem, seeing the description 
of ACIO in 
where it is clear that the ACIO actions are just prepended to main.

So I'll retract my proposal in favour of ACIO :-)

Regards, Brian.

More information about the Haskell-Cafe mailing list