[Haskell-cafe] puzzling polymorphism behavior (7.0.3 windows)

gladstein at gladstein.com gladstein at gladstein.com
Thu Mar 15 17:53:34 CET 2012


Why does the following program compile and produce the results it does?
It seems like 3 and "x" got interpreted as the same type, (). Thanks in
advance for your help.
 
import Data.IORef
import System.IO.Unsafe

cell = unsafePerformIO $ newIORef []

push i = modifyIORef cell (++ [i])

main = do
 push 3
 push "x"
 readIORef cell >>= return

*Main> :browse
cell :: GHC.IORef.IORef [a]
push :: a -> IO ()
main :: IO [a]

*Main> main
[(),()]





More information about the Haskell-Cafe mailing list