@@ -30,11 +30,10 @@ import Node.Path (FilePath())
3030import Node.FS.Perms (Perms ())
3131import Node.FS.Stats (Stats ())
3232import Data.Date (Date ())
33- import Control.Monad.Eff (Eff (), runPure )
34- import Control.Monad.Eff.Unsafe (unsafeInterleaveEff )
33+ import Control.Monad.Eff (Eff ())
3534import Data.Either (either )
3635import Control.Monad.Aff (Aff (), makeAff )
37- import Node.Buffer (Buffer ())
36+ import Node.Buffer (Buffer (), BUFFER () )
3837import Node.Encoding (Encoding ())
3938import qualified Node.FS as F
4039import qualified Node.FS.Async as A
@@ -44,8 +43,25 @@ toAff :: forall eff a.
4443 Aff (fs :: F.FS | eff ) a
4544toAff p = makeAff \e a -> p $ either e a
4645
46+ toAff1 :: forall eff a x .
47+ (x -> A.Callback eff a -> Eff (fs :: F.FS | eff ) Unit ) ->
48+ x ->
49+ Aff (fs :: F.FS | eff ) a
4750toAff1 f a = toAff (f a)
51+
52+ toAff2 :: forall eff a x y .
53+ (x -> y -> A.Callback eff a -> Eff (fs :: F.FS | eff ) Unit ) ->
54+ x ->
55+ y ->
56+ Aff (fs :: F.FS | eff ) a
4857toAff2 f a b = toAff (f a b)
58+
59+ toAff3 :: forall eff a x y z .
60+ (x -> y -> z -> A.Callback eff a -> Eff (fs :: F.FS | eff ) Unit ) ->
61+ x ->
62+ y ->
63+ z ->
64+ Aff (fs :: F.FS | eff ) a
4965toAff3 f a b c = toAff (f a b c)
5066
5167-- |
@@ -60,16 +76,16 @@ rename = toAff2 A.rename
6076-- | Truncates a file to the specified length.
6177-- |
6278truncate :: forall eff . FilePath
63- -> Number
79+ -> Int
6480 -> Aff (fs :: F.FS | eff ) Unit
6581truncate = toAff2 A .truncate
6682
6783-- |
6884-- | Changes the ownership of a file.
6985-- |
7086chown :: forall eff . FilePath
71- -> Number
72- -> Number
87+ -> Int
88+ -> Int
7389 -> Aff (fs :: F.FS | eff ) Unit
7490chown = toAff3 A .chown
7591
@@ -177,7 +193,7 @@ utimes = toAff3 A.utimes
177193-- | Reads the entire contents of a file returning the result as a raw buffer.
178194-- |
179195readFile :: forall eff . FilePath
180- -> Aff (fs :: F.FS | eff ) Buffer
196+ -> Aff (fs :: F.FS , buffer :: BUFFER | eff ) Buffer
181197readFile = toAff1 A .readFile
182198
183199-- |
@@ -193,7 +209,7 @@ readTextFile = toAff2 A.readTextFile
193209-- |
194210writeFile :: forall eff . FilePath
195211 -> Buffer
196- -> Aff (fs :: F.FS | eff ) Unit
212+ -> Aff (fs :: F.FS , buffer :: BUFFER | eff ) Unit
197213writeFile = toAff2 A .writeFile
198214
199215-- |
@@ -210,7 +226,7 @@ writeTextFile = toAff3 A.writeTextFile
210226-- |
211227appendFile :: forall eff . FilePath
212228 -> Buffer
213- -> Aff (fs :: F.FS | eff ) Unit
229+ -> Aff (fs :: F.FS , buffer :: BUFFER | eff ) Unit
214230appendFile = toAff2 A .appendFile
215231
216232-- |
0 commit comments