From ec39a09dffceb843fb4dcceda291072d3c425cbe Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Thu, 3 May 2018 16:52:08 +0100 Subject: [PATCH 1/2] Updates for 0.12 --- bower.json | 8 ++--- src/{Control/Monad/Eff => Effect}/Timer.js | 0 src/{Control/Monad/Eff => Effect}/Timer.purs | 32 +++++--------------- test/Main.purs | 29 +++++++++--------- 4 files changed, 25 insertions(+), 44 deletions(-) rename src/{Control/Monad/Eff => Effect}/Timer.js (100%) rename src/{Control/Monad/Eff => Effect}/Timer.purs (67%) diff --git a/bower.json b/bower.json index d554fdd..d5d0ffb 100644 --- a/bower.json +++ b/bower.json @@ -17,11 +17,11 @@ "package.json" ], "dependencies": { - "purescript-eff": "^3.0.0" + "purescript-effect": "#compiler/0.12" }, "devDependencies": { - "purescript-assert": "^3.0.0", - "purescript-refs": "^3.0.0", - "purescript-console": "^3.0.0" + "purescript-assert": "#compiler/0.12", + "purescript-refs": "#compiler/0.12", + "purescript-console": "#compiler/0.12" } } diff --git a/src/Control/Monad/Eff/Timer.js b/src/Effect/Timer.js similarity index 100% rename from src/Control/Monad/Eff/Timer.js rename to src/Effect/Timer.js diff --git a/src/Control/Monad/Eff/Timer.purs b/src/Effect/Timer.purs similarity index 67% rename from src/Control/Monad/Eff/Timer.purs rename to src/Effect/Timer.purs index ef8de16..9394623 100644 --- a/src/Control/Monad/Eff/Timer.purs +++ b/src/Effect/Timer.purs @@ -1,6 +1,5 @@ -module Control.Monad.Eff.Timer - ( TIMER - , TimeoutId +module Effect.Timer + ( TimeoutId , setTimeout , clearTimeout , IntervalId @@ -10,10 +9,7 @@ module Control.Monad.Eff.Timer import Prelude -import Control.Monad.Eff (kind Effect, Eff) - --- | The effect for the usage of a JavaScript timer. -foreign import data TIMER :: Effect +import Effect (Effect) -- | The ID of a timer started with `setTimeout`. newtype TimeoutId = TimeoutId Int @@ -26,18 +22,11 @@ derive instance ordTimeoutId :: Ord TimeoutId -- | -- | The timeout delay value is capped at 4ms by the JS API, any value less than -- | this will be clamped. -foreign import setTimeout - :: forall eff - . Int - -> Eff (timer :: TIMER | eff) Unit - -> Eff (timer :: TIMER | eff) TimeoutId +foreign import setTimeout :: Int -> Effect Unit -> Effect TimeoutId -- | Cancels a timeout. If the timeout has already been cancelled or has already -- | elapsed this will have no effect. -foreign import clearTimeout - :: forall eff - . TimeoutId - -> Eff (timer :: TIMER | eff) Unit +foreign import clearTimeout :: TimeoutId -> Effect Unit -- | The ID of a timer started with `setInterval`. newtype IntervalId = IntervalId Int @@ -51,15 +40,8 @@ derive instance ordIntervalId :: Ord IntervalId -- | -- | The interval delay value is capped at 4ms by the JS API, any value less -- | than this will be clamped. -foreign import setInterval - :: forall eff - . Int - -> Eff (timer :: TIMER | eff) Unit - -> Eff (timer :: TIMER | eff) IntervalId +foreign import setInterval :: Int -> Effect Unit -> Effect IntervalId -- | Cancels an interval timer. If the interval has already been cancelled this -- | will have no effect. -foreign import clearInterval - :: forall eff - . IntervalId - -> Eff (timer :: TIMER | eff) Unit +foreign import clearInterval :: IntervalId -> Effect Unit diff --git a/test/Main.purs b/test/Main.purs index 5aef47a..71b66bd 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -2,51 +2,50 @@ module Test.Main where import Prelude -import Control.Monad.Eff (Eff) -import Control.Monad.Eff.Console as C -import Control.Monad.Eff.Ref as R -import Control.Monad.Eff.Timer as T +import Effect (Effect) +import Effect.Console as C +import Effect.Ref as R +import Effect.Timer as T +import Test.Assert (assert) -import Test.Assert (ASSERT, assert) - -main :: Eff (ref :: R.REF, timer :: T.TIMER, console :: C.CONSOLE, assert :: ASSERT) Unit +main :: Effect Unit main = do - counter <- R.newRef 0 + counter <- R.new 0 void $ T.setTimeout 10 do C.log "timeout increment counter" - R.modifyRef counter (_ + 1) + R.modify (_ + 1) counter void $ T.setTimeout 50 do C.log "timeout check counter" - n <- R.readRef counter + n <- R.read counter assert $ n == 1 void $ T.setTimeout 100 do t <- T.setTimeout 20 do - R.modifyRef counter (_ + 1) + R.modify (_ + 1) counter T.clearTimeout t void $ T.setTimeout 50 do C.log "check timeout never ran" - n <- R.readRef counter + n <- R.read counter assert $ n == 1 void $ T.setTimeout 200 do i <- T.setInterval 20 do C.log "interval increment counter" - R.modifyRef counter (_ + 1) + R.modify (_ + 1) counter void $ T.setTimeout 90 do T.clearInterval i C.log "interval check counter" - n <- R.readRef counter + n <- R.read counter assert $ n == 5 void $ T.setTimeout 150 do C.log "check interval has stopped" - n <- R.readRef counter + n <- R.read counter assert $ n == 5 From b53a7a7db9d50b6eec71d8a3dd132804cd86a013 Mon Sep 17 00:00:00 2001 From: justinwoo Date: Fri, 25 May 2018 16:54:56 +0300 Subject: [PATCH 2/2] update packages --- .travis.yml | 7 +++++++ bower.json | 8 ++++---- package.json | 9 ++++----- test/Main.purs | 6 +++--- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7f150a3..d5bba8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,14 @@ language: node_js dist: trusty sudo: required node_js: stable +env: + - PATH=$HOME/purescript:$PATH install: + - npm install -g bower + - 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') + - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz + - tar -xvf $HOME/purescript.tar.gz -C $HOME/ + - chmod a+x $HOME/purescript - npm install -g bower - npm install - bower install --production diff --git a/bower.json b/bower.json index d5d0ffb..a4de691 100644 --- a/bower.json +++ b/bower.json @@ -17,11 +17,11 @@ "package.json" ], "dependencies": { - "purescript-effect": "#compiler/0.12" + "purescript-effect": "^2.0.0" }, "devDependencies": { - "purescript-assert": "#compiler/0.12", - "purescript-refs": "#compiler/0.12", - "purescript-console": "#compiler/0.12" + "purescript-assert": "^4.0.0", + "purescript-refs": "^4.0.0", + "purescript-console": "^4.1.0" } } diff --git a/package.json b/package.json index 5a71519..6615039 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,9 @@ "test": "pulp test" }, "devDependencies": { - "eslint": "^3.19.0", - "pulp": "^11.0.0", - "purescript-psa": "^0.5.0", - "purescript": "^0.11.1", - "rimraf": "^2.6.1" + "eslint": "^4.19.1", + "pulp": "^12.2.0", + "purescript-psa": "^0.6.0", + "rimraf": "^2.6.2" } } diff --git a/test/Main.purs b/test/Main.purs index 71b66bd..832ea23 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -14,7 +14,7 @@ main = do void $ T.setTimeout 10 do C.log "timeout increment counter" - R.modify (_ + 1) counter + void $ R.modify (_ + 1) counter void $ T.setTimeout 50 do C.log "timeout check counter" @@ -24,7 +24,7 @@ main = do void $ T.setTimeout 100 do t <- T.setTimeout 20 do - R.modify (_ + 1) counter + void $ R.modify (_ + 1) counter T.clearTimeout t @@ -37,7 +37,7 @@ main = do i <- T.setInterval 20 do C.log "interval increment counter" - R.modify (_ + 1) counter + void $ R.modify (_ + 1) counter void $ T.setTimeout 90 do T.clearInterval i