[Haskell-cafe] unsafePerformIO: are we safe?

Jonathan Cast jcast at ou.edu
Wed Sep 26 17:44:40 EDT 2007

On Wed, 2007-09-26 at 14:28 -0700, Dan Piponi wrote:
> On 9/26/07, Lennart Augustsson <lennart at augustsson.net> wrote:
> > Things can go arbitrarily wrong if you misuse unsafePerformIO, you can even
> > subvert the type system.
> So...if I was in a subversive kind of mood (speaking hypothetically),
> what would I have to do?

unsafeCoerce :: a -> b
unsafeCoerce a = unsafePerformIO $ do
  let ref = unsafePerformIO $ newIORef undefined
  ref `writeIORef` a
  readIORef ref


More information about the Haskell-Cafe mailing list