on master help sign in
Fix deprecation warnings for File Writing.
87f1da9Jan de Muijnck-Hughes
libs/effects/Effect/File.idr+4−4
@@ -64,7 +64,7 @@ data FileIO : Effect where
64 ||| Write a string to a file.
64 ||| Write a string to a file.
65 |||
65 |||
66 ||| Only file that are open for writing can be written to.
66 ||| Only file that are open for writing can be written to.
67− WriteString : String -> sig FileIO () (OpenFile Write)
67+ WriteString : String -> sig FileIO () (OpenFile WriteTruncate)
68
68
69 ||| End of file?
69 ||| End of file?
70 |||
70 |||
@@ -138,11 +138,11 @@ readLine : Eff String [FILE_IO (OpenFile Read)]
138readLine = call $ ReadLine
138readLine = call $ ReadLine
139
139
140||| Write a string to a file.
140||| Write a string to a file.
141−writeString : String -> Eff () [FILE_IO (OpenFile Write)]
141+writeString : String -> Eff () [FILE_IO (OpenFile WriteTruncate)]
142writeString str = call $ WriteString str
142writeString str = call $ WriteString str
143
143
144||| Write a line to a file.
144||| Write a line to a file.
145−writeLine : String -> Eff () [FILE_IO (OpenFile Write)]
145+writeLine : String -> Eff () [FILE_IO (OpenFile WriteTruncate)]
146writeLine str = call $ WriteString (str ++ "\n")
146writeLine str = call $ WriteString (str ++ "\n")
147
147
148||| End of file?
148||| End of file?
@@ -176,7 +176,7 @@ writeFile : (errFunc : String -> e)
176 -> (content : String)
176 -> (content : String)
177 -> Eff (Either e ()) [FILE_IO ()]
177 -> Eff (Either e ()) [FILE_IO ()]
178writeFile errFunc fname content = do
178writeFile errFunc fname content = do
179− case !(open fname Write) of
179+ case !(open fname WriteTruncate) of
180 True => do
180 True => do
181 writeString content
181 writeString content
182 close
182 close
libs/prelude/Prelude/File.idr+2−2
@@ -255,7 +255,7 @@ export
255writeFile : (filepath : String) -> (contents : String) ->
255writeFile : (filepath : String) -> (contents : String) ->
256 IO (Either FileError ())
256 IO (Either FileError ())
257writeFile fn contents = do
257writeFile fn contents = do
258− Right h <- openFile fn Write | Left err => return (Left err)
258+ Right h <- openFile fn WriteTruncate | Left err => return (Left err)
259− Right () <- fPutStr h contents | Left err => return (Left err)
259+ Right () <- fPutStr h contents | Left err => return (Left err)
260 closeFile h
260 closeFile h
261 return (Right ())
261 return (Right ())