Skip to content

Commit 0f2b352

Browse files
authored
Merge pull request #13 from anilanar/ps-0.11
update for purescript 0.11
2 parents f342cbc + 3e4cbf2 commit 0f2b352

File tree

4 files changed

+47
-47
lines changed

4 files changed

+47
-47
lines changed

bower.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
"url": "git://github.com/purescript-node/purescript-node-streams.git"
1313
},
1414
"devDependencies": {
15-
"purescript-console": "^2.0.0",
16-
"purescript-assert": "^2.0.0",
17-
"purescript-partial": "^1.1.2"
15+
"purescript-console": "^3.0.0",
16+
"purescript-assert": "^3.0.0",
17+
"purescript-partial": "^1.2.0"
1818
},
1919
"dependencies": {
20-
"purescript-eff": "^2.0.0",
21-
"purescript-node-buffer": "^2.0.0",
22-
"purescript-prelude": "^2.1.0",
23-
"purescript-either": "^2.0.0",
24-
"purescript-exceptions": "^2.0.0"
20+
"purescript-eff": "^3.0.0",
21+
"purescript-node-buffer": "^3.0.0",
22+
"purescript-prelude": "^3.0.0",
23+
"purescript-either": "^3.0.0",
24+
"purescript-exceptions": "^3.0.0"
2525
}
2626
}

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
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.3",
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
"stream-buffers": "^3.0.1"
1515
}
1616
}

src/Node/Stream.purs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module Node.Stream
3232

3333
import Prelude
3434

35-
import Control.Monad.Eff (Eff)
35+
import Control.Monad.Eff (Eff, kind Effect)
3636
import Control.Monad.Eff.Exception (throw, EXCEPTION(), Error())
3737
import Control.Monad.Eff.Unsafe (unsafeCoerceEff)
3838
import Data.Either (Either(..))
@@ -47,7 +47,7 @@ import Node.Encoding (Encoding)
4747
-- |
4848
-- | - Whether reading and/or writing from/to the stream are allowed.
4949
-- | - Effects associated with reading/writing from/to this stream.
50-
foreign import data Stream :: # * -> # ! -> *
50+
foreign import data Stream :: # Type -> # Effect -> Type
5151

5252
-- | A phantom type associated with _readable streams_.
5353
data Read
@@ -66,7 +66,7 @@ type Duplex = Stream (read :: Read, write :: Write)
6666

6767
foreign import undefined :: forall a. a
6868

69-
foreign import data Chunk :: *
69+
foreign import data Chunk :: Type
7070

7171
foreign import readChunkImpl
7272
:: (forall l r. l -> Either l r)
@@ -81,9 +81,9 @@ readChunk = readChunkImpl Left Right
8181
-- | if `setEncoding` has been called on the stream.
8282
onData
8383
:: forall w eff
84-
. Readable w (err :: EXCEPTION | eff)
85-
-> (Buffer -> Eff (err :: EXCEPTION | eff) Unit)
86-
-> Eff (err :: EXCEPTION | eff) Unit
84+
. Readable w (exception :: EXCEPTION | eff)
85+
-> (Buffer -> Eff (exception :: EXCEPTION | eff) Unit)
86+
-> Eff (exception :: EXCEPTION | eff) Unit
8787
onData r cb =
8888
onDataEither r (cb <=< fromEither)
8989
where
@@ -96,9 +96,9 @@ onData r cb =
9696

9797
read
9898
:: forall w eff
99-
. Readable w (err :: EXCEPTION | eff)
99+
. Readable w (exception :: EXCEPTION | eff)
100100
-> Maybe Int
101-
-> Eff (err :: EXCEPTION | eff) (Maybe Buffer)
101+
-> Eff (exception :: EXCEPTION | eff) (Maybe Buffer)
102102
read r size = do
103103
v <- readEither r size
104104
case v of
@@ -108,10 +108,10 @@ read r size = do
108108

109109
readString
110110
:: forall w eff
111-
. Readable w (err :: EXCEPTION | eff)
111+
. Readable w (exception :: EXCEPTION | eff)
112112
-> Maybe Int
113113
-> Encoding
114-
-> Eff (err :: EXCEPTION | eff) (Maybe String)
114+
-> Eff (exception :: EXCEPTION | eff) (Maybe String)
115115
readString r size enc = do
116116
v <- readEither r size
117117
case v of
@@ -140,20 +140,20 @@ foreign import readImpl
140140
-- | has been called on the stream.
141141
onDataString
142142
:: forall w eff
143-
. Readable w (err :: EXCEPTION | eff)
143+
. Readable w (exception :: EXCEPTION | eff)
144144
-> Encoding
145-
-> (String -> Eff (err :: EXCEPTION | eff) Unit)
146-
-> Eff (err :: EXCEPTION | eff) Unit
145+
-> (String -> Eff (exception :: EXCEPTION | eff) Unit)
146+
-> Eff (exception :: EXCEPTION | eff) Unit
147147
onDataString r enc cb = onData r (cb <=< unsafeCoerceEff <<< Buffer.toString enc)
148148

149149
-- | Listen for `data` events, returning data in an `Either String Buffer`. This
150150
-- | function is provided for the (hopefully rare) case that `setEncoding` has
151151
-- | been called on the stream.
152152
onDataEither
153153
:: forall r eff
154-
. Readable r (err :: EXCEPTION | eff)
155-
-> (Either String Buffer -> Eff (err :: EXCEPTION | eff) Unit)
156-
-> Eff (err :: EXCEPTION | eff) Unit
154+
. Readable r (exception :: EXCEPTION | eff)
155+
-> (Either String Buffer -> Eff (exception :: EXCEPTION | eff) Unit)
156+
-> Eff (exception :: EXCEPTION | eff) Unit
157157
onDataEither r cb = onDataEitherImpl readChunk r cb
158158

159159
foreign import onDataEitherImpl

test/Main.purs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Test.Main where
22

33
import Prelude
4-
import Control.Monad.Eff (Eff)
4+
import Control.Monad.Eff (Eff, kind Effect)
55
import Control.Monad.Eff.Console (CONSOLE, log)
66
import Control.Monad.Eff.Exception (EXCEPTION)
77
import Node.Encoding (Encoding(..))
@@ -12,11 +12,11 @@ import Data.Either (Either(..))
1212
import Data.Maybe (Maybe(..), fromJust, isNothing, isJust)
1313
import Partial.Unsafe (unsafePartial)
1414

15-
assertEqual :: forall e a. (Show a, Eq a) => a -> a -> Eff (assert :: ASSERT | e) Unit
15+
assertEqual :: forall e a. Show a => Eq a => a -> a -> Eff (assert :: ASSERT | e) Unit
1616
assertEqual x y =
1717
assert' (show x <> " did not equal " <> show y) (x == y)
1818

19-
foreign import data STREAM_BUFFER :: !
19+
foreign import data STREAM_BUFFER :: Effect
2020

2121
foreign import writableStreamBuffer :: forall eff. Eff (sb :: STREAM_BUFFER | eff) (Writable () (sb :: STREAM_BUFFER | eff))
2222

@@ -34,20 +34,20 @@ main
3434
. Eff ( console :: CONSOLE
3535
, sb :: STREAM_BUFFER
3636
, assert :: ASSERT
37-
, err :: EXCEPTION
37+
, exception :: EXCEPTION
3838
, buffer :: Buffer.BUFFER
3939
, stream :: PASS_THROUGH
4040
, gzip :: GZIP
4141
| eff ) Boolean
4242
main = do
4343
log "setDefaultEncoding should not affect writing"
44-
testSetDefaultEncoding
44+
_ <- testSetDefaultEncoding
4545

4646
log "setEncoding should not affect reading"
4747
testSetEncoding
4848

4949
log "test pipe"
50-
testPipe
50+
_ <- testPipe
5151

5252
log "test manual reads"
5353
testReads
@@ -58,12 +58,12 @@ testString = "üöß💡"
5858
testReads
5959
:: forall eff
6060
. Eff ( stream :: PASS_THROUGH
61-
, err :: EXCEPTION
61+
, exception :: EXCEPTION
6262
, buffer :: Buffer.BUFFER
6363
, assert :: ASSERT
6464
| eff ) Boolean
6565
testReads = do
66-
testReadString
66+
_ <- testReadString
6767
testReadBuf
6868

6969
where
@@ -89,7 +89,7 @@ testReads = do
8989
onReadable sIn do
9090
buf <- read sIn Nothing
9191
assert (isJust buf)
92-
assertEqual <$> (Buffer.toString UTF8 (unsafePartial (fromJust buf)))
92+
_ <- assertEqual <$> (Buffer.toString UTF8 (unsafePartial (fromJust buf)))
9393
<*> pure testString
9494
pure unit
9595

@@ -103,7 +103,7 @@ testSetDefaultEncoding
103103
| eff ) Boolean
104104
testSetDefaultEncoding = do
105105
w1 <- writableStreamBuffer
106-
check w1
106+
_ <- check w1
107107

108108
w2 <- writableStreamBuffer
109109
setDefaultEncoding w2 UCS2
@@ -118,7 +118,7 @@ testSetDefaultEncoding = do
118118
testSetEncoding
119119
:: forall eff
120120
. Eff ( sb :: STREAM_BUFFER
121-
, err :: EXCEPTION
121+
, exception :: EXCEPTION
122122
, buffer :: Buffer.BUFFER
123123
, assert :: ASSERT
124124
| eff ) Unit
@@ -137,14 +137,14 @@ testSetEncoding = do
137137

138138
onData r1 \buf -> unsafePartial do
139139
onDataEither r2 \(Left str) -> do
140-
assertEqual <$> Buffer.toString enc buf <*> pure testString
140+
_ <- assertEqual <$> Buffer.toString enc buf <*> pure testString
141141
assertEqual str testString
142142

143143
testPipe
144144
:: forall eff
145145
. Eff ( stream :: PASS_THROUGH
146146
, gzip :: GZIP
147-
, err :: EXCEPTION
147+
, exception :: EXCEPTION
148148
, assert :: ASSERT
149149
, console :: CONSOLE
150150
| eff ) Boolean
@@ -155,23 +155,23 @@ testPipe = do
155155
unzip <- createGunzip
156156

157157
log "pipe 1"
158-
sIn `pipe` zip
158+
_ <- sIn `pipe` zip
159159
log "pipe 2"
160-
zip `pipe` unzip
160+
_ <- zip `pipe` unzip
161161
log "pipe 3"
162-
unzip `pipe` sOut
162+
_ <- unzip `pipe` sOut
163163

164164
writeString sIn UTF8 testString do
165165
end sIn do
166166
onDataString sOut UTF8 \str -> do
167167
assertEqual str testString
168168

169-
foreign import data GZIP :: !
169+
foreign import data GZIP :: Effect
170170

171171
foreign import createGzip :: forall eff. Eff (gzip :: GZIP | eff) (Duplex (gzip :: GZIP | eff))
172172
foreign import createGunzip :: forall eff. Eff (gzip :: GZIP | eff) (Duplex (gzip :: GZIP | eff))
173173

174-
foreign import data PASS_THROUGH :: !
174+
foreign import data PASS_THROUGH :: Effect
175175

176176
-- | Create a PassThrough stream, which simply writes its input to its output.
177177
foreign import passThrough :: forall eff. Eff (stream :: PASS_THROUGH | eff) (Duplex (stream :: PASS_THROUGH | eff))

0 commit comments

Comments
 (0)