[Haskell-cafe] Portable implementation of unsafeCoerce

Alfonso Acosta alfonso.acosta at gmail.com
Tue Feb 6 10:58:28 EST 2007


Hi all,

Reading the sources of Lava (a Haskell Hardware Description DSL) I run
into this definition ...


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

Is this actually equivalent to the infamous unsafeCoerce# ?


Thanks in advance,

Alfonso Acosta


More information about the Haskell-Cafe mailing list