GHC -O2 and unsafePerformIO

Neil Mitchell ndmitchell at gmail.com
Wed May 2 11:17:49 EDT 2007


Hi Bulat,

> Wednesday, May 2, 2007, 7:00:05 PM, you wrote:
> > {-# NOINLINE wrapIO #-}
> > wrapIO x = unsafePerformIO (x >>= return)
>
> -fno-cse ? it's usual company for unsafePerformIO+NOINLINE :)

No luck, alas. A slightly tweaked version, which is slightly simpler
and still gives the same behaviour is below.

Thanks

Neil


----------------------



main = p_System_IO_hGetChar undefined `seq` p_System_IO_hGetChar 12
`seq` putStrLn "done"

foreign import ccall "stdio.h getchar" getchar :: IO Word8

{-# NOINLINE p_System_IO_hGetChar #-}
p_System_IO_hGetChar h   = trace "i am here" $
    unsafePerformIO  (getchar >>= \c -> print c >> return (if c ==
(-1) then 0 else chr_ c))

chr_ = fromEnum


More information about the Glasgow-haskell-users mailing list