[Haskell-cafe] ACIO versus Execution Contexts

Adrian Hey ahey at iee.org
Wed Dec 1 07:42:11 EST 2004


On Tuesday 30 Nov 2004 9:19 pm, Benjamin Franksen wrote:
> I don't get it: How can they be top-level without scoping over an entire
> module? I mean, the proposal was to have
>
> x <- action
>
> at the top-level, right? Then how can it not be visible in the whole
> module? What scope *does* it have, in your opinion?

x scopes over an entire module, and may be reasonably described as "global"
if x is exported. But in this example..

 userInit <- oneShot realInit

oneShot creates a top level MVar which is only accessible via userInit
and no other function, so it doesn't even scope over an entire module
and is certainly not exportable.

With the ACIO monad the type of oneShot would be..

 oneShot :: IO a -> ACIO(IO a)

If userInit is exported, it could reasonably be described as "global",
but this doesn't matter because as far as users are concerned it's just
a perfectly ordinary side-effectful, state manipulating IO function that
works it's magic by unknown means. There's no reason for them to know
or care that the some of the state it manipulates is top-level Haskell
state rather than "real world" state, and there's no possibility of
anybody getting at the underlying MVar and accidently corrupting it.
The only way it can be got at is by executing userInit.

Regards
--
Adrian Hey



More information about the Haskell-Cafe mailing list