[Haskell] (no subject)

Simon Marlow simonmar at microsoft.com
Thu Oct 14 05:18:49 EDT 2004

On 13 October 2004 16:17, Wolfgang Thaller wrote:

> We could get away with "desugaring" them to some very "unsafe" non-IO-
> bindings and having the "module init action" do something evil to
> make the IO happen in the right order... should be possible to make
> that look exactly like mdo from the outside.
> We'll end up using the unsafePerformIO hack inside the implementation
> again, so that people end up with two IORefs instead of one, but that
> should be cheap enough:
> foo <- someAction
> ... could be transformed into ...
> foo_var = unsafePerformIO $ newIORef (throw NonTermination)
> foo_action = someAction >>= writeIORef foo_var
> foo = unsafePerformIO $ readIORef foo
> ... with the appropriate NOINLINEs.
> The module init action would then make sure that foo_action gets
> invoked. 

Yes, we could do that.  The fact that we're using NOCSE/NOINLINE
internally still seems very fragile, though.  Oh well, perhaps we have
to live with that if we don't want the pain of a special binding type
throughout the compiler.


More information about the Haskell mailing list