@@ -28,292 +28,239 @@ module Node.FS.Aff
28
28
, fdWrite
29
29
, fdAppend
30
30
, fdClose
31
- , module Exports
32
31
) where
33
32
34
33
import Prelude
35
34
36
- import Control.Monad .Aff (Aff , makeAff , nonCanceler )
37
- import Control.Monad.Eff ( Eff )
35
+ import Effect .Aff (Aff , makeAff , nonCanceler )
36
+ import Effect ( Effect )
38
37
import Data.DateTime (DateTime )
39
38
import Data.Maybe (Maybe )
40
- import Node.Buffer (Buffer , BUFFER )
39
+ import Node.Buffer (Buffer )
41
40
import Node.Encoding (Encoding )
42
41
import Node.FS as F
43
42
import Node.FS.Async as A
44
43
import Node.FS.Perms (Perms )
45
44
import Node.FS.Stats (Stats )
46
45
import Node.Path (FilePath )
47
46
48
- import Node.FS (FS ) as Exports
49
-
50
- toAff :: forall eff a .
51
- (A.Callback eff a -> Eff (fs :: F.FS | eff ) Unit ) ->
52
- Aff (fs :: F.FS | eff ) a
47
+ toAff :: forall a .
48
+ (A.Callback a -> Effect Unit ) ->
49
+ Aff a
53
50
toAff p = makeAff \k -> p k $> nonCanceler
54
51
55
- toAff1 :: forall eff a x .
56
- (x -> A.Callback eff a -> Eff ( fs :: F.FS | eff ) Unit ) ->
52
+ toAff1 :: forall a x .
53
+ (x -> A.Callback a -> Effect Unit ) ->
57
54
x ->
58
- Aff ( fs :: F.FS | eff ) a
55
+ Aff a
59
56
toAff1 f a = toAff (f a)
60
57
61
- toAff2 :: forall eff a x y .
62
- (x -> y -> A.Callback eff a -> Eff ( fs :: F.FS | eff ) Unit ) ->
58
+ toAff2 :: forall a x y .
59
+ (x -> y -> A.Callback a -> Effect Unit ) ->
63
60
x ->
64
61
y ->
65
- Aff ( fs :: F.FS | eff ) a
62
+ Aff a
66
63
toAff2 f a b = toAff (f a b)
67
64
68
- toAff3 :: forall eff a x y z .
69
- (x -> y -> z -> A.Callback eff a -> Eff ( fs :: F.FS | eff ) Unit ) ->
65
+ toAff3 :: forall a x y z .
66
+ (x -> y -> z -> A.Callback a -> Effect Unit ) ->
70
67
x ->
71
68
y ->
72
69
z ->
73
- Aff ( fs :: F.FS | eff ) a
70
+ Aff a
74
71
toAff3 f a b c = toAff (f a b c)
75
72
76
- toAff5 :: forall eff a w v x y z .
77
- (w -> v -> x -> y -> z -> A.Callback eff a -> Eff ( fs :: F.FS | eff ) Unit ) ->
73
+ toAff5 :: forall a w v x y z .
74
+ (w -> v -> x -> y -> z -> A.Callback a -> Effect Unit ) ->
78
75
w ->
79
76
v ->
80
77
x ->
81
78
y ->
82
79
z ->
83
- Aff ( fs :: F.FS | eff ) a
80
+ Aff a
84
81
toAff5 f a b c d e = toAff (f a b c d e)
85
82
86
83
-- |
87
84
-- | Rename a file.
88
85
-- |
89
- rename :: forall eff . FilePath
90
- -> FilePath
91
- -> Aff (fs :: F.FS | eff ) Unit
86
+ rename :: FilePath -> FilePath -> Aff Unit
92
87
rename = toAff2 A .rename
93
88
94
89
-- |
95
90
-- | Truncates a file to the specified length.
96
91
-- |
97
- truncate :: forall eff . FilePath
98
- -> Int
99
- -> Aff (fs :: F.FS | eff ) Unit
92
+ truncate :: FilePath -> Int -> Aff Unit
100
93
truncate = toAff2 A .truncate
101
94
102
95
-- |
103
96
-- | Changes the ownership of a file.
104
97
-- |
105
- chown :: forall eff . FilePath
106
- -> Int
107
- -> Int
108
- -> Aff (fs :: F.FS | eff ) Unit
98
+ chown :: FilePath -> Int -> Int -> Aff Unit
109
99
chown = toAff3 A .chown
110
100
111
101
-- |
112
102
-- | Changes the permissions of a file.
113
103
-- |
114
- chmod :: forall eff . FilePath
115
- -> Perms
116
- -> Aff (fs :: F.FS | eff ) Unit
104
+ chmod :: FilePath -> Perms -> Aff Unit
117
105
chmod = toAff2 A .chmod
118
106
119
107
-- |
120
108
-- | Gets file statistics.
121
109
-- |
122
- stat :: forall eff . FilePath
123
- -> Aff (fs :: F.FS | eff ) Stats
110
+ stat :: FilePath -> Aff Stats
124
111
stat = toAff1 A .stat
125
112
126
113
-- |
127
114
-- | Creates a link to an existing file.
128
115
-- |
129
- link :: forall eff . FilePath
130
- -> FilePath
131
- -> Aff (fs :: F.FS | eff ) Unit
116
+ link :: FilePath -> FilePath -> Aff Unit
132
117
link = toAff2 A .link
133
118
134
119
-- |
135
120
-- | Creates a symlink.
136
121
-- |
137
- symlink :: forall eff . FilePath
138
- -> FilePath
139
- -> F.SymlinkType
140
- -> Aff ( fs :: F.FS | eff ) Unit
122
+ symlink :: FilePath
123
+ -> FilePath
124
+ -> F.SymlinkType
125
+ -> Aff Unit
141
126
symlink = toAff3 A .symlink
142
127
143
128
-- |
144
129
-- | Reads the value of a symlink.
145
130
-- |
146
- readlink :: forall eff . FilePath
147
- -> Aff (fs :: F.FS | eff ) FilePath
131
+ readlink :: FilePath -> Aff FilePath
148
132
readlink = toAff1 A .readlink
149
133
150
134
-- |
151
135
-- | Find the canonicalized absolute location for a path.
152
136
-- |
153
- realpath :: forall eff . FilePath
154
- -> Aff (fs :: F.FS | eff ) FilePath
137
+ realpath :: FilePath -> Aff FilePath
155
138
realpath = toAff1 A .realpath
156
139
157
140
-- |
158
141
-- | Find the canonicalized absolute location for a path using a cache object
159
142
-- | for already resolved paths.
160
143
-- |
161
- realpath' :: forall eff cache . FilePath
162
- -> { | cache }
163
- -> Aff (fs :: F.FS | eff ) FilePath
144
+ realpath' :: forall cache . FilePath -> { | cache } -> Aff FilePath
164
145
realpath' = toAff2 A .realpath'
165
146
166
147
-- |
167
148
-- | Deletes a file.
168
149
-- |
169
- unlink :: forall eff . FilePath
170
- -> Aff (fs :: F.FS | eff ) Unit
150
+ unlink :: FilePath -> Aff Unit
171
151
unlink = toAff1 A .unlink
172
152
173
153
-- |
174
154
-- | Deletes a directory.
175
155
-- |
176
- rmdir :: forall eff . FilePath
177
- -> Aff (fs :: F.FS | eff ) Unit
156
+ rmdir :: FilePath -> Aff Unit
178
157
rmdir = toAff1 A .rmdir
179
158
180
159
-- |
181
160
-- | Makes a new directory.
182
161
-- |
183
- mkdir :: forall eff . FilePath
184
- -> Aff (fs :: F.FS | eff ) Unit
162
+ mkdir :: FilePath -> Aff Unit
185
163
mkdir = toAff1 A .mkdir
186
164
187
165
-- |
188
166
-- | Makes a new directory with the specified permissions.
189
167
-- |
190
- mkdir' :: forall eff . FilePath
191
- -> Perms
192
- -> Aff (fs :: F.FS | eff ) Unit
168
+ mkdir' :: FilePath -> Perms -> Aff Unit
193
169
mkdir' = toAff2 A .mkdir'
194
170
195
171
-- |
196
172
-- | Reads the contents of a directory.
197
173
-- |
198
- readdir :: forall eff . FilePath
199
- -> Aff (fs :: F.FS | eff ) (Array FilePath )
174
+ readdir :: FilePath -> Aff (Array FilePath )
200
175
readdir = toAff1 A .readdir
201
176
202
177
-- |
203
178
-- | Sets the accessed and modified times for the specified file.
204
179
-- |
205
- utimes :: forall eff . FilePath
206
- -> DateTime
207
- -> DateTime
208
- -> Aff (fs :: F.FS | eff ) Unit
180
+ utimes :: FilePath -> DateTime -> DateTime -> Aff Unit
209
181
utimes = toAff3 A .utimes
210
182
211
183
-- |
212
184
-- | Reads the entire contents of a file returning the result as a raw buffer.
213
185
-- |
214
- readFile :: forall eff . FilePath
215
- -> Aff (fs :: F.FS , buffer :: BUFFER | eff ) Buffer
186
+ readFile :: FilePath -> Aff Buffer
216
187
readFile = toAff1 A .readFile
217
188
218
189
-- |
219
190
-- | Reads the entire contents of a text file with the specified encoding.
220
191
-- |
221
- readTextFile :: forall eff . Encoding
222
- -> FilePath
223
- -> Aff (fs :: F.FS | eff ) String
192
+ readTextFile :: Encoding -> FilePath -> Aff String
224
193
readTextFile = toAff2 A .readTextFile
225
194
226
195
-- |
227
196
-- | Writes a buffer to a file.
228
197
-- |
229
- writeFile :: forall eff . FilePath
230
- -> Buffer
231
- -> Aff (fs :: F.FS , buffer :: BUFFER | eff ) Unit
198
+ writeFile :: FilePath -> Buffer -> Aff Unit
232
199
writeFile = toAff2 A .writeFile
233
200
234
201
-- |
235
202
-- | Writes text to a file using the specified encoding.
236
203
-- |
237
- writeTextFile :: forall eff . Encoding
238
- -> FilePath
239
- -> String
240
- -> Aff (fs :: F.FS | eff ) Unit
204
+ writeTextFile :: Encoding -> FilePath -> String -> Aff Unit
241
205
writeTextFile = toAff3 A .writeTextFile
242
206
243
207
-- |
244
208
-- | Appends the contents of a buffer to a file.
245
209
-- |
246
- appendFile :: forall eff . FilePath
247
- -> Buffer
248
- -> Aff (fs :: F.FS , buffer :: BUFFER | eff ) Unit
210
+ appendFile :: FilePath -> Buffer -> Aff Unit
249
211
appendFile = toAff2 A .appendFile
250
212
251
213
-- |
252
214
-- | Appends text to a file using the specified encoding.
253
215
-- |
254
- appendTextFile :: forall eff . Encoding
255
- -> FilePath
256
- -> String
257
- -> Aff (fs :: F.FS | eff ) Unit
216
+ appendTextFile :: Encoding -> FilePath -> String -> Aff Unit
258
217
appendTextFile = toAff3 A .appendTextFile
259
218
260
219
-- |
261
220
-- | Check to see if a file exists.
262
221
-- |
263
- exists :: forall eff . String
264
- -> Aff (fs :: F.FS | eff ) Boolean
222
+ exists :: String -> Aff Boolean
265
223
exists file = makeAff \k -> A .exists file (pure >>> k) $> nonCanceler
266
224
267
225
-- | Open a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback)
268
226
-- | for details.
269
- fdOpen :: forall eff .
270
- FilePath
227
+ fdOpen :: FilePath
271
228
-> F.FileFlags
272
229
-> Maybe F.FileMode
273
- -> Aff ( fs :: F.FS | eff ) F.FileDescriptor
230
+ -> Aff F.FileDescriptor
274
231
fdOpen = toAff3 A .fdOpen
275
232
276
233
-- | Read from a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback)
277
234
-- | for details.
278
- fdRead :: forall eff .
279
- F.FileDescriptor
235
+ fdRead :: F.FileDescriptor
280
236
-> Buffer
281
237
-> F.BufferOffset
282
238
-> F.BufferLength
283
239
-> Maybe F.FilePosition
284
- -> Aff ( buffer :: BUFFER , fs :: F.FS | eff ) F.ByteCount
240
+ -> Aff F.ByteCount
285
241
fdRead = toAff5 A .fdRead
286
242
287
243
-- | Convenience function to fill the whole buffer from the current
288
244
-- | file position.
289
- fdNext :: forall eff .
290
- F.FileDescriptor
291
- -> Buffer
292
- -> Aff (buffer :: BUFFER , fs :: F.FS | eff ) F.ByteCount
245
+ fdNext :: F.FileDescriptor -> Buffer -> Aff F.ByteCount
293
246
fdNext = toAff2 A .fdNext
294
247
295
248
-- | Write to a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_write_fd_buffer_offset_length_position_callback)
296
249
-- | for details.
297
- fdWrite :: forall eff .
298
- F.FileDescriptor
250
+ fdWrite :: F.FileDescriptor
299
251
-> Buffer
300
252
-> F.BufferOffset
301
253
-> F.BufferLength
302
254
-> Maybe F.FilePosition
303
- -> Aff ( buffer :: BUFFER , fs :: F.FS | eff ) F.ByteCount
255
+ -> Aff F.ByteCount
304
256
fdWrite = toAff5 A .fdWrite
305
257
306
258
-- | Convenience function to append the whole buffer to the current
307
259
-- | file position.
308
- fdAppend :: forall eff .
309
- F.FileDescriptor
310
- -> Buffer
311
- -> Aff (buffer :: BUFFER , fs :: F.FS | eff ) F.ByteCount
260
+ fdAppend :: F.FileDescriptor -> Buffer -> Aff F.ByteCount
312
261
fdAppend = toAff2 A .fdAppend
313
262
314
263
-- | Close a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_close_fd_callback)
315
264
-- | for details.
316
- fdClose :: forall eff .
317
- F.FileDescriptor
318
- -> Aff (fs :: F.FS | eff ) Unit
265
+ fdClose :: F.FileDescriptor -> Aff Unit
319
266
fdClose = toAff1 A .fdClose
0 commit comments