unsafeLocalState = unsafeDupablePerformIO?

Simon Marlow marlowsd at gmail.com
Fri Jul 8 10:17:47 CEST 2011

We currently have

   Foreign.Marshal.Unsafe.unsafeLocalState :: IO a -> a
   unsafeLocalState = unsafePerformIO

however, unsafePerformIO in GHC is rather expensive, because it tries to 
avoid the IO being executed more than once when there are multiple 
processors.  However, for the cases that we claim unsafeLocalState is to 
be used for, it would be safe to use the cheaper unsafeDupablePerformIO 

The only way to get at unsafeDupablePerformIO currently is from GHC.IO, 
this would give users a legitimate way to get at a cheaper unsafePerformIO.

Or perhaps we should just export unsafeDupablePerformIO from 
System.IO.Unsafe?  Thoughts?


More information about the Libraries mailing list