[Haskell] Re: Global Variables and IO initializers

Keean Schupke k.schupke at imperial.ac.uk
Mon Nov 8 05:52:39 EST 2004


Krasimir Angelov wrote:

>Note that 2-rank type of runSTInit doesn't allow to
>execute regular IO actions. Even that (ST s a) allows
>actions like readRef and writeRef. This allows to
>initialise local references but doesn't allow to
>access other toplevel reverences since they are bound
>to RealWorld state.
>  
>
The proposal for merging ST and IO for refernce creation
seems sound. I would like to point out that this does not
address Adrian's problem as his example was that of
initialising hardware which would require real IO
actions.

Also the gain from this seems small as I can already write:

ref = newSTRef 0

and then I can use this safely from in the ST monad or
the IO monad using "stToIO" - so using STRefs instead of
IORefs would be as flexible as the proposal.

    Keean.


More information about the Haskell mailing list