On Tue, Apr 09, 2002 at 11:06:14AM +0100, Simon Marlow wrote:
this usage of unsafePerformIO is such a staple of real-world Haskell
programming, it seems there should be some language (or experemental
compiler *wink wink ghc nudge*) support for it. I am not sure
what form
it would take
However, it is possible to have global top-level references using
unsafePerformIO if you're very careful about it. In GHC we
do something
like this:
{-# NOINLINE global_var #-}
global_var :: IORef Int
global_var = unsafePerformIO (newIORef 42)
the NOINLINE pragma is used
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
A while back I asked how to make the Ref's from Koen Clasessen's PhD
thesis Ord-able for the purpose of making them keys for efficient
finite maps.
Koen quickly responded with a clever implementation which attaches the
values to the keys. While I don't rule out eventually making use of