[Haskell] threading mutable state through callbacks

Jules Bean jules at jellybean.co.uk
Tue Oct 12 13:28:41 EDT 2004


On 12 Oct 2004, at 14:08, Adrian Hey wrote:

>> x <- someAction
>> y <- someAction(x)
>
> I would say keep things as they currently are with the unsafePerformIO
> solution, I.E. Order unspecified, the action that creates a particular
> top level thing is executed only once, when the value of thing is
> demanded (perhaps not at all).
>

Also consider the case of

z = someAction(y)

Here z is a value outside the IO monad, calculated using a function 
outside the IO monad, based on a value (y) which also lies outside the 
IO monad... What sane semantics will explain when the actions which led 
to the value y should be taken?

I think what people are trying to suggest is an 'initialization phase' 
in the IO monad, which takes place "before" the pure functions are 
defined. At compile time, conceptually. I don't have any clear idea how 
that should be made precise.

Jules



More information about the Haskell mailing list