[Haskell-cafe] Just for a laugh...
dan.doel at gmail.com
Fri Jun 1 15:11:19 EDT 2007
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.
ref :: IORef a
ref = unsafePerformIO $ newIORef undefined
cast :: a -> b
cast a = unsafePerformIO $ do writeIORef ref a ; readIORef ref
*Main> cast 2 :: Double
More information about the Haskell-Cafe