
1 Jun
2007
1 Jun
'07
7:11 p.m.
On Friday 01 June 2007, Andrew Coppin wrote:
David Roundy wrote:
Note also that you can use unsafePerformIO to safely get pure functions doing both these operations.
I've always been puzzled by this one... how does unsafePerformIO circumvent the type system? I don't understand.
import Data.IORef import System.IO.Unsafe ref :: IORef a ref = unsafePerformIO $ newIORef undefined cast :: a -> b cast a = unsafePerformIO $ do writeIORef ref a ; readIORef ref *Main> cast 2 :: Double -3.824225156758791e-48 *Main> -- Dan