Skip to content

Commit d18a01f

Browse files
authored
Merge pull request purescript-node#34 from anilanar/ps-0.11
update for purescript 0.11
2 parents 7cae2f0 + a2b5fce commit d18a01f

File tree

8 files changed

+68
-67
lines changed

8 files changed

+68
-67
lines changed

bower.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
"package.json"
2121
],
2222
"dependencies": {
23-
"purescript-datetime": "^2.0.0",
24-
"purescript-foreign": "^3.0.0",
25-
"purescript-node-buffer": "^2.0.0",
26-
"purescript-node-path": "^1.0.0",
27-
"purescript-unsafe-coerce": "^2.0.0",
28-
"purescript-nullable": "^2.0.0",
29-
"purescript-node-streams": "^2.0.0",
30-
"purescript-exceptions": "^2.0.0",
31-
"purescript-js-date": "^3.0.0",
32-
"purescript-globals": "^2.0.0"
23+
"purescript-datetime": "^3.0.0",
24+
"purescript-foreign": "^4.0.0",
25+
"purescript-node-buffer": "^3.0.0",
26+
"purescript-node-path": "^2.0.0",
27+
"purescript-unsafe-coerce": "^3.0.0",
28+
"purescript-nullable": "^3.0.0",
29+
"purescript-node-streams": "^3.0.0",
30+
"purescript-exceptions": "^3.0.0",
31+
"purescript-js-date": "^4.0.0",
32+
"purescript-globals": "^3.0.0"
3333
},
3434
"devDependencies": {
35-
"purescript-console": "^2.0.0"
35+
"purescript-console": "^3.0.0"
3636
}
3737
}

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"private": true,
33
"scripts": {
44
"clean": "rimraf output && rimraf .pulp-cache",
5-
"build": "jshint src && jscs src && pulp build --censor-lib --strict",
5+
"build": "jshint src && jscs src && pulp build -- --censor-lib --strict",
66
"test": "pulp test"
77
},
88
"devDependencies": {
99
"jscs": "^3.0.7",
10-
"jshint": "^2.9.2",
11-
"pulp": "^9.0.1",
12-
"purescript-psa": "^0.3.9",
13-
"rimraf": "^2.5.4"
10+
"jshint": "^2.9.4",
11+
"pulp": "^11.0.0",
12+
"purescript-psa": "^0.5.0",
13+
"rimraf": "^2.6.1"
1414
}
1515
}

src/Node/FS.purs

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ module Node.FS
1313
) where
1414

1515
import Prelude
16+
import Control.Monad.Eff (kind Effect)
1617

1718
-- | Effect type for file system usage.
18-
foreign import data FS :: !
19+
foreign import data FS :: Effect
1920

20-
foreign import data FileDescriptor :: *
21+
foreign import data FileDescriptor :: Type
2122

2223
data FileFlags = R | R_PLUS | RS | RS_PLUS
2324
| W | WX | W_PLUS | WX_PLUS

src/Node/FS/Sync.purs

+32-32
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ import Control.Monad.Eff.Exception (EXCEPTION)
3737
import Data.DateTime (DateTime)
3838
import Data.Time.Duration (Milliseconds(..))
3939
import Data.DateTime.Instant (fromDateTime, unInstant)
40-
import Data.Function.Uncurried (Fn1, Fn5, Fn3, Fn2,
40+
import Data.Function.Uncurried (Fn1, Fn5, Fn3, Fn2,
4141
runFn1, runFn5, runFn3, runFn2)
4242
import Data.Nullable (Nullable(), toNullable)
4343
import Data.Int (round)
4444
import Data.Maybe (Maybe(..))
4545
import Node.Buffer (Buffer(), BUFFER(), size)
4646
import Node.Encoding (Encoding)
4747

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,
5050
fileFlagsToNode, symlinkTypeToNode)
5151
import Node.FS.Stats (StatsObj, Stats(..))
5252
import Node.Path (FilePath())
@@ -83,15 +83,15 @@ fs = unsafeRequireFS
8383
-- | Renames a file.
8484
rename :: forall eff. FilePath
8585
-> FilePath
86-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
86+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
8787

8888
rename oldFile newFile = mkEff $ \_ -> runFn2
8989
fs.renameSync oldFile newFile
9090

9191
-- | Truncates a file to the specified length.
9292
truncate :: forall eff. FilePath
9393
-> Int
94-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
94+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
9595

9696
truncate file len = mkEff $ \_ -> runFn2
9797
fs.truncateSync file len
@@ -100,30 +100,30 @@ truncate file len = mkEff $ \_ -> runFn2
100100
chown :: forall eff. FilePath
101101
-> Int
102102
-> Int
103-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
103+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
104104

105105
chown file uid gid = mkEff $ \_ -> runFn3
106106
fs.chownSync file uid gid
107107

108108
-- | Changes the permissions of a file.
109109
chmod :: forall eff. FilePath
110110
-> Perms
111-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
111+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
112112

113113
chmod file perms = mkEff $ \_ -> runFn2
114114
fs.chmodSync file (permsToString perms)
115115

116116
-- | Gets file statistics.
117117
stat :: forall eff. FilePath
118-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Stats
118+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Stats
119119

120120
stat file = map Stats $ mkEff $ \_ -> runFn1
121121
fs.statSync file
122122

123123
-- | Creates a link to an existing file.
124124
link :: forall eff. FilePath
125125
-> FilePath
126-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
126+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
127127

128128
link src dst = mkEff $ \_ -> runFn2
129129
fs.linkSync src dst
@@ -132,21 +132,21 @@ link src dst = mkEff $ \_ -> runFn2
132132
symlink :: forall eff. FilePath
133133
-> FilePath
134134
-> SymlinkType
135-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
135+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
136136

137137
symlink src dst ty = mkEff $ \_ -> runFn3
138138
fs.symlinkSync src dst (symlinkTypeToNode ty)
139139

140140
-- | Reads the value of a symlink.
141141
readlink :: forall eff. FilePath
142-
-> Eff (fs :: FS, err :: EXCEPTION | eff) FilePath
142+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) FilePath
143143

144144
readlink path = mkEff $ \_ -> runFn1
145145
fs.readlinkSync path
146146

147147
-- | Find the canonicalized absolute location for a path.
148148
realpath :: forall eff. FilePath
149-
-> Eff (fs :: FS, err :: EXCEPTION | eff) FilePath
149+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) FilePath
150150

151151
realpath path = mkEff $ \_ -> runFn2
152152
fs.realpathSync path {}
@@ -155,42 +155,42 @@ realpath path = mkEff $ \_ -> runFn2
155155
-- | already resolved paths.
156156
realpath' :: forall eff cache. FilePath
157157
-> { | cache }
158-
-> Eff (fs :: FS, err :: EXCEPTION | eff) FilePath
158+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) FilePath
159159

160160
realpath' path cache = mkEff $ \_ -> runFn2
161161
fs.realpathSync path cache
162162

163163
-- | Deletes a file.
164164
unlink :: forall eff. FilePath
165-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
165+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
166166

167167
unlink file = mkEff $ \_ -> runFn1
168168
fs.unlinkSync file
169169

170170
-- | Deletes a directory.
171171
rmdir :: forall eff. FilePath
172-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
172+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
173173

174174
rmdir file = mkEff $ \_ -> runFn1
175175
fs.rmdirSync file
176176

177177
-- | Makes a new directory.
178178
mkdir :: forall eff. FilePath
179-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
179+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
180180

181181
mkdir = flip mkdir' $ mkPerms all all all
182182

183183
-- | Makes a new directory with the specified permissions.
184184
mkdir' :: forall eff. FilePath
185185
-> Perms
186-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
186+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
187187

188188
mkdir' file perms = mkEff $ \_ -> runFn2
189189
fs.mkdirSync file (permsToString perms)
190190

191191
-- | Reads the contents of a directory.
192192
readdir :: forall eff. FilePath
193-
-> Eff (fs :: FS, err :: EXCEPTION | eff) (Array FilePath)
193+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) (Array FilePath)
194194

195195
readdir file = mkEff $ \_ -> runFn1
196196
fs.readdirSync file
@@ -199,7 +199,7 @@ readdir file = mkEff $ \_ -> runFn1
199199
utimes :: forall eff. FilePath
200200
-> DateTime
201201
-> DateTime
202-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
202+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
203203

204204
utimes file atime mtime = mkEff $ \_ -> runFn3
205205
fs.utimesSync file
@@ -212,23 +212,23 @@ utimes file atime mtime = mkEff $ \_ -> runFn3
212212

213213
-- | Reads the entire contents of a file returning the result as a raw buffer.
214214
readFile :: forall eff. FilePath
215-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Buffer
215+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Buffer
216216

217217
readFile file = mkEff $ \_ -> runFn2
218218
fs.readFileSync file {}
219219

220220
-- | Reads the entire contents of a text file with the specified encoding.
221221
readTextFile :: forall eff. Encoding
222222
-> FilePath
223-
-> Eff (fs :: FS, err :: EXCEPTION | eff) String
223+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) String
224224

225225
readTextFile encoding file = mkEff $ \_ -> runFn2
226226
fs.readFileSync file { encoding: show encoding }
227227

228228
-- | Writes a buffer to a file.
229229
writeFile :: forall eff. FilePath
230230
-> Buffer
231-
-> Eff (buffer :: BUFFER, fs :: FS, err :: EXCEPTION | eff) Unit
231+
-> Eff (buffer :: BUFFER, fs :: FS, exception :: EXCEPTION | eff) Unit
232232

233233
writeFile file buff = mkEff $ \_ -> runFn3
234234
fs.writeFileSync file buff {}
@@ -237,15 +237,15 @@ writeFile file buff = mkEff $ \_ -> runFn3
237237
writeTextFile :: forall eff. Encoding
238238
-> FilePath
239239
-> String
240-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
240+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
241241

242242
writeTextFile encoding file text = mkEff $ \_ -> runFn3
243243
fs.writeFileSync file text { encoding: show encoding }
244244

245245
-- | Appends the contents of a buffer to a file.
246246
appendFile :: forall eff. FilePath
247247
-> Buffer
248-
-> Eff (buffer :: BUFFER, fs :: FS, err :: EXCEPTION | eff) Unit
248+
-> Eff (buffer :: BUFFER, fs :: FS, exception :: EXCEPTION | eff) Unit
249249

250250
appendFile file buff = mkEff $ \_ -> runFn3
251251
fs.appendFileSync file buff {}
@@ -254,7 +254,7 @@ appendFile file buff = mkEff $ \_ -> runFn3
254254
appendTextFile :: forall eff. Encoding
255255
-> FilePath
256256
-> String
257-
-> Eff (fs :: FS, err :: EXCEPTION | eff) Unit
257+
-> Eff (fs :: FS, exception :: EXCEPTION | eff) Unit
258258

259259
appendTextFile encoding file buff = mkEff $ \_ -> runFn3
260260
fs.appendFileSync file buff { encoding: show encoding }
@@ -270,7 +270,7 @@ fdOpen :: forall eff.
270270
FilePath
271271
-> FileFlags
272272
-> Maybe FileMode
273-
-> Eff (err :: EXCEPTION, fs :: FS | eff) FileDescriptor
273+
-> Eff (exception :: EXCEPTION, fs :: FS | eff) FileDescriptor
274274
fdOpen file flags mode = mkEff $ \_ ->
275275
runFn3 fs.openSync file (fileFlagsToNode flags) (toNullable mode)
276276

@@ -282,7 +282,7 @@ fdRead :: forall eff.
282282
-> BufferOffset
283283
-> BufferLength
284284
-> Maybe FilePosition
285-
-> Eff (buffer :: BUFFER, err :: EXCEPTION, fs :: FS | eff) ByteCount
285+
-> Eff (buffer :: BUFFER, exception :: EXCEPTION, fs :: FS | eff) ByteCount
286286
fdRead fd buff off len pos =
287287
mkEff $ \_ -> runFn5 fs.readSync fd buff off len (toNullable pos)
288288

@@ -291,7 +291,7 @@ fdRead fd buff off len pos =
291291
fdNext :: forall eff.
292292
FileDescriptor
293293
-> Buffer
294-
-> Eff (buffer :: BUFFER, err :: EXCEPTION, fs :: FS | eff) ByteCount
294+
-> Eff (buffer :: BUFFER, exception :: EXCEPTION, fs :: FS | eff) ByteCount
295295
fdNext fd buff = do
296296
sz <- size buff
297297
fdRead fd buff 0 sz Nothing
@@ -304,7 +304,7 @@ fdWrite :: forall eff.
304304
-> BufferOffset
305305
-> BufferLength
306306
-> Maybe FilePosition
307-
-> Eff (buffer :: BUFFER, err :: EXCEPTION, fs :: FS | eff) ByteCount
307+
-> Eff (buffer :: BUFFER, exception :: EXCEPTION, fs :: FS | eff) ByteCount
308308
fdWrite fd buff off len pos =
309309
mkEff $ \_ -> runFn5 fs.writeSync fd buff off len (toNullable pos)
310310

@@ -313,7 +313,7 @@ fdWrite fd buff off len pos =
313313
fdAppend :: forall eff.
314314
FileDescriptor
315315
-> Buffer
316-
-> Eff (buffer :: BUFFER, err :: EXCEPTION, fs :: FS | eff) ByteCount
316+
-> Eff (buffer :: BUFFER, exception :: EXCEPTION, fs :: FS | eff) ByteCount
317317
fdAppend fd buff = do
318318
sz <- size buff
319319
fdWrite fd buff 0 sz Nothing
@@ -322,12 +322,12 @@ fdAppend fd buff = do
322322
-- | for details.
323323
fdFlush :: forall eff.
324324
FileDescriptor
325-
-> Eff (err :: EXCEPTION, fs :: FS | eff) Unit
325+
-> Eff (exception :: EXCEPTION, fs :: FS | eff) Unit
326326
fdFlush fd = mkEff $ \_ -> runFn1 fs.fsyncSync fd
327327

328328
-- | Close a file synchronously. See the [Node documentation](http://nodejs.org/api/fs.html#fs_fs_closesync_fd)
329329
-- | for details.
330330
fdClose :: forall eff.
331331
FileDescriptor
332-
-> Eff (err :: EXCEPTION, fs :: FS | eff) Unit
332+
-> Eff (exception :: EXCEPTION, fs :: FS | eff) Unit
333333
fdClose fd = mkEff $ \_ -> runFn1 fs.closeSync fd

test/Main.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import Test as Test
1010
import TestAsync as TestAsync
1111
import Test.Streams as Streams
1212

13-
main::forall e. Eff (fs :: FS , console :: CONSOLE ,
14-
err :: EXCEPTION , buffer :: BUFFER | e) Unit
13+
main::forall e. Eff (fs :: FS , console :: CONSOLE ,
14+
exception :: EXCEPTION , buffer :: BUFFER | e) Unit
1515
main = do
1616
Test.main
1717
TestAsync.main

test/Streams.purs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ import Node.FS (FS)
1212
import Node.FS.Stream (createWriteStream, createReadStream)
1313
import Node.FS.Sync as Sync
1414

15-
main::forall e. Eff (fs::FS, console::CONSOLE, err::EXCEPTION | e) Unit
15+
main::forall e. Eff (fs::FS, console::CONSOLE, exception::EXCEPTION | e) Unit
1616
main = do
1717
let fp = Path.concat
1818

19-
log "Testing streams"
19+
_ <- log "Testing streams"
2020

2121
r <- createReadStream (fp ["test", "Streams.purs"])
2222
w <- createWriteStream (fp ["tmp", "Streams.purs"])
2323

24-
Stream.pipe r w
24+
_ <- Stream.pipe r w
2525

2626
Stream.onEnd r do
2727
src <- Sync.readTextFile UTF8 (fp ["test", "Streams.purs"])

0 commit comments

Comments
 (0)