 type FileProgressCallback = {# type goffset #} -> {# type goffset #} -> IO ()
 type FileReadMoreCallback = BS.ByteString -> IO Bool
 
-fileNewForPath :: FilePath -> IO File
-fileNewForPath path =
-    withUTFString path $ {# call file_new_for_path #} >=> takeGObject
-
-fileNewForURI :: String -> IO File
-fileNewForURI uri =
-    withUTFString uri $ {# call file_new_for_uri #} >=> takeGObject
-
-fileNewForCommandlineArg :: String -> IO File
-fileNewForCommandlineArg arg =
-    withUTFString arg $ {# call file_new_for_commandline_arg #} >=> takeGObject
-
-fileParseName :: String -> IO File
-fileParseName parseName =
-    withUTFString parseName $ {# call file_parse_name #} >=> takeGObject
-
-fileDup :: FileClass file
-        => file -> IO file
-fileDup =
-    {# call file_dup #} . toFile >=> takeGObject . castPtr
+fileFromPath :: FilePath -> File
+fileFromPath path =
+    unsafePerformIO $ withUTFString path $ {# call file_new_for_path #} >=> takeGObject
+
+fileFromURI :: String -> File
+fileFromURI uri =
+    unsafePerformIO $ withUTFString uri $ {# call file_new_for_uri #} >=> takeGObject
+
+fileFromCommandlineArg :: String -> File
+fileFromCommandlineArg arg =
+    unsafePerformIO $ withUTFString arg $ {# call file_new_for_commandline_arg #} >=> takeGObject
+
+fileFromParseName :: String -> File
+fileFromParseName parseName =
+    unsafePerformIO $ withUTFString parseName $ {# call file_parse_name #} >=> takeGObject
 
 fileEqual :: (FileClass file1, FileClass file2)
-          => file1 -> file2 -> IO Bool
+          => file1 -> file2 -> Bool
 fileEqual file1 file2 =
-    liftM toBool $ {# call file_equal #} (toFile file1) (toFile file2)
-
-fileGetBasename :: FileClass file => file -> IO String
-fileGetBasename =
-    {# call file_get_basename #} . toFile >=> readUTFString
-
-fileGetPath :: FileClass file => file -> IO FilePath
-fileGetPath =
-    {# call file_get_path #} . toFile >=> readUTFString
-
-fileGetURI :: FileClass file => file -> IO String
-fileGetURI =
-    {# call file_get_uri #} . toFile >=> readUTFString
-
-fileGetParseName :: FileClass file => file -> IO String
-fileGetParseName =
-    {# call file_get_parse_name #} . toFile >=> readUTFString
-
-fileGetParent :: FileClass file => file -> IO (Maybe File)
-fileGetParent =
-    {# call file_get_parent #} . toFile >=> maybePeek takeGObject
-
-fileGetChild :: FileClass file => file -> String -> IO (Maybe File)
+    unsafePerformIO $ liftM toBool $ {# call file_equal #} (toFile file1) (toFile file2)
+
+instance Eq File where
+    (==) = fileEqual
+
+fileBasename :: FileClass file => file -> String
+fileBasename =
+    unsafePerformIO . ({# call file_get_basename #} . toFile >=> readUTFString)
+
+filePath :: FileClass file => file -> FilePath
+filePath =
+    unsafePerformIO . ({# call file_get_path #} . toFile >=> readUTFString)
+
+fileURI :: FileClass file => file -> String
+fileURI =
+    unsafePerformIO . ({# call file_get_uri #} . toFile >=> readUTFString)
+
+fileParseName :: FileClass file => file -> String
+fileParseName =
+    unsafePerformIO . ({# call file_get_parse_name #} . toFile >=> readUTFString)
+
+fileParent :: FileClass file => file -> Maybe File
+fileParent =
+    unsafePerformIO . ({# call file_get_parent #} . toFile >=> maybePeek takeGObject)
+
+fileGetChild :: FileClass file => file -> String -> File
 fileGetChild file name =
-    withUTFString name $ {# call file_get_child #} (toFile file) >=> maybePeek takeGObject
-
-fileGetChildForDisplayName :: FileClass file => file -> String -> IO File
+    unsafePerformIO $
+        withUTFString name $
+        {# call file_get_child #} (toFile file) >=> takeGObject
+
+fileGetChildForDisplayName :: FileClass file => file -> String -> Maybe File
 fileGetChildForDisplayName file displayName =
-    withUTFString displayName $ \cDisplayName ->
+    unsafePerformIO $
+        withUTFString displayName $ \cDisplayName ->
         propagateGError ({# call file_get_child_for_display_name #} (toFile file) cDisplayName) >>=
-        takeGObject
-
-fileHasPrefix :: (FileClass file1, FileClass file2) => file1 -> file2 -> IO Bool
+        maybePeek takeGObject
+
+fileHasPrefix :: (FileClass file1, FileClass file2) => file1 -> file2 -> Bool
 fileHasPrefix file1 file2 =
-    liftM toBool $ {# call file_has_prefix #} (toFile file1) (toFile file2)
-
-fileGetRelativePath :: (FileClass file1, FileClass file2) => file1 -> file2 -> IO FilePath
+    unsafePerformIO $
+        liftM toBool $ {# call file_has_prefix #} (toFile file1) (toFile file2)
+
+fileGetRelativePath :: (FileClass file1, FileClass file2) => file1 -> file2 -> Maybe FilePath
 fileGetRelativePath file1 file2 =
-    {# call file_get_relative_path #} (toFile file1) (toFile file2) >>= readUTFString
-
-fileResolveRelativePath :: FileClass file => file -> FilePath -> IO (Maybe File)
+    unsafePerformIO $
+        {# call file_get_relative_path #} (toFile file1) (toFile file2) >>=
+        maybePeek readUTFString
+
+fileResolveRelativePath :: FileClass file => file -> FilePath -> Maybe File
 fileResolveRelativePath file relativePath =
-    withUTFString relativePath $ \cRelativePath ->
+    unsafePerformIO $
+        withUTFString relativePath $ \cRelativePath ->
         {# call file_resolve_relative_path #} (toFile file) cRelativePath >>=
         maybePeek takeGObject
 
-fileIsNative :: FileClass file => file -> IO Bool
+fileIsNative :: FileClass file => file -> Bool
 fileIsNative =
-    liftM toBool . {# call file_is_native #} . toFile
-
-fileHasURIScheme :: FileClass file => file -> String -> IO Bool
+    unsafePerformIO .
+        liftM toBool . {# call file_is_native #} . toFile
+
+fileHasURIScheme :: FileClass file => file -> String -> Bool
 fileHasURIScheme file uriScheme =
-    withUTFString uriScheme $ \cURIScheme ->
+    unsafePerformIO $
+        withUTFString uriScheme $ \cURIScheme ->
         liftM toBool $ {# call file_has_uri_scheme #} (toFile file) cURIScheme
 
-fileGetURIScheme :: FileClass file => file -> IO String
-fileGetURIScheme =
-    {# call file_get_uri_scheme #} . toFile >=> readUTFString
+fileURIScheme :: FileClass file => file -> String
+fileURIScheme =
+    unsafePerformIO . ({# call file_get_uri_scheme #} . toFile >=> readUTFString)
 
 fileRead :: FileClass file => file -> Maybe Cancellable -> IO FileInputStream
 fileRead file cancellable =

        propagateGError (g_file_query_filesystem_info cFile cAttributes cCancellable) >>=
        takeGObject
    where _ = {# call file_query_filesystem_info #}

    FilesystemPreviewType,
    FileProgressCallback,
    FileReadMoreCallback,
    fileFromPath,
    fileFromURI,
    fileFromCommandlineArg,
    fileFromParseName,
    fileEqual,
    fileBasename,
    filePath,
    fileURI,
    fileParseName,
    fileGetChild,
    fileGetChildForDisplayName,
    fileHasPrefix,
