@@ -37,16 +37,16 @@ import Control.Monad.Eff.Exception (EXCEPTION)
37
37
import Data.DateTime (DateTime )
38
38
import Data.Time.Duration (Milliseconds (..))
39
39
import Data.DateTime.Instant (fromDateTime , unInstant )
40
- import Data.Function.Uncurried (Fn1 , Fn5 , Fn3 , Fn2 ,
40
+ import Data.Function.Uncurried (Fn1 , Fn5 , Fn3 , Fn2 ,
41
41
runFn1 , runFn5 , runFn3 , runFn2 )
42
42
import Data.Nullable (Nullable (), toNullable )
43
43
import Data.Int (round )
44
44
import Data.Maybe (Maybe (..))
45
45
import Node.Buffer (Buffer (), BUFFER (), size )
46
46
import Node.Encoding (Encoding )
47
47
48
- import Node.FS (FS , FileDescriptor , ByteCount , FilePosition , BufferLength ,
49
- BufferOffset , FileMode , FileFlags , SymlinkType ,
48
+ import Node.FS (FS , FileDescriptor , ByteCount , FilePosition , BufferLength ,
49
+ BufferOffset , FileMode , FileFlags , SymlinkType ,
50
50
fileFlagsToNode , symlinkTypeToNode )
51
51
import Node.FS.Stats (StatsObj , Stats (..))
52
52
import Node.Path (FilePath ())
@@ -83,15 +83,15 @@ fs = unsafeRequireFS
83
83
-- | Renames a file.
84
84
rename :: forall eff . FilePath
85
85
-> FilePath
86
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
86
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
87
87
88
88
rename oldFile newFile = mkEff $ \_ -> runFn2
89
89
fs.renameSync oldFile newFile
90
90
91
91
-- | Truncates a file to the specified length.
92
92
truncate :: forall eff . FilePath
93
93
-> Int
94
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
94
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
95
95
96
96
truncate file len = mkEff $ \_ -> runFn2
97
97
fs.truncateSync file len
@@ -100,30 +100,30 @@ truncate file len = mkEff $ \_ -> runFn2
100
100
chown :: forall eff . FilePath
101
101
-> Int
102
102
-> Int
103
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
103
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
104
104
105
105
chown file uid gid = mkEff $ \_ -> runFn3
106
106
fs.chownSync file uid gid
107
107
108
108
-- | Changes the permissions of a file.
109
109
chmod :: forall eff . FilePath
110
110
-> Perms
111
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
111
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
112
112
113
113
chmod file perms = mkEff $ \_ -> runFn2
114
114
fs.chmodSync file (permsToString perms)
115
115
116
116
-- | Gets file statistics.
117
117
stat :: forall eff . FilePath
118
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Stats
118
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Stats
119
119
120
120
stat file = map Stats $ mkEff $ \_ -> runFn1
121
121
fs.statSync file
122
122
123
123
-- | Creates a link to an existing file.
124
124
link :: forall eff . FilePath
125
125
-> FilePath
126
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
126
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
127
127
128
128
link src dst = mkEff $ \_ -> runFn2
129
129
fs.linkSync src dst
@@ -132,21 +132,21 @@ link src dst = mkEff $ \_ -> runFn2
132
132
symlink :: forall eff . FilePath
133
133
-> FilePath
134
134
-> SymlinkType
135
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
135
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
136
136
137
137
symlink src dst ty = mkEff $ \_ -> runFn3
138
138
fs.symlinkSync src dst (symlinkTypeToNode ty)
139
139
140
140
-- | Reads the value of a symlink.
141
141
readlink :: forall eff . FilePath
142
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) FilePath
142
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) FilePath
143
143
144
144
readlink path = mkEff $ \_ -> runFn1
145
145
fs.readlinkSync path
146
146
147
147
-- | Find the canonicalized absolute location for a path.
148
148
realpath :: forall eff . FilePath
149
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) FilePath
149
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) FilePath
150
150
151
151
realpath path = mkEff $ \_ -> runFn2
152
152
fs.realpathSync path {}
@@ -155,42 +155,42 @@ realpath path = mkEff $ \_ -> runFn2
155
155
-- | already resolved paths.
156
156
realpath' :: forall eff cache . FilePath
157
157
-> { | cache }
158
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) FilePath
158
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) FilePath
159
159
160
160
realpath' path cache = mkEff $ \_ -> runFn2
161
161
fs.realpathSync path cache
162
162
163
163
-- | Deletes a file.
164
164
unlink :: forall eff . FilePath
165
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
165
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
166
166
167
167
unlink file = mkEff $ \_ -> runFn1
168
168
fs.unlinkSync file
169
169
170
170
-- | Deletes a directory.
171
171
rmdir :: forall eff . FilePath
172
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
172
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
173
173
174
174
rmdir file = mkEff $ \_ -> runFn1
175
175
fs.rmdirSync file
176
176
177
177
-- | Makes a new directory.
178
178
mkdir :: forall eff . FilePath
179
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
179
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
180
180
181
181
mkdir = flip mkdir' $ mkPerms all all all
182
182
183
183
-- | Makes a new directory with the specified permissions.
184
184
mkdir' :: forall eff . FilePath
185
185
-> Perms
186
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
186
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
187
187
188
188
mkdir' file perms = mkEff $ \_ -> runFn2
189
189
fs.mkdirSync file (permsToString perms)
190
190
191
191
-- | Reads the contents of a directory.
192
192
readdir :: forall eff . FilePath
193
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) (Array FilePath )
193
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) (Array FilePath )
194
194
195
195
readdir file = mkEff $ \_ -> runFn1
196
196
fs.readdirSync file
@@ -199,7 +199,7 @@ readdir file = mkEff $ \_ -> runFn1
199
199
utimes :: forall eff . FilePath
200
200
-> DateTime
201
201
-> DateTime
202
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
202
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
203
203
204
204
utimes file atime mtime = mkEff $ \_ -> runFn3
205
205
fs.utimesSync file
@@ -212,23 +212,23 @@ utimes file atime mtime = mkEff $ \_ -> runFn3
212
212
213
213
-- | Reads the entire contents of a file returning the result as a raw buffer.
214
214
readFile :: forall eff . FilePath
215
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Buffer
215
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Buffer
216
216
217
217
readFile file = mkEff $ \_ -> runFn2
218
218
fs.readFileSync file {}
219
219
220
220
-- | Reads the entire contents of a text file with the specified encoding.
221
221
readTextFile :: forall eff . Encoding
222
222
-> FilePath
223
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) String
223
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) String
224
224
225
225
readTextFile encoding file = mkEff $ \_ -> runFn2
226
226
fs.readFileSync file { encoding: show encoding }
227
227
228
228
-- | Writes a buffer to a file.
229
229
writeFile :: forall eff . FilePath
230
230
-> Buffer
231
- -> Eff (buffer :: BUFFER , fs :: FS , err :: EXCEPTION | eff ) Unit
231
+ -> Eff (buffer :: BUFFER , fs :: FS , exception :: EXCEPTION | eff ) Unit
232
232
233
233
writeFile file buff = mkEff $ \_ -> runFn3
234
234
fs.writeFileSync file buff {}
@@ -237,15 +237,15 @@ writeFile file buff = mkEff $ \_ -> runFn3
237
237
writeTextFile :: forall eff . Encoding
238
238
-> FilePath
239
239
-> String
240
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
240
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
241
241
242
242
writeTextFile encoding file text = mkEff $ \_ -> runFn3
243
243
fs.writeFileSync file text { encoding: show encoding }
244
244
245
245
-- | Appends the contents of a buffer to a file.
246
246
appendFile :: forall eff . FilePath
247
247
-> Buffer
248
- -> Eff (buffer :: BUFFER , fs :: FS , err :: EXCEPTION | eff ) Unit
248
+ -> Eff (buffer :: BUFFER , fs :: FS , exception :: EXCEPTION | eff ) Unit
249
249
250
250
appendFile file buff = mkEff $ \_ -> runFn3
251
251
fs.appendFileSync file buff {}
@@ -254,7 +254,7 @@ appendFile file buff = mkEff $ \_ -> runFn3
254
254
appendTextFile :: forall eff . Encoding
255
255
-> FilePath
256
256
-> String
257
- -> Eff (fs :: FS , err :: EXCEPTION | eff ) Unit
257
+ -> Eff (fs :: FS , exception :: EXCEPTION | eff ) Unit
258
258
259
259
appendTextFile encoding file buff = mkEff $ \_ -> runFn3
260
260
fs.appendFileSync file buff { encoding: show encoding }
@@ -270,7 +270,7 @@ fdOpen :: forall eff.
270
270
FilePath
271
271
-> FileFlags
272
272
-> Maybe FileMode
273
- -> Eff (err :: EXCEPTION , fs :: FS | eff ) FileDescriptor
273
+ -> Eff (exception :: EXCEPTION , fs :: FS | eff ) FileDescriptor
274
274
fdOpen file flags mode = mkEff $ \_ ->
275
275
runFn3 fs.openSync file (fileFlagsToNode flags) (toNullable mode)
276
276
@@ -282,7 +282,7 @@ fdRead :: forall eff.
282
282
-> BufferOffset
283
283
-> BufferLength
284
284
-> Maybe FilePosition
285
- -> Eff (buffer :: BUFFER , err :: EXCEPTION , fs :: FS | eff ) ByteCount
285
+ -> Eff (buffer :: BUFFER , exception :: EXCEPTION , fs :: FS | eff ) ByteCount
286
286
fdRead fd buff off len pos =
287
287
mkEff $ \_ -> runFn5 fs.readSync fd buff off len (toNullable pos)
288
288
@@ -291,7 +291,7 @@ fdRead fd buff off len pos =
291
291
fdNext :: forall eff .
292
292
FileDescriptor
293
293
-> Buffer
294
- -> Eff (buffer :: BUFFER , err :: EXCEPTION , fs :: FS | eff ) ByteCount
294
+ -> Eff (buffer :: BUFFER , exception :: EXCEPTION , fs :: FS | eff ) ByteCount
295
295
fdNext fd buff = do
296
296
sz <- size buff
297
297
fdRead fd buff 0 sz Nothing
@@ -304,7 +304,7 @@ fdWrite :: forall eff.
304
304
-> BufferOffset
305
305
-> BufferLength
306
306
-> Maybe FilePosition
307
- -> Eff (buffer :: BUFFER , err :: EXCEPTION , fs :: FS | eff ) ByteCount
307
+ -> Eff (buffer :: BUFFER , exception :: EXCEPTION , fs :: FS | eff ) ByteCount
308
308
fdWrite fd buff off len pos =
309
309
mkEff $ \_ -> runFn5 fs.writeSync fd buff off len (toNullable pos)
310
310
@@ -313,7 +313,7 @@ fdWrite fd buff off len pos =
313
313
fdAppend :: forall eff .
314
314
FileDescriptor
315
315
-> Buffer
316
- -> Eff (buffer :: BUFFER , err :: EXCEPTION , fs :: FS | eff ) ByteCount
316
+ -> Eff (buffer :: BUFFER , exception :: EXCEPTION , fs :: FS | eff ) ByteCount
317
317
fdAppend fd buff = do
318
318
sz <- size buff
319
319
fdWrite fd buff 0 sz Nothing
@@ -322,12 +322,12 @@ fdAppend fd buff = do
322
322
-- | for details.
323
323
fdFlush :: forall eff .
324
324
FileDescriptor
325
- -> Eff (err :: EXCEPTION , fs :: FS | eff ) Unit
325
+ -> Eff (exception :: EXCEPTION , fs :: FS | eff ) Unit
326
326
fdFlush fd = mkEff $ \_ -> runFn1 fs.fsyncSync fd
327
327
328
328
-- | Close a file synchronously. See the [Node documentation](http://nodejs.org/api/fs.html#fs_fs_closesync_fd)
329
329
-- | for details.
330
330
fdClose :: forall eff .
331
331
FileDescriptor
332
- -> Eff (err :: EXCEPTION , fs :: FS | eff ) Unit
332
+ -> Eff (exception :: EXCEPTION , fs :: FS | eff ) Unit
333
333
fdClose fd = mkEff $ \_ -> runFn1 fs.closeSync fd
0 commit comments