From 213989cc2a4ee001592fe27074ce9d18cc2adb97 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 14 May 2018 15:32:22 +0200 Subject: [PATCH 1/6] Updates for 0.12 --- bower.json | 10 +++---- src/Node/ReadLine.purs | 68 +++++++++++++++--------------------------- test/Main.purs | 9 +++--- 3 files changed, 33 insertions(+), 54 deletions(-) diff --git a/bower.json b/bower.json index 9b1ceb2..d8a181a 100644 --- a/bower.json +++ b/bower.json @@ -16,10 +16,10 @@ "package.json" ], "dependencies": { - "purescript-console": "^3.0.0", - "purescript-node-streams": "^3.0.0", - "purescript-node-process": ">= 4.0.0 <6.0.0", - "purescript-options": "^3.0.0", - "purescript-foreign": "^4.0.0" + "purescript-console": "#compiler/0.12", + "purescript-node-streams": "#compiler/0.12", + "purescript-node-process": "#compiler/0.12", + "purescript-options": "#compiler/0.12", + "purescript-foreign": "#compiler/0.12" } } diff --git a/src/Node/ReadLine.purs b/src/Node/ReadLine.purs index 0004681..aa36bfc 100644 --- a/src/Node/ReadLine.purs +++ b/src/Node/ReadLine.purs @@ -2,7 +2,6 @@ module Node.ReadLine ( Interface - , READLINE , InterfaceOptions , Completer , LineHandler @@ -22,11 +21,9 @@ module Node.ReadLine import Prelude -import Control.Monad.Eff (kind Effect, Eff) -import Control.Monad.Eff.Console (CONSOLE) -import Control.Monad.Eff.Exception (EXCEPTION) +import Effect (Effect) -import Data.Foreign (Foreign) +import Foreign (Foreign) import Data.Options (Options, Option, (:=), options, opt) import Node.Process (stdin, stdout) @@ -37,21 +34,15 @@ import Node.Stream (Readable, Writable) -- | A handle can be created with the `createInterface` function. foreign import data Interface :: Type --- | The effect of interacting with a stream via an `Interface` -foreign import data READLINE :: Effect - -foreign import createInterfaceImpl - :: forall eff - . Foreign - -> Eff ( readline :: READLINE | eff ) Interface +foreign import createInterfaceImpl :: Foreign -> Effect Interface -- | Options passed to `readline`'s `createInterface` -data InterfaceOptions +foreign import data InterfaceOptions :: Type -output :: forall w eff. Option InterfaceOptions (Writable w eff) +output :: forall w. Option InterfaceOptions (Writable w) output = opt "output" -completer :: forall eff. Option InterfaceOptions (Completer eff) +completer :: Option InterfaceOptions Completer completer = opt "completer" terminal :: Option InterfaceOptions Boolean @@ -64,73 +55,62 @@ historySize = opt "historySize" -- | -- | This function takes the partial command as input, and returns a collection of -- | completions, as well as the matched portion of the input string. -type Completer eff +type Completer = String - -> Eff eff + -> Effect { completions :: Array String , matched :: String } -- | Builds an interface with the specified options. createInterface - :: forall r eff - . Readable r (readline :: READLINE | eff) + :: forall r + . Readable r -> Options InterfaceOptions - -> Eff (readline :: READLINE | eff) Interface + -> Effect Interface createInterface input opts = createInterfaceImpl $ options $ opts <> opt "input" := input -- | Create an interface with the specified completion function. -createConsoleInterface - :: forall eff - . Completer (readline :: READLINE, console :: CONSOLE, exception :: EXCEPTION | eff) - -> Eff (readline :: READLINE, console :: CONSOLE, exception :: EXCEPTION | eff) Interface +createConsoleInterface :: Completer -> Effect Interface createConsoleInterface compl = createInterface stdin $ output := stdout <> completer := compl -- | A completion function which offers no completions. -noCompletion :: forall eff. Completer eff +noCompletion :: Completer noCompletion s = pure { completions: [], matched: s } -- | Prompt the user for input on the specified `Interface`. -foreign import prompt - :: forall eff - . Interface - -> Eff (readline :: READLINE | eff) Unit +foreign import prompt :: Interface -> Effect Unit -- | Writes a query to the output, waits -- | for user input to be provided on input, then invokes -- | the callback function foreign import question - :: forall eff - . String - -> (String -> Eff (readline :: READLINE | eff) Unit) + :: String + -> (String -> Effect Unit) -> Interface - -> Eff (readline :: READLINE | eff) Unit + -> Effect Unit -- | Set the prompt. foreign import setPrompt - :: forall eff - . String + :: String -> Int -> Interface - -> Eff (readline :: READLINE | eff) Unit + -> Effect Unit -- | Close the specified `Interface`. -foreign import close - :: forall eff - . Interface - -> Eff (readline :: READLINE | eff) Unit +foreign import close :: Interface -> Effect Unit -- | A function which handles each line of input. -type LineHandler eff a = String -> Eff eff a +type LineHandler a = String -> Effect a -- | Set the current line handler function. foreign import setLineHandler - :: forall eff a + :: forall a . Interface - -> LineHandler (readline :: READLINE | eff) a - -> Eff (readline :: READLINE | eff) Unit + -> LineHandler a + -> Effect Unit diff --git a/test/Main.purs b/test/Main.purs index 7dac097..f72d1cc 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -2,13 +2,12 @@ module Test.Main where import Prelude -import Control.Monad.Eff (Eff) -import Control.Monad.Eff.Console (CONSOLE, log) -import Control.Monad.Eff.Exception (EXCEPTION) +import Effect (Effect) +import Effect.Console (log) -import Node.ReadLine (READLINE, prompt, close, setLineHandler, setPrompt, noCompletion, createConsoleInterface) +import Node.ReadLine (prompt, close, setLineHandler, setPrompt, noCompletion, createConsoleInterface) -main :: forall eff. Eff (readline :: READLINE, console :: CONSOLE, exception :: EXCEPTION | eff) Unit +main :: Effect Unit main = do interface <- createConsoleInterface noCompletion setPrompt "> " 2 interface From a14fc45333315fe06d48f201e0d9ce5d5bf15576 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 14 May 2018 15:34:32 +0200 Subject: [PATCH 2/6] move console to devDependencies --- bower.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index d8a181a..06c12e5 100644 --- a/bower.json +++ b/bower.json @@ -15,11 +15,15 @@ "bower.json", "package.json" ], + "devDependencies": { + "purescript-console": "#compiler/0.12" + } "dependencies": { - "purescript-console": "#compiler/0.12", "purescript-node-streams": "#compiler/0.12", "purescript-node-process": "#compiler/0.12", "purescript-options": "#compiler/0.12", - "purescript-foreign": "#compiler/0.12" + "purescript-foreign": "#compiler/0.12", + "purescript-prelude": "#compiler/0.12", + "purescript-effect": "#compiler/0.12" } } From 396702df535a1e77bb3cf824efcc5c31139484c0 Mon Sep 17 00:00:00 2001 From: Alex Mouton Date: Sun, 27 May 2018 12:00:25 -0700 Subject: [PATCH 3/6] Replaced compiler/0.12 branch references with version numbers. --- bower.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index 06c12e5..7dcf134 100644 --- a/bower.json +++ b/bower.json @@ -16,14 +16,14 @@ "package.json" ], "devDependencies": { - "purescript-console": "#compiler/0.12" - } + "purescript-console": "^4.0.0" + }, "dependencies": { - "purescript-node-streams": "#compiler/0.12", - "purescript-node-process": "#compiler/0.12", - "purescript-options": "#compiler/0.12", - "purescript-foreign": "#compiler/0.12", - "purescript-prelude": "#compiler/0.12", - "purescript-effect": "#compiler/0.12" + "purescript-node-streams": "^4.0.0", + "purescript-node-process": "^6.0.0", + "purescript-options": "^v4.0.0", + "purescript-foreign": "^5.0.0", + "purescript-prelude": "^v4.0.0", + "purescript-effect": "^2.0.0" } } From 2ac84f3c80741e5acaffbb9df44e1143022b46c7 Mon Sep 17 00:00:00 2001 From: Alex Mouton Date: Tue, 29 May 2018 11:32:37 -0700 Subject: [PATCH 4/6] node_js to 8 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c83266e..c3a3d4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js dist: trusty sudo: required -node_js: 6 +node_js: 8 install: - npm install -g bower - npm install From abd92109857b1f87a6fe24b97d309c01af5923b2 Mon Sep 17 00:00:00 2001 From: Alex Mouton Date: Tue, 29 May 2018 11:17:56 -0700 Subject: [PATCH 5/6] Purescript to 12 in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 276a84c..009d59a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "eslint": "^3.17.1", "pulp": "^11.0.0", "purescript-psa": "^0.5.0", - "purescript": "^0.11.1", + "purescript": "^0.12.0", "rimraf": "^2.5.4" } } From cf66311153c7b85405446b812f50fd1d3efb09dc Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 30 May 2018 00:12:08 +0200 Subject: [PATCH 6/6] fetch latest PS binary from Github --- .travis.yml | 9 +++++++-- package.json | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c3a3d4a..be7e6e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,19 @@ language: node_js dist: trusty sudo: required -node_js: 8 +node_js: stable +env: + - PATH=$HOME/purescript:$PATH install: + - 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 script: - bower install --production - npm run -s build - - bower install after_success: - >- test $TRAVIS_TAG && diff --git a/package.json b/package.json index 009d59a..6048c95 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "eslint": "^3.17.1", "pulp": "^11.0.0", "purescript-psa": "^0.5.0", - "purescript": "^0.12.0", "rimraf": "^2.5.4" } }