Skip to content
This repository was archived by the owner on Aug 4, 2023. It is now read-only.

Commit d02c0a2

Browse files
authored
Merge pull request #21 from purescript-node/compiler/0.12
Compiler/0.12
2 parents 3d8e020 + 9ce2c1b commit d02c0a2

File tree

5 files changed

+78
-129
lines changed

5 files changed

+78
-129
lines changed

.travis.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
language: node_js
22
dist: trusty
33
sudo: required
4-
node_js: 6
4+
node_js: stable
5+
env:
6+
- PATH=$HOME/purescript:$PATH
57
install:
8+
- TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p')
9+
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
10+
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
11+
- chmod a+x $HOME/purescript
612
- npm install -g bower
713
- npm install
814
- bower install --production

bower.json

+7-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727
"example"
2828
],
2929
"dependencies": {
30-
"purescript-aff": "^4.0.0",
31-
"purescript-either": "^3.0.0",
32-
"purescript-node-fs": "^4.0.0",
33-
"purescript-node-path": "^2.0.0"
30+
"purescript-aff": "^5.0.0",
31+
"purescript-either": "^4.0.0",
32+
"purescript-node-fs": "^5.0.0",
33+
"purescript-node-path": "^3.0.0"
34+
},
35+
"devDependencies": {
36+
"purescript-console": "^4.1.0"
3437
}
3538
}

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"pulp": "^11.0.0",
10-
"purescript-psa": "^0.5.0",
11-
"purescript": "^0.11.1",
12-
"rimraf": "^2.5.4"
9+
"pulp": "^12.2.0",
10+
"purescript-psa": "^0.6.0",
11+
"rimraf": "^2.6.2"
1312
}
1413
}

src/Node/FS/Aff.purs

+53-106
Original file line numberDiff line numberDiff line change
@@ -28,292 +28,239 @@ module Node.FS.Aff
2828
, fdWrite
2929
, fdAppend
3030
, fdClose
31-
, module Exports
3231
) where
3332

3433
import Prelude
3534

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)
3837
import Data.DateTime (DateTime)
3938
import Data.Maybe (Maybe)
40-
import Node.Buffer (Buffer, BUFFER)
39+
import Node.Buffer (Buffer)
4140
import Node.Encoding (Encoding)
4241
import Node.FS as F
4342
import Node.FS.Async as A
4443
import Node.FS.Perms (Perms)
4544
import Node.FS.Stats (Stats)
4645
import Node.Path (FilePath)
4746

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
5350
toAff p = makeAff \k -> p k $> nonCanceler
5451

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) ->
5754
x ->
58-
Aff (fs :: F.FS | eff) a
55+
Aff a
5956
toAff1 f a = toAff (f a)
6057

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) ->
6360
x ->
6461
y ->
65-
Aff (fs :: F.FS | eff) a
62+
Aff a
6663
toAff2 f a b = toAff (f a b)
6764

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) ->
7067
x ->
7168
y ->
7269
z ->
73-
Aff (fs :: F.FS | eff) a
70+
Aff a
7471
toAff3 f a b c = toAff (f a b c)
7572

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) ->
7875
w ->
7976
v ->
8077
x ->
8178
y ->
8279
z ->
83-
Aff (fs :: F.FS | eff) a
80+
Aff a
8481
toAff5 f a b c d e = toAff (f a b c d e)
8582

8683
-- |
8784
-- | Rename a file.
8885
-- |
89-
rename :: forall eff. FilePath
90-
-> FilePath
91-
-> Aff (fs :: F.FS | eff) Unit
86+
rename :: FilePath -> FilePath -> Aff Unit
9287
rename = toAff2 A.rename
9388

9489
-- |
9590
-- | Truncates a file to the specified length.
9691
-- |
97-
truncate :: forall eff. FilePath
98-
-> Int
99-
-> Aff (fs :: F.FS | eff) Unit
92+
truncate :: FilePath -> Int -> Aff Unit
10093
truncate = toAff2 A.truncate
10194

10295
-- |
10396
-- | Changes the ownership of a file.
10497
-- |
105-
chown :: forall eff. FilePath
106-
-> Int
107-
-> Int
108-
-> Aff (fs :: F.FS | eff) Unit
98+
chown :: FilePath -> Int -> Int -> Aff Unit
10999
chown = toAff3 A.chown
110100

111101
-- |
112102
-- | Changes the permissions of a file.
113103
-- |
114-
chmod :: forall eff. FilePath
115-
-> Perms
116-
-> Aff (fs :: F.FS | eff) Unit
104+
chmod :: FilePath -> Perms -> Aff Unit
117105
chmod = toAff2 A.chmod
118106

119107
-- |
120108
-- | Gets file statistics.
121109
-- |
122-
stat :: forall eff. FilePath
123-
-> Aff (fs :: F.FS | eff) Stats
110+
stat :: FilePath -> Aff Stats
124111
stat = toAff1 A.stat
125112

126113
-- |
127114
-- | Creates a link to an existing file.
128115
-- |
129-
link :: forall eff. FilePath
130-
-> FilePath
131-
-> Aff (fs :: F.FS | eff) Unit
116+
link :: FilePath -> FilePath -> Aff Unit
132117
link = toAff2 A.link
133118

134119
-- |
135120
-- | Creates a symlink.
136121
-- |
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
141126
symlink = toAff3 A.symlink
142127

143128
-- |
144129
-- | Reads the value of a symlink.
145130
-- |
146-
readlink :: forall eff. FilePath
147-
-> Aff (fs :: F.FS | eff) FilePath
131+
readlink :: FilePath -> Aff FilePath
148132
readlink = toAff1 A.readlink
149133

150134
-- |
151135
-- | Find the canonicalized absolute location for a path.
152136
-- |
153-
realpath :: forall eff. FilePath
154-
-> Aff (fs :: F.FS | eff) FilePath
137+
realpath :: FilePath -> Aff FilePath
155138
realpath = toAff1 A.realpath
156139

157140
-- |
158141
-- | Find the canonicalized absolute location for a path using a cache object
159142
-- | for already resolved paths.
160143
-- |
161-
realpath' :: forall eff cache. FilePath
162-
-> { | cache }
163-
-> Aff (fs :: F.FS | eff) FilePath
144+
realpath' :: forall cache. FilePath -> { | cache } -> Aff FilePath
164145
realpath' = toAff2 A.realpath'
165146

166147
-- |
167148
-- | Deletes a file.
168149
-- |
169-
unlink :: forall eff. FilePath
170-
-> Aff (fs :: F.FS | eff) Unit
150+
unlink :: FilePath -> Aff Unit
171151
unlink = toAff1 A.unlink
172152

173153
-- |
174154
-- | Deletes a directory.
175155
-- |
176-
rmdir :: forall eff. FilePath
177-
-> Aff (fs :: F.FS | eff) Unit
156+
rmdir :: FilePath -> Aff Unit
178157
rmdir = toAff1 A.rmdir
179158

180159
-- |
181160
-- | Makes a new directory.
182161
-- |
183-
mkdir :: forall eff. FilePath
184-
-> Aff (fs :: F.FS | eff) Unit
162+
mkdir :: FilePath -> Aff Unit
185163
mkdir = toAff1 A.mkdir
186164

187165
-- |
188166
-- | Makes a new directory with the specified permissions.
189167
-- |
190-
mkdir' :: forall eff. FilePath
191-
-> Perms
192-
-> Aff (fs :: F.FS | eff) Unit
168+
mkdir' :: FilePath -> Perms -> Aff Unit
193169
mkdir' = toAff2 A.mkdir'
194170

195171
-- |
196172
-- | Reads the contents of a directory.
197173
-- |
198-
readdir :: forall eff. FilePath
199-
-> Aff (fs :: F.FS | eff) (Array FilePath)
174+
readdir :: FilePath -> Aff (Array FilePath)
200175
readdir = toAff1 A.readdir
201176

202177
-- |
203178
-- | Sets the accessed and modified times for the specified file.
204179
-- |
205-
utimes :: forall eff. FilePath
206-
-> DateTime
207-
-> DateTime
208-
-> Aff (fs :: F.FS | eff) Unit
180+
utimes :: FilePath -> DateTime -> DateTime -> Aff Unit
209181
utimes = toAff3 A.utimes
210182

211183
-- |
212184
-- | Reads the entire contents of a file returning the result as a raw buffer.
213185
-- |
214-
readFile :: forall eff. FilePath
215-
-> Aff (fs :: F.FS, buffer :: BUFFER | eff) Buffer
186+
readFile :: FilePath -> Aff Buffer
216187
readFile = toAff1 A.readFile
217188

218189
-- |
219190
-- | Reads the entire contents of a text file with the specified encoding.
220191
-- |
221-
readTextFile :: forall eff. Encoding
222-
-> FilePath
223-
-> Aff (fs :: F.FS | eff) String
192+
readTextFile :: Encoding -> FilePath -> Aff String
224193
readTextFile = toAff2 A.readTextFile
225194

226195
-- |
227196
-- | Writes a buffer to a file.
228197
-- |
229-
writeFile :: forall eff. FilePath
230-
-> Buffer
231-
-> Aff (fs :: F.FS, buffer :: BUFFER | eff) Unit
198+
writeFile :: FilePath -> Buffer -> Aff Unit
232199
writeFile = toAff2 A.writeFile
233200

234201
-- |
235202
-- | Writes text to a file using the specified encoding.
236203
-- |
237-
writeTextFile :: forall eff. Encoding
238-
-> FilePath
239-
-> String
240-
-> Aff (fs :: F.FS | eff) Unit
204+
writeTextFile :: Encoding -> FilePath -> String -> Aff Unit
241205
writeTextFile = toAff3 A.writeTextFile
242206

243207
-- |
244208
-- | Appends the contents of a buffer to a file.
245209
-- |
246-
appendFile :: forall eff. FilePath
247-
-> Buffer
248-
-> Aff (fs :: F.FS, buffer :: BUFFER | eff) Unit
210+
appendFile :: FilePath -> Buffer -> Aff Unit
249211
appendFile = toAff2 A.appendFile
250212

251213
-- |
252214
-- | Appends text to a file using the specified encoding.
253215
-- |
254-
appendTextFile :: forall eff. Encoding
255-
-> FilePath
256-
-> String
257-
-> Aff (fs :: F.FS | eff) Unit
216+
appendTextFile :: Encoding -> FilePath -> String -> Aff Unit
258217
appendTextFile = toAff3 A.appendTextFile
259218

260219
-- |
261220
-- | Check to see if a file exists.
262221
-- |
263-
exists :: forall eff. String
264-
-> Aff (fs :: F.FS | eff) Boolean
222+
exists :: String -> Aff Boolean
265223
exists file = makeAff \k -> A.exists file (pure >>> k) $> nonCanceler
266224

267225
-- | Open a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback)
268226
-- | for details.
269-
fdOpen :: forall eff.
270-
FilePath
227+
fdOpen :: FilePath
271228
-> F.FileFlags
272229
-> Maybe F.FileMode
273-
-> Aff (fs :: F.FS | eff) F.FileDescriptor
230+
-> Aff F.FileDescriptor
274231
fdOpen = toAff3 A.fdOpen
275232

276233
-- | Read from a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback)
277234
-- | for details.
278-
fdRead :: forall eff.
279-
F.FileDescriptor
235+
fdRead :: F.FileDescriptor
280236
-> Buffer
281237
-> F.BufferOffset
282238
-> F.BufferLength
283239
-> Maybe F.FilePosition
284-
-> Aff (buffer :: BUFFER, fs :: F.FS | eff) F.ByteCount
240+
-> Aff F.ByteCount
285241
fdRead = toAff5 A.fdRead
286242

287243
-- | Convenience function to fill the whole buffer from the current
288244
-- | 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
293246
fdNext = toAff2 A.fdNext
294247

295248
-- | Write to a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_write_fd_buffer_offset_length_position_callback)
296249
-- | for details.
297-
fdWrite :: forall eff.
298-
F.FileDescriptor
250+
fdWrite :: F.FileDescriptor
299251
-> Buffer
300252
-> F.BufferOffset
301253
-> F.BufferLength
302254
-> Maybe F.FilePosition
303-
-> Aff (buffer :: BUFFER, fs :: F.FS | eff) F.ByteCount
255+
-> Aff F.ByteCount
304256
fdWrite = toAff5 A.fdWrite
305257

306258
-- | Convenience function to append the whole buffer to the current
307259
-- | 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
312261
fdAppend = toAff2 A.fdAppend
313262

314263
-- | Close a file asynchronously. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_close_fd_callback)
315264
-- | for details.
316-
fdClose :: forall eff.
317-
F.FileDescriptor
318-
-> Aff (fs :: F.FS | eff) Unit
265+
fdClose :: F.FileDescriptor -> Aff Unit
319266
fdClose = toAff1 A.fdClose

0 commit comments

Comments
 (0)