GHC -O2 and unsafePerformIO
Simon Marlow
simonmarhaskell at gmail.com
Thu May 3 03:57:25 EDT 2007
Neil Mitchell wrote:
> Hi
>
> Thanks to dcoutts, I have now come up with an answer. I don't
> understand why it works now, but not before. I do remember than
> browsing either Core or STG is not a fun thing to do...
>
> p_System_IO_hGetChar h = trace "i am here" $
> unsafePerformIO $ getCharIO h
>
>
> {-# NOINLINE getCharIO #-}
> getCharIO h = do
> c <- getchar
> print c
> return $ if c == (-1) then 0 else chr_ c
This is clearly a misuse of unsafePerformIO (as I'm sure you're aware). Just
out of interest - what's the context?
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list