unsafePerformIO safety.

Isaac Dupree isaacdupree at charter.net
Tue Mar 6 18:25:57 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Brown wrote:
> I've noticed quite a few pages referencing constructs such as:
> 
>   var :: MVar ([Foo])
>   var = unsafePerformIO (newMVar ([]))
> 
> and the likes.  Is there a danger of different uses of 'var' getting
> new MVars instead of all sharing one.

If I remember correctly, you "should" put {-# NOINLINE var #-} on a line
just before that.

> 
> Having a reliable way to create a piece of global state would be very
> convenient.

This is well known and extensively discussed - unfortunately it is a
complicated (or at least controversial) issue

Isaac

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF7fiFHgcxvIWYTTURAoMXAJ9SCryCX+daNLKrMIhWlMh/aJmVXwCghosx
6/lBweYnNslHLal57RAtX0Y=
=2oIN
-----END PGP SIGNATURE-----


More information about the Glasgow-haskell-users mailing list