An answer and a question to GHC implementors [was Re: How to make Claessen's Refs Ord-able?]

David Feuer dfeuer@cs.brown.edu
Tue, 9 Apr 2002 06:59:07 -0400


On Tue, Apr 09, 2002, Simon Marlow wrote:
> <muse>
> I did wonder once whether IO monad bindings should be allowed at the
> top-level of a module, so you could say
> 
>      module M where
>      ref <- newIORef 42
> 
> and the top-level IO would be executed as part of the module
> initialization code.  This solves the problems with unsafePerformIO in a
> cleanish way, but would add some extra complexity to implementations.
> And I'm not sure what happens if one top-level IO action refers to other
> top-level IO bindings (modules can be recursive, so you could get loops
> too).
> </muse>

First-class modules could (I believe) solve this problem quite neatly.

David