Skip to content

Commit 77d56f5

Browse files
authored
Merge pull request #7 from purescript-contrib/compiler/0.12
Compiler/0.12
2 parents 1aadf04 + ca7bfd0 commit 77d56f5

File tree

6 files changed

+36
-49
lines changed

6 files changed

+36
-49
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ language: node_js
22
dist: trusty
33
sudo: required
44
node_js: stable
5+
env:
6+
- PATH=$HOME/purescript:$PATH
57
install:
8+
- npm install -g bower
9+
- 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')
10+
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
11+
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
12+
- chmod a+x $HOME/purescript
613
- npm install -g bower
714
- npm install
815
- bower install --production

bower.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"package.json"
1818
],
1919
"dependencies": {
20-
"purescript-eff": "^3.0.0"
20+
"purescript-effect": "^2.0.0"
2121
},
2222
"devDependencies": {
23-
"purescript-assert": "^3.0.0",
24-
"purescript-refs": "^3.0.0",
25-
"purescript-console": "^3.0.0"
23+
"purescript-assert": "^4.0.0",
24+
"purescript-refs": "^4.0.0",
25+
"purescript-console": "^4.1.0"
2626
}
2727
}

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"eslint": "^3.19.0",
10-
"pulp": "^11.0.0",
11-
"purescript-psa": "^0.5.0",
12-
"purescript": "^0.11.1",
13-
"rimraf": "^2.6.1"
9+
"eslint": "^4.19.1",
10+
"pulp": "^12.2.0",
11+
"purescript-psa": "^0.6.0",
12+
"rimraf": "^2.6.2"
1413
}
1514
}
File renamed without changes.
Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module Control.Monad.Eff.Timer
2-
( TIMER
3-
, TimeoutId
1+
module Effect.Timer
2+
( TimeoutId
43
, setTimeout
54
, clearTimeout
65
, IntervalId
@@ -10,10 +9,7 @@ module Control.Monad.Eff.Timer
109

1110
import Prelude
1211

13-
import Control.Monad.Eff (kind Effect, Eff)
14-
15-
-- | The effect for the usage of a JavaScript timer.
16-
foreign import data TIMER :: Effect
12+
import Effect (Effect)
1713

1814
-- | The ID of a timer started with `setTimeout`.
1915
newtype TimeoutId = TimeoutId Int
@@ -26,18 +22,11 @@ derive instance ordTimeoutId :: Ord TimeoutId
2622
-- |
2723
-- | The timeout delay value is capped at 4ms by the JS API, any value less than
2824
-- | this will be clamped.
29-
foreign import setTimeout
30-
:: forall eff
31-
. Int
32-
-> Eff (timer :: TIMER | eff) Unit
33-
-> Eff (timer :: TIMER | eff) TimeoutId
25+
foreign import setTimeout :: Int -> Effect Unit -> Effect TimeoutId
3426

3527
-- | Cancels a timeout. If the timeout has already been cancelled or has already
3628
-- | elapsed this will have no effect.
37-
foreign import clearTimeout
38-
:: forall eff
39-
. TimeoutId
40-
-> Eff (timer :: TIMER | eff) Unit
29+
foreign import clearTimeout :: TimeoutId -> Effect Unit
4130

4231
-- | The ID of a timer started with `setInterval`.
4332
newtype IntervalId = IntervalId Int
@@ -51,15 +40,8 @@ derive instance ordIntervalId :: Ord IntervalId
5140
-- |
5241
-- | The interval delay value is capped at 4ms by the JS API, any value less
5342
-- | than this will be clamped.
54-
foreign import setInterval
55-
:: forall eff
56-
. Int
57-
-> Eff (timer :: TIMER | eff) Unit
58-
-> Eff (timer :: TIMER | eff) IntervalId
43+
foreign import setInterval :: Int -> Effect Unit -> Effect IntervalId
5944

6045
-- | Cancels an interval timer. If the interval has already been cancelled this
6146
-- | will have no effect.
62-
foreign import clearInterval
63-
:: forall eff
64-
. IntervalId
65-
-> Eff (timer :: TIMER | eff) Unit
47+
foreign import clearInterval :: IntervalId -> Effect Unit

test/Main.purs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,50 @@ module Test.Main where
22

33
import Prelude
44

5-
import Control.Monad.Eff (Eff)
6-
import Control.Monad.Eff.Console as C
7-
import Control.Monad.Eff.Ref as R
8-
import Control.Monad.Eff.Timer as T
5+
import Effect (Effect)
6+
import Effect.Console as C
7+
import Effect.Ref as R
8+
import Effect.Timer as T
9+
import Test.Assert (assert)
910

10-
import Test.Assert (ASSERT, assert)
11-
12-
main :: Eff (ref :: R.REF, timer :: T.TIMER, console :: C.CONSOLE, assert :: ASSERT) Unit
11+
main :: Effect Unit
1312
main = do
14-
counter <- R.newRef 0
13+
counter <- R.new 0
1514

1615
void $ T.setTimeout 10 do
1716
C.log "timeout increment counter"
18-
R.modifyRef counter (_ + 1)
17+
void $ R.modify (_ + 1) counter
1918

2019
void $ T.setTimeout 50 do
2120
C.log "timeout check counter"
22-
n <- R.readRef counter
21+
n <- R.read counter
2322
assert $ n == 1
2423

2524
void $ T.setTimeout 100 do
2625

2726
t <- T.setTimeout 20 do
28-
R.modifyRef counter (_ + 1)
27+
void $ R.modify (_ + 1) counter
2928

3029
T.clearTimeout t
3130

3231
void $ T.setTimeout 50 do
3332
C.log "check timeout never ran"
34-
n <- R.readRef counter
33+
n <- R.read counter
3534
assert $ n == 1
3635

3736
void $ T.setTimeout 200 do
3837

3938
i <- T.setInterval 20 do
4039
C.log "interval increment counter"
41-
R.modifyRef counter (_ + 1)
40+
void $ R.modify (_ + 1) counter
4241

4342
void $ T.setTimeout 90 do
4443
T.clearInterval i
4544
C.log "interval check counter"
46-
n <- R.readRef counter
45+
n <- R.read counter
4746
assert $ n == 5
4847

4948
void $ T.setTimeout 150 do
5049
C.log "check interval has stopped"
51-
n <- R.readRef counter
50+
n <- R.read counter
5251
assert $ n == 5

0 commit comments

Comments
 (0)