Remove Control.Parallel*, now in package parallel
[haskell-directory.git] / Foreign / Marshal / Alloc.hs
index dbd3644..8a89467 100644 (file)
@@ -1,4 +1,4 @@
-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS_GHC -fno-implicit-prelude #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Foreign.Marshal.Alloc
@@ -51,6 +51,8 @@ import Control.Exception      ( bracket )
 #endif
 
 #ifdef __HUGS__
+import Hugs.Prelude            ( IOException(IOError),
+                                 IOErrorType(ResourceExhausted) )
 import Hugs.ForeignPtr         ( FinalizerPtr )
 #endif
 
@@ -68,7 +70,7 @@ import Hugs.ForeignPtr                ( FinalizerPtr )
 malloc :: Storable a => IO (Ptr a)
 malloc  = doMalloc undefined
   where
-    doMalloc       :: Storable a => a -> IO (Ptr a)
+    doMalloc       :: Storable b => b -> IO (Ptr b)
     doMalloc dummy  = mallocBytes (sizeOf dummy)
 
 -- |Allocate a block of memory of the given number of bytes.
@@ -91,7 +93,7 @@ mallocBytes size  = failWhenNULL "malloc" (_malloc (fromIntegral size))
 alloca :: Storable a => (Ptr a -> IO b) -> IO b
 alloca  = doAlloca undefined
   where
-    doAlloca       :: Storable a => a -> (Ptr a -> IO b) -> IO b
+    doAlloca       :: Storable a' => a' -> (Ptr a' -> IO b') -> IO b'
     doAlloca dummy  = allocaBytes (sizeOf dummy)
 
 -- |@'allocaBytes' n f@ executes the computation @f@, passing as argument
@@ -131,7 +133,7 @@ allocaBytes size  = bracket (mallocBytes size) free
 realloc :: Storable b => Ptr a -> IO (Ptr b)
 realloc  = doRealloc undefined
   where
-    doRealloc           :: Storable b => b -> Ptr a -> IO (Ptr b)
+    doRealloc           :: Storable b' => b' -> Ptr a' -> IO (Ptr b')
     doRealloc dummy ptr  = let
                             size = fromIntegral (sizeOf dummy)
                           in
@@ -173,8 +175,8 @@ failWhenNULL :: String -> IO (Ptr a) -> IO (Ptr a)
 failWhenNULL name f = do
    addr <- f
    if addr == nullPtr
-#ifdef __GLASGOW_HASKELL__
-      then ioException (IOError Nothing ResourceExhausted name 
+#if __GLASGOW_HASKELL__ || __HUGS__
+      then ioError (IOError Nothing ResourceExhausted name 
                                        "out of memory" Nothing)
 #else
       then ioError (userError (name++": out of memory"))