Hi!

The following program dumps core on execution (compiled with ghc-4.04):

\begin{code}
{-# OPTIONS -fglasgow-exts #-}
import IO
import IOExts

{-# notInline test #-}
test :: IORef [a]
test = unsafePerformIO $ newIORef []

main = do
    writeIORef test [42]
    bang <- readIORef test
    print (bang :: [Char])
\end{code}

The problem cause is clear, but is there a way to make the RTS (or type
system) smarter, i.e. not just dumping core (besides from not using IORefs
*this* way ;-))?

The problem is, that these errors may be hard to track down, if the program
dumps core occasionally. For example, the following works without core-dump:

\begin{code}
main = do
    writeIORef test [42]
    writeIORef test "NO BANG"
    bang <- readIORef test
    print (bang :: [Char])
\end{code}


Cheers,
Michael
-- 
If builders built buildings the way programmers wrote programs, then the
first woodpecker that came along would destroy civilization.
                                -- Gerald Weinberg

Reply via email to