 checkType :: forall t a. GDALType a => Dataset t a -> IO (Dataset t a)
 checkType ds
   | datasetBandCount ds > 0 = withBand ds 1 $ \b ->
-                                if isValidDatatype b (Proxy :: Proxy a)
-                                  then return ds
-                                  else throw InvalidType
+      if datatype (Proxy :: Proxy a) == bandDatatype b
+        then return ds
+        else throw InvalidType
   | otherwise = return ds
+
+{-
+data SomeDataset t = forall a. GDALType a => SomeDataset (Dataset t a)
+
+openAnyReadOnly :: FilePath -> IO (SomeDataset ReadOnly)
+openAnyReadOnly p = withCString p $ \p' ->
+  open_ p' (fromEnumC GA_ReadOnly) >>= (fmap SomeDataset . newDatasetHandle)
+
+openAnyReadWrite :: FilePath -> IO (SomeDataset ReadWrite)
+openAnyReadWrite p = withCString p $ \p' ->
+  open_ p' (fromEnumC GA_Update) >>= (fmap SomeDataset . newDatasetHandle)
+-}
 
 foreign import ccall safe "gdal.h GDALOpen" open_
    :: CString -> CInt -> IO (Ptr (Dataset a t))
 
 
-createCopy' ::
-  Driver -> String -> (Dataset a t) -> Bool -> DriverOptions
-  -> ProgressFun -> IO (RWDataset t)
+createCopy' :: GDALType a
+  => Driver -> String -> (Dataset t a) -> Bool -> DriverOptions
+  -> ProgressFun -> IO (RWDataset a)
 createCopy' driver path dataset strict options progressFun = do
   d <- driverByName driver
   withCString path $ \p ->

import Data.Complex (Complex(..))
import Data.Maybe (isJust)
import Data.Proxy (Proxy(..))
import Data.Typeable (Typeable, typeOf)
import Data.Word (Word8, Word16, Word32)
import Data.Vector.Storable (Vector, unsafeFromForeignPtr0, unsafeToForeignPtr0)
import Foreign.C.String (withCString, CString, peekCString)

withDataset (Dataset (fptr,_)) = withForeignPtr fptr

{#pointer GDALRasterBandH as Band newtype nocode#}
newtype (Band s (t::DatasetMode) a) = Band (Ptr (Band s t a))

unBand :: Band s a t -> Ptr (Band s a t)
unBand (Band b) = b
