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

Commit f92a544

Browse files
paf31felixSchl
authored andcommitted
Update to purescript 0.7
1 parent c115a73 commit f92a544

File tree

5 files changed

+48
-62
lines changed

5 files changed

+48
-62
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.psci_modules
12
*.sw[mnopqrstuv]
23
*.un~
34
.psci

README.md

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# Module Documentation
2-
31
## Module Node.FS.Aff
42

53

6-
74
[Node.FS][Node.FS] Wrappers for [purescript-aff][aff]
85

96
The `Aff` monad let's you write async code with ease.
@@ -18,7 +15,7 @@ main = launchAff do
1815
return $
1916
FS.isDirectory stat
2017
&& (maybe false (fromChar >>> (/= ".")) $ charAt 0 file)
21-
liftEff $ Debug.Trace.trace $ show files'
18+
liftEff $ print files'
2219
```
2320

2421
That was easy. For a working example, see [example.purs][example].
@@ -31,7 +28,7 @@ To build the example, run `gulp example`.
3128
#### `rename`
3229

3330
``` purescript
34-
rename :: forall eff. FilePath -> FilePath -> Aff (fs :: F.FS | eff) Unit
31+
rename :: forall eff. FilePath -> FilePath -> Aff (fs :: FS | eff) Unit
3532
```
3633

3734

@@ -41,7 +38,7 @@ Rename a file.
4138
#### `truncate`
4239

4340
``` purescript
44-
truncate :: forall eff. FilePath -> Number -> Aff (fs :: F.FS | eff) Unit
41+
truncate :: forall eff. FilePath -> Number -> Aff (fs :: FS | eff) Unit
4542
```
4643

4744

@@ -51,7 +48,7 @@ Truncates a file to the specified length.
5148
#### `chown`
5249

5350
``` purescript
54-
chown :: forall eff. FilePath -> Number -> Number -> Aff (fs :: F.FS | eff) Unit
51+
chown :: forall eff. FilePath -> Number -> Number -> Aff (fs :: FS | eff) Unit
5552
```
5653

5754

@@ -61,7 +58,7 @@ Changes the ownership of a file.
6158
#### `chmod`
6259

6360
``` purescript
64-
chmod :: forall eff. FilePath -> Perms -> Aff (fs :: F.FS | eff) Unit
61+
chmod :: forall eff. FilePath -> Perms -> Aff (fs :: FS | eff) Unit
6562
```
6663

6764

@@ -71,7 +68,7 @@ Changes the permissions of a file.
7168
#### `stat`
7269

7370
``` purescript
74-
stat :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Stats
71+
stat :: forall eff. FilePath -> Aff (fs :: FS | eff) Stats
7572
```
7673

7774

@@ -81,7 +78,7 @@ Gets file statistics.
8178
#### `link`
8279

8380
``` purescript
84-
link :: forall eff. FilePath -> FilePath -> Aff (fs :: F.FS | eff) Unit
81+
link :: forall eff. FilePath -> FilePath -> Aff (fs :: FS | eff) Unit
8582
```
8683

8784

@@ -91,7 +88,7 @@ Creates a link to an existing file.
9188
#### `symlink`
9289

9390
``` purescript
94-
symlink :: forall eff. FilePath -> FilePath -> F.SymlinkType -> Aff (fs :: F.FS | eff) Unit
91+
symlink :: forall eff. FilePath -> FilePath -> SymlinkType -> Aff (fs :: FS | eff) Unit
9592
```
9693

9794

@@ -101,7 +98,7 @@ Creates a symlink.
10198
#### `readlink`
10299

103100
``` purescript
104-
readlink :: forall eff. FilePath -> Aff (fs :: F.FS | eff) FilePath
101+
readlink :: forall eff. FilePath -> Aff (fs :: FS | eff) FilePath
105102
```
106103

107104

@@ -111,7 +108,7 @@ Reads the value of a symlink.
111108
#### `realpath`
112109

113110
``` purescript
114-
realpath :: forall eff. FilePath -> Aff (fs :: F.FS | eff) FilePath
111+
realpath :: forall eff. FilePath -> Aff (fs :: FS | eff) FilePath
115112
```
116113

117114

@@ -121,7 +118,7 @@ Find the canonicalized absolute location for a path.
121118
#### `realpath'`
122119

123120
``` purescript
124-
realpath' :: forall eff cache. FilePath -> { | cache } -> Aff (fs :: F.FS | eff) FilePath
121+
realpath' :: forall eff cache. FilePath -> { | cache } -> Aff (fs :: FS | eff) FilePath
125122
```
126123

127124

@@ -132,7 +129,7 @@ for already resolved paths.
132129
#### `unlink`
133130

134131
``` purescript
135-
unlink :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Unit
132+
unlink :: forall eff. FilePath -> Aff (fs :: FS | eff) Unit
136133
```
137134

138135

@@ -142,7 +139,7 @@ Deletes a file.
142139
#### `rmdir`
143140

144141
``` purescript
145-
rmdir :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Unit
142+
rmdir :: forall eff. FilePath -> Aff (fs :: FS | eff) Unit
146143
```
147144

148145

@@ -152,7 +149,7 @@ Deletes a directory.
152149
#### `mkdir`
153150

154151
``` purescript
155-
mkdir :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Unit
152+
mkdir :: forall eff. FilePath -> Aff (fs :: FS | eff) Unit
156153
```
157154

158155

@@ -162,7 +159,7 @@ Makes a new directory.
162159
#### `mkdir'`
163160

164161
``` purescript
165-
mkdir' :: forall eff. FilePath -> Perms -> Aff (fs :: F.FS | eff) Unit
162+
mkdir' :: forall eff. FilePath -> Perms -> Aff (fs :: FS | eff) Unit
166163
```
167164

168165

@@ -172,7 +169,7 @@ Makes a new directory with the specified permissions.
172169
#### `readdir`
173170

174171
``` purescript
175-
readdir :: forall eff. FilePath -> Aff (fs :: F.FS | eff) [FilePath]
172+
readdir :: forall eff. FilePath -> Aff (fs :: FS | eff) (Array FilePath)
176173
```
177174

178175

@@ -182,7 +179,7 @@ Reads the contents of a directory.
182179
#### `utimes`
183180

184181
``` purescript
185-
utimes :: forall eff. FilePath -> Date -> Date -> Aff (fs :: F.FS | eff) Unit
182+
utimes :: forall eff. FilePath -> Date -> Date -> Aff (fs :: FS | eff) Unit
186183
```
187184

188185

@@ -192,7 +189,7 @@ Sets the accessed and modified times for the specified file.
192189
#### `readFile`
193190

194191
``` purescript
195-
readFile :: forall eff. FilePath -> Aff (fs :: F.FS | eff) Buffer
192+
readFile :: forall eff. FilePath -> Aff (fs :: FS | eff) Buffer
196193
```
197194

198195

@@ -202,7 +199,7 @@ Reads the entire contents of a file returning the result as a raw buffer.
202199
#### `readTextFile`
203200

204201
``` purescript
205-
readTextFile :: forall eff. Encoding -> FilePath -> Aff (fs :: F.FS | eff) String
202+
readTextFile :: forall eff. Encoding -> FilePath -> Aff (fs :: FS | eff) String
206203
```
207204

208205

@@ -212,7 +209,7 @@ Reads the entire contents of a text file with the specified encoding.
212209
#### `writeFile`
213210

214211
``` purescript
215-
writeFile :: forall eff. FilePath -> Buffer -> Aff (fs :: F.FS | eff) Unit
212+
writeFile :: forall eff. FilePath -> Buffer -> Aff (fs :: FS | eff) Unit
216213
```
217214

218215

@@ -222,7 +219,7 @@ Writes a buffer to a file.
222219
#### `writeTextFile`
223220

224221
``` purescript
225-
writeTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: F.FS | eff) Unit
222+
writeTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: FS | eff) Unit
226223
```
227224

228225

@@ -232,7 +229,7 @@ Writes text to a file using the specified encoding.
232229
#### `appendFile`
233230

234231
``` purescript
235-
appendFile :: forall eff. FilePath -> Buffer -> Aff (fs :: F.FS | eff) Unit
232+
appendFile :: forall eff. FilePath -> Buffer -> Aff (fs :: FS | eff) Unit
236233
```
237234

238235

@@ -242,7 +239,7 @@ Appends the contents of a buffer to a file.
242239
#### `appendTextFile`
243240

244241
``` purescript
245-
appendTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: F.FS | eff) Unit
242+
appendTextFile :: forall eff. Encoding -> FilePath -> String -> Aff (fs :: FS | eff) Unit
246243
```
247244

248245

@@ -252,12 +249,11 @@ Appends text to a file using the specified encoding.
252249
#### `exists`
253250

254251
``` purescript
255-
exists :: forall eff. String -> Aff (fs :: F.FS | eff) Boolean
252+
exists :: forall eff. String -> Aff (fs :: FS | eff) Boolean
256253
```
257254

258255

259256
Check to see if a file exists.
260257

261258

262259

263-

bower.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"tests"
2020
],
2121
"dependencies": {
22-
"purescript-aff": "~0.10.1",
23-
"purescript-node-fs": "~0.6.0",
24-
"purescript-either": "~0.1.8",
25-
"purescript-node-path": "~0.3.0"
22+
"purescript-aff": "~0.11.0",
23+
"purescript-node-fs": "~0.7.0",
24+
"purescript-either": "~0.2.0",
25+
"purescript-node-path": "~0.4.0"
2626
}
2727
}

example/example.purs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
module Example.Main where
1+
module Test.Main where
2+
3+
import Prelude
24

3-
import Control.Monad (filterM)
4-
import Control.Functor
5-
import Data.String (charAt, fromChar)
65
import Data.Maybe
76
import Data.Array
8-
import Control.Monad.Trans
7+
import Data.Functor
8+
import Data.String (charAt, fromChar)
9+
910
import Control.Monad.Aff
1011
import Control.Monad.Eff.Class (liftEff)
12+
import Control.Monad.Eff.Console
13+
1114
import qualified Node.Path as Path
12-
import qualified Debug.Trace as T
1315
import qualified Node.FS.Aff as FS
1416
import qualified Node.FS as FS
1517
import qualified Node.FS.Stats as FS
1618

17-
trace :: forall e a. (Show a) => a -> Aff (trace :: T.Trace | e) a
19+
trace :: forall e a. (Show a) => a -> Aff (console :: CONSOLE | e) a
1820
trace a = do
19-
liftEff $ T.trace (show a)
21+
liftEff $ log (show a)
2022
return a
2123

2224
main = launchAff do
@@ -26,4 +28,4 @@ main = launchAff do
2628
return $
2729
FS.isDirectory stat
2830
&& (maybe false (fromChar >>> (/= ".")) $ charAt 0 file)
29-
liftEff $ Debug.Trace.trace $ show files'
31+
liftEff $ log $ show files'

src/Node/FS/Aff.purs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
-- | return $
1414
-- | FS.isDirectory stat
1515
-- | && (maybe false (fromChar >>> (/= ".")) $ charAt 0 file)
16-
-- | liftEff $ Debug.Trace.trace $ show files'
16+
-- | liftEff $ print files'
1717
-- | ```
1818
-- |
1919
-- | That was easy. For a working example, see [example.purs][example].
@@ -24,9 +24,9 @@
2424
-- | [example]: http://github.com/purescript-node/purescript-node-fs-aff/blob/master/example/example.purs
2525

2626
module Node.FS.Aff
27-
( rename
28-
, truncate
29-
, chown
27+
( rename
28+
, truncate
29+
, chown
3030
, chmod
3131
, stat
3232
, link
@@ -49,6 +49,8 @@ module Node.FS.Aff
4949
, exists
5050
) where
5151

52+
import Prelude
53+
5254
import Node.Path (FilePath())
5355
import Node.FS.Perms (Perms())
5456
import Node.FS.Stats (Stats())
@@ -184,7 +186,7 @@ mkdir' = toAff2 A.mkdir'
184186
-- | Reads the contents of a directory.
185187
-- |
186188
readdir :: forall eff. FilePath
187-
-> Aff (fs :: F.FS | eff) [FilePath]
189+
-> Aff (fs :: F.FS | eff) (Array FilePath)
188190
readdir = toAff1 A.readdir
189191

190192
-- |
@@ -245,24 +247,9 @@ appendTextFile :: forall eff. Encoding
245247
-> Aff (fs :: F.FS | eff) Unit
246248
appendTextFile = toAff3 A.appendTextFile
247249

248-
-- |
249-
-- Patch `Node.FS.Async.exists`
250-
-- The current version of `Node.FS.Async.exists` fails the occurs check
251-
-- because it's callback signature does not include the FS effect.
252-
--
253-
import Data.Function
254-
foreign import mkEff
255-
"function mkEff(action) {\
256-
\ return action;\
257-
\}" :: forall eff a. (Unit -> a) -> Eff eff a
258-
foreign import fs "var fs = require('fs');" ::
259-
{ exists :: forall a. Fn2 FilePath (Boolean -> a) Unit }
260-
_exists file cb = mkEff $ \_ -> runFn2
261-
fs.exists file $ \b -> runPure (unsafeInterleaveEff (cb b))
262-
263250
-- |
264251
-- | Check to see if a file exists.
265252
-- |
266253
exists :: forall eff. String
267254
-> Aff (fs :: F.FS | eff) Boolean
268-
exists file = makeAff \_ a -> _exists file a
255+
exists file = makeAff \_ a -> A.exists file a

0 commit comments

Comments
 (0)