On Thu, Nov 25, 2004 at 12:49:13AM +0100, Benjamin Franksen wrote: > On Thursday 25 November 2004 00:38, Ben Rudiak-Gould wrote: > > John Meacham wrote: > > >With my mdo proposal, and I think all proposals brought forth, the > > >module system behaves identically to how it normally does for > > >namespace control. [...] modules do not change code at all, they > > >are pure syntantic sugar for deciding what names you can see. > > > > I'm not sure I understand your mdo proposal correctly then. A lot of > > this debate has been over what should happen when a module has a > > top-level action like > > > > x <- putStrLn "hello" > > > > Everyone agrees that "hello" should be printed at most once, [...] > > And I thought at least everyone agreed that things like that should not be > allowed. Instead, only a "safe" subset of things that are currently in IO > should be allowed to appear at the top-level, such as creation of mutable > reference cells.
Yes. I think such things should not be 'exported' by the default mechanism. just how that can be enforced by a library is an interesting technical issue. My current thinking is newtype InitIO a = InitIO (IO a) deriving(Monad) liftIO :: IO a -> InitIO a newInitIORef :: a -> InitIO (IORef a) newInitMVar ... then have x <- foo execute foo in the InitIO monad. The nice thing about this is that the 'hiding' mechanism is the normal haskell module system! by only exporting 'safe' IO actions as InitIO we effectivly enforce sane style while system programmers can go in and create new InitIO's as appropriate with liftIO. This is exactly equivalant to how the IO monad itself is handled. you get it abstractly by default, but if you know what you are doing you can extract out the RealWorld component in order to extend its functionality. I belive the only disadvantge to this scheme is the addition of another special name used in desugaring 'InitIO', however all the other proposals which involved limiting the set of initalization actions involved the same thing. (CIO, SafeIO, etc...) John -- John Meacham - ârepetae.netâjohnâ _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell