[make lots of library routines more strict, eta expand some IO routines, various performance fixes
John Meacham <john@repetae.net>**20061121100124] hunk ./lib/base/Foreign/Marshal/Alloc.hs 26
+import Jhc.IO
hunk ./lib/base/Foreign/Marshal/Alloc.hs 42
-allocaBytes num fn = case JO.target of
+allocaBytes num fn = etaIO $ case JO.target of
hunk ./lib/base/Foreign/Marshal/Alloc.hs 73
-alloca  = doAlloca undefined
-doAlloca       :: Storable a' => a' -> (Ptr a' -> IO b') -> IO b'
-doAlloca dummy  = allocaBytes (sizeOf dummy)
+alloca fn  = etaIO $ doAlloca undefined fn where
+    doAlloca       :: Storable a' => a' -> (Ptr a' -> IO b') -> IO b'
+    doAlloca dummy fn = allocaBytes (sizeOf dummy) fn
hunk ./lib/base/Foreign/Marshal/Alloc.hs 126
+reallocBytes ptr i | ptr `seq` i `seq` False = undefined
hunk ./lib/base/Foreign/Marshal/Array.hs 55
+import Jhc.IO
hunk ./lib/base/Foreign/Marshal/Array.hs 78
-allocaArray  = doAlloca undefined
-doAlloca            :: Storable a' => a' -> Int -> (Ptr a' -> IO b') -> IO b'
-doAlloca dummy size  = allocaBytes (size * sizeOf dummy)
+allocaArray  size fn = etaIO $ doAlloca undefined fn where
+    doAlloca            :: Storable a' => a' ->  (Ptr a' -> IO b') -> IO b'
+    doAlloca dummy fn = allocaBytes (size * sizeOf dummy) fn
hunk ./lib/base/Foreign/Marshal/Array.hs 108
-peekArray size ptr | size <= 0 = return []
-                 | otherwise = f (size-1) []
+peekArray size ptr | ptr `seq` (size <= 0) = return []
+                   | otherwise = f (size-1) []
hunk ./lib/base/Foreign/Marshal/Array.hs 127
+--pokeArray :: Storable a => Ptr a -> [a] -> IO ()
+--pokeArray ptr vals =  zipWithM_ (pokeElemOff ptr) [0..] vals where
+--    zipWithM_         :: (Monad m) => (a -> b -> m c) -> [a] -> [b] -> m ()
+--    zipWithM_ f xs ys =  sequence_ (zipWith f xs ys)
+
hunk ./lib/base/Foreign/Marshal/Array.hs 133
-pokeArray ptr vals =  zipWithM_ (pokeElemOff ptr) [0..] vals where
-    zipWithM_         :: (Monad m) => (a -> b -> m c) -> [a] -> [b] -> m ()
-    zipWithM_ f xs ys =  sequence_ (zipWith f xs ys)
+pokeArray ptr vals = pokeArray' ptr vals >> return ()
+
+pokeArray' :: Storable a => Ptr a -> [a] -> IO Int
+pokeArray' ptr vals =  etaIO $ f 0 vals where
+    f n [] | n `seq` True = return n
+    f n (x:xs) = pokeElemOff ptr n x >> f (n + 1) xs
+
hunk ./lib/base/Foreign/Marshal/Array.hs 146
-  pokeArray ptr vals
-  pokeElemOff ptr (length vals) marker
+  lv <- pokeArray' ptr vals
+  pokeElemOff ptr lv marker
hunk ./lib/base/Foreign/Marshal/Array.hs 181
-withArrayLen vals f  =
-  allocaArray len $ \ptr -> do
+withArrayLen vals f  = etaIO $
+  len `seq` allocaArray len $ \ptr -> do
hunk ./lib/base/Foreign/Marshal/Array.hs 197
-withArrayLen0 marker vals f  =
-  allocaArray0 len $ \ptr -> do
+withArrayLen0 marker vals f  = etaIO $
+  len `seq` allocaArray0 len $ \ptr -> do
hunk ./lib/base/Foreign/Marshal/Array.hs 234
-lengthArray0 marker ptr  = loop 0
+lengthArray0 marker ptr | ptr `seq` True  = etaIO $ loop 0
hunk ./lib/base/Foreign/Marshal/Array.hs 236
-    loop i = do
+    loop i | i `seq` True = do
hunk ./lib/base/Jhc/Enum.hs 44
-    enumFrom x       =  x:enumFrom (increment x)
+    enumFrom x  | x `seq` True     =  x:enumFrom (increment x)
hunk ./lib/base/Jhc/Enum.hs 48
-    enumFromThen x y = f x where
+    enumFromThen x y | x `seq` y `seq` True = f x where
hunk ./lib/base/Jhc/IO.hs 10
+    etaIO,
hunk ./lib/base/Jhc/IO.hs 45
+-- | this ensures the world parameter is eta expanded out
+{-# INLINE etaIO #-}
+etaIO :: IO a -> IO a
+etaIO x = IO $ \w -> unIO x w
+
hunk ./lib/base/Prelude.hs 609
-    enumFrom x  =  x:enumFrom (x + 1)
+    enumFrom x | x `seq` True =  x:enumFrom (x + 1)
hunk ./lib/base/Prelude.hs 613
-    enumFromThen x y = f x where
+    enumFromThen x y | x `seq` y `seq` True = f x where