@@ -30,6 +30,7 @@ import Data.Maybe
3030import Data.Time.Clock.POSIX (getPOSIXTime)
3131import Data.Traversable (forM)
3232import Debug.Trace
33+import System.Directory
3334import System.IO
3435import System.IO.Error
3536import System.IO.Unsafe
@@ -387,6 +388,15 @@ execForeign env ctxt arity ty fn xs onfail
387388 "The argument to fileError should be a file handle, but it was " ++
388389 show handle ++
389390 ". Are all cases covered?"
391+ | Just (FFun "fileRemove" [(_,fileStr)] _) <- foreignFromTT arity ty fn xs
392+ = case fileStr of
393+ EConstant (Str f) -> do eofp <- execIO $ removeFile f
394+ let res = ioWrap (EConstant (I $ if eofp then 1 else 0))
395+ execApp env ctxt res (drop arity xs)
396+ _ -> execFail . Msg $
397+ "The argument to fileRemove should be a constant string, but it was " ++
398+ show handle ++
399+ ". Are all cases covered?"
390400 | Just (FFun "fileClose" [(_,handle)] _) <- foreignFromTT arity ty fn xs
391401 = case handle of
392402 EHandle h -> do execIO $ hClose h