         else f rBand
 
 foreign import ccall unsafe "gdal.h GDALGetRasterBand" getRasterBand
-        :: (Ptr (Dataset a)) -> (CInt -> (IO (Band)))
-
-
-{# fun pure unsafe GDALGetRasterDataType as bandDatatype
-   { id `Band'} -> `Datatype' toEnumC #}
-
-bandBlockSize :: Band -> (Int,Int)
-bandBlockSize band = unsafePerformIO $ alloca $ \xPtr -> alloca $ \yPtr ->
+        :: (Ptr (Dataset a)) -> (CInt -> (IO ((Band a))))
+
+
+bandDatatype :: Band a -> Datatype
+bandDatatype band = toEnumC . getDatatype_ $ band
+
+foreign import ccall unsafe "gdal.h GDALGetRasterDataType" getDatatype_
+   :: Band a -> CInt
+
+
+bandBlockSize :: Band a -> (Int,Int)
+bandBlockSize band = unsafePerformIO $ alloca $ \xPtr -> alloca $ \yPtr -> do
    -- unsafePerformIO is safe here since the block size cant change once
    -- a dataset is created
-   {#call unsafe GDALGetBlockSize as ^#} band xPtr yPtr >>
+   getBlockSize_ band xPtr yPtr
    liftA2 (,) (liftM fromIntegral $ peek xPtr) (liftM fromIntegral $ peek yPtr)
 
-bandBlockLen :: Band -> Int
+foreign import ccall unsafe "gdal.h GDALGetBlockSize" getBlockSize_
+    :: Band a -> Ptr CInt -> Ptr CInt -> IO ()
+
+
+bandBlockLen :: Band a -> Int
 bandBlockLen = uncurry (*) . bandBlockSize
 
-bandSize :: Band -> (Int, Int)
+bandSize :: Band a -> (Int, Int)
 bandSize band
-  = ( fromIntegral . {# call pure unsafe GDALGetRasterBandXSize as ^#} $ band
-    , fromIntegral . {# call pure unsafe GDALGetRasterBandYSize as ^#} $ band
-    )
-
-bandNodataValue :: Band -> IO (Maybe Double)
+  = (fromIntegral . getXSize_ $ band, fromIntegral . getYSize_ $ band)
+
+foreign import ccall unsafe "gdal.h GDALGetRasterBandXSize" getXSize_
+  :: Band a -> CInt
+
+foreign import ccall unsafe "gdal.h GDALGetRasterBandYSize" getYSize_
+  :: Band a -> CInt
+
+
+bandNodataValue :: Band a -> IO (Maybe Double)
 bandNodataValue b = alloca $ \p -> do
-   value <- liftM realToFrac $ {#call unsafe GDALGetRasterNoDataValue as ^#} b p
+   value <- liftM realToFrac $ getNodata_ b p
    hasNodata <- liftM toBool $ peek p
    return (if hasNodata then Just value else Nothing)
    
-{# fun GDALSetRasterNoDataValue as setBandNodataValue
-   { id `Band', `Double'} -> `Error' toEnumC #}
-
-{# fun GDALFillRaster as fillBand
-    { id `Band', `Double', `Double'} -> `Error' toEnumC #}
+foreign import ccall unsafe "gdal.h GDALGetRasterNoDataValue" getNodata_
+   :: Band a -> Ptr CInt -> IO CDouble
+   
+
+setBandNodataValue :: RWBand -> Double -> IO ()
+setBandNodataValue b v = throwIfError "could not set nodata" $
+                            setNodata_ b (realToFrac v)
+
+foreign import ccall safe "gdal.h GDALSetRasterNoDataValue" setNodata_
+    :: RWBand -> CDouble -> IO CInt
+
+
+fillBand :: RWBand -> Double -> Double -> IO ()
+fillBand b r i = throwIfError "could not fill band" $
+    fillRaster_ b (realToFrac r) (realToFrac i)
+
+foreign import ccall safe "gdal.h GDALFillRaster" fillRaster_
+    :: RWBand -> CDouble -> CDouble -> IO CInt
+
 
 class HasDatatype a where
     datatype :: a -> Datatype

            (fromIntegral pxs)
            (fromIntegral lns)


data Block where
    Block :: (Typeable a, Storable a) => Vector a -> Block

           then throw $ GDALException CE_Failure "wrongly typed vector"
           else withForeignPtr fp $ \ptr ->
                throwIfError "could not write block" $
                   writeBlock_ b (fromIntegral x) (fromIntegral y) (castPtr ptr)

foreign import ccall safe "gdal.h GDALWriteBlock" writeBlock_
   :: RWBand -> CInt -> CInt -> Ptr () -> IO CInt


typeOfBand = typeOfdatatype . bandDatatype

