[add newWorld__ and drop__ primitives to avoid the pulling of the world into a CAF.
John Meacham <john@repetae.net>**20060216042844] hunk ./DataConstructors.hs 118
+getConstructor n (DataTable dt) | n == tc_World__, Just c <- Map.lookup n dt = return c { conChildren = Nothing }
hunk ./Grin/FromE.hs 299
+    ce (EPrim ap@(APrim (PrimPrim "newWorld__") _) [_] _) = do
+        return $ Return world__
+    ce (EPrim ap@(APrim (PrimPrim "drop__") _) [_,e] _) = ce e
hunk ./Grin/FromE.hs 427
+    cc (EPrim (APrim (PrimPrim "newWorld__") _) [_] _) = return $ Return pworld__
+    cc (EPrim (APrim (PrimPrim "drop__") _) [_,e] _) = cc e
hunk ./lib/Jhc/Array.hs 3
+import Jhc.IO(World__,newWorld__)
hunk ./lib/Jhc/Array.hs 9
-data AT a
+newtype AT a = AT (Array__ -> Array__)
hunk ./lib/Jhc/Array.hs 11
+seqAT__ :: AT a -> AT a -> AT a
+seqAT__ (AT a1) (AT a2) = AT $ \a -> a2 (a1 a)
hunk ./lib/Jhc/Array.hs 14
+doneAT__ :: AT a
+doneAT__ = AT id
hunk ./lib/Jhc/Array.hs 17
--- none of these routines have run-time checks
-foreign import primitive "newAT__" :: Int -> AT a -> Array__ a
-foreign import primitive "writeAT__" :: Int -> a -> AT a
-foreign import primitive "seqAT__" :: AT a -> AT a -> AT a
-foreign import primitive "doneAT__" :: Int -> a -> AT a
+newAT__ :: Int -> AT a -> Array__ a
+newAT__ n (AT a1) = a1 (prim_newAT__ (newUnique__ a1) n)
hunk ./lib/Jhc/Array.hs 20
+writeAT__ :: Int -> a -> AT a
+writeAT__ i x = AT $ \a -> prim_writeAT__ i x a
hunk ./lib/Jhc/Array.hs 23
+-- none of these routines have run-time checks
+foreign import primitive "prim_newAT__" :: World__ -> Int -> Array__
+foreign import primitive "prim_writeAT__" :: Int -> a -> Array__ -> Array__
hunk ./lib/Jhc/Array.hs 35
+
hunk ./lib/Jhc/IO.hs 6
+-- this is treated specially by the compiler. it won't treat it as a product type.
hunk ./lib/Jhc/IO.hs 8
-    deriving(Show)
hunk ./lib/Jhc/IO.hs 14
-unsafePerformIO (IO x) = case x World__ of
+unsafePerformIO (IO x) = case x (newWorld__ x) of
hunk ./lib/Jhc/IO.hs 55
---foreign import primitive unsafeCoerce :: a -> b
hunk ./lib/Jhc/IO.hs 56
+-- | this creates a new world object that artificially depends on its argument to avoid CSE.
+foreign import primitive newWorld__ :: a -> World__
hunk ./lib/Jhc/IO.hs 59
+-- throws away first argument. but causes second argument to artificially depend on it.
+foreign import primitive drop__ :: forall a b. a -> b -> b
hunk ./lib/Jhc/IO.hs 62
-{-
-data World__ = World__
hunk ./lib/Jhc/IO.hs 63
-data IO a = IO (World__ -> (World__,a))
-unIO (IO x) = x
-
-unsafePerformIO :: IO a -> a
-unsafePerformIO (IO x) = case x World__ of (_,z) -> z
---unsafePerformIO (IO x) = snd $ x undefined
-
-unsafeInterleaveIO :: IO a -> IO a
-unsafeInterleaveIO (IO m) = IO f where
-    f w = (w,case m w of (_,r) -> r)
--}