[Haskell] threading mutable state through callbacks

Adrian Hey ahey at iee.org
Tue Oct 12 09:08:10 EDT 2004


On Tuesday 12 Oct 2004 1:44 pm, Vincenzo Ciancia wrote:
> On Tuesday 12 October 2004 12:23, Adrian Hey wrote:
> >  I don't know what more
> > general-purpose extension you have in mind, but couldn't you just
> > borrow from do syntax at the top level
>
> I think that the problem is with the order of execution of these
> bindings. For example ghci supports top-level "let x <- something"
> declarations, but the haskell compiler does not have to respect any
> order of execution, which would instead be forced. The general purpose
> extension could however require the same proof obligations of
> unsafeInterleaveIO, but how do we deal with
>
> 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).

If ordering is significant (due to important side effects say) then
it can be controlled with `seq` I think.

But I think something ought to be done about it. Having to use
unsafePerformIO to do something that ought to be perfectly safe
is just embarrassing I think :-)

There's also the type security issues that Marcin was talking about,
but I don't see why that can't be addressed with appropriate
constraints which are enforced at compile time.

Regards
--
Adrian Hey



More information about the Haskell mailing list