Skip to content

Commit 72bed94

Browse files
authored
Merge pull request #16 from purescript-node/compiler/0.12
Compiler/0.12
2 parents 2a4628c + cf66311 commit 72bed94

File tree

5 files changed

+44
-57
lines changed

5 files changed

+44
-57
lines changed

.travis.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
language: node_js
22
dist: trusty
33
sudo: required
4-
node_js: 6
4+
node_js: stable
5+
env:
6+
- PATH=$HOME/purescript:$PATH
57
install:
8+
- 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')
9+
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
10+
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
11+
- chmod a+x $HOME/purescript
612
- npm install -g bower
713
- npm install
814
script:
915
- bower install --production
1016
- npm run -s build
11-
- bower install
1217
after_success:
1318
- >-
1419
test $TRAVIS_TAG &&

bower.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515
"bower.json",
1616
"package.json"
1717
],
18+
"devDependencies": {
19+
"purescript-console": "^4.0.0"
20+
},
1821
"dependencies": {
19-
"purescript-console": "^3.0.0",
20-
"purescript-node-streams": "^3.0.0",
21-
"purescript-node-process": ">= 4.0.0 <6.0.0",
22-
"purescript-options": "^3.0.0",
23-
"purescript-foreign": "^4.0.0"
22+
"purescript-node-streams": "^4.0.0",
23+
"purescript-node-process": "^6.0.0",
24+
"purescript-options": "^v4.0.0",
25+
"purescript-foreign": "^5.0.0",
26+
"purescript-prelude": "^v4.0.0",
27+
"purescript-effect": "^2.0.0"
2428
}
2529
}

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"eslint": "^3.17.1",
99
"pulp": "^11.0.0",
1010
"purescript-psa": "^0.5.0",
11-
"purescript": "^0.11.1",
1211
"rimraf": "^2.5.4"
1312
}
1413
}

src/Node/ReadLine.purs

+24-44
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
module Node.ReadLine
44
( Interface
5-
, READLINE
65
, InterfaceOptions
76
, Completer
87
, LineHandler
@@ -22,11 +21,9 @@ module Node.ReadLine
2221

2322
import Prelude
2423

25-
import Control.Monad.Eff (kind Effect, Eff)
26-
import Control.Monad.Eff.Console (CONSOLE)
27-
import Control.Monad.Eff.Exception (EXCEPTION)
24+
import Effect (Effect)
2825

29-
import Data.Foreign (Foreign)
26+
import Foreign (Foreign)
3027
import Data.Options (Options, Option, (:=), options, opt)
3128

3229
import Node.Process (stdin, stdout)
@@ -37,21 +34,15 @@ import Node.Stream (Readable, Writable)
3734
-- | A handle can be created with the `createInterface` function.
3835
foreign import data Interface :: Type
3936

40-
-- | The effect of interacting with a stream via an `Interface`
41-
foreign import data READLINE :: Effect
42-
43-
foreign import createInterfaceImpl
44-
:: forall eff
45-
. Foreign
46-
-> Eff ( readline :: READLINE | eff ) Interface
37+
foreign import createInterfaceImpl :: Foreign -> Effect Interface
4738

4839
-- | Options passed to `readline`'s `createInterface`
49-
data InterfaceOptions
40+
foreign import data InterfaceOptions :: Type
5041

51-
output :: forall w eff. Option InterfaceOptions (Writable w eff)
42+
output :: forall w. Option InterfaceOptions (Writable w)
5243
output = opt "output"
5344

54-
completer :: forall eff. Option InterfaceOptions (Completer eff)
45+
completer :: Option InterfaceOptions Completer
5546
completer = opt "completer"
5647

5748
terminal :: Option InterfaceOptions Boolean
@@ -64,73 +55,62 @@ historySize = opt "historySize"
6455
-- |
6556
-- | This function takes the partial command as input, and returns a collection of
6657
-- | completions, as well as the matched portion of the input string.
67-
type Completer eff
58+
type Completer
6859
= String
69-
-> Eff eff
60+
-> Effect
7061
{ completions :: Array String
7162
, matched :: String
7263
}
7364

7465
-- | Builds an interface with the specified options.
7566
createInterface
76-
:: forall r eff
77-
. Readable r (readline :: READLINE | eff)
67+
:: forall r
68+
. Readable r
7869
-> Options InterfaceOptions
79-
-> Eff (readline :: READLINE | eff) Interface
70+
-> Effect Interface
8071
createInterface input opts = createInterfaceImpl
8172
$ options $ opts
8273
<> opt "input" := input
8374

8475
-- | Create an interface with the specified completion function.
85-
createConsoleInterface
86-
:: forall eff
87-
. Completer (readline :: READLINE, console :: CONSOLE, exception :: EXCEPTION | eff)
88-
-> Eff (readline :: READLINE, console :: CONSOLE, exception :: EXCEPTION | eff) Interface
76+
createConsoleInterface :: Completer -> Effect Interface
8977
createConsoleInterface compl =
9078
createInterface stdin
9179
$ output := stdout
9280
<> completer := compl
9381

9482
-- | A completion function which offers no completions.
95-
noCompletion :: forall eff. Completer eff
83+
noCompletion :: Completer
9684
noCompletion s = pure { completions: [], matched: s }
9785

9886
-- | Prompt the user for input on the specified `Interface`.
99-
foreign import prompt
100-
:: forall eff
101-
. Interface
102-
-> Eff (readline :: READLINE | eff) Unit
87+
foreign import prompt :: Interface -> Effect Unit
10388

10489
-- | Writes a query to the output, waits
10590
-- | for user input to be provided on input, then invokes
10691
-- | the callback function
10792
foreign import question
108-
:: forall eff
109-
. String
110-
-> (String -> Eff (readline :: READLINE | eff) Unit)
93+
:: String
94+
-> (String -> Effect Unit)
11195
-> Interface
112-
-> Eff (readline :: READLINE | eff) Unit
96+
-> Effect Unit
11397

11498
-- | Set the prompt.
11599
foreign import setPrompt
116-
:: forall eff
117-
. String
100+
:: String
118101
-> Int
119102
-> Interface
120-
-> Eff (readline :: READLINE | eff) Unit
103+
-> Effect Unit
121104

122105
-- | Close the specified `Interface`.
123-
foreign import close
124-
:: forall eff
125-
. Interface
126-
-> Eff (readline :: READLINE | eff) Unit
106+
foreign import close :: Interface -> Effect Unit
127107

128108
-- | A function which handles each line of input.
129-
type LineHandler eff a = String -> Eff eff a
109+
type LineHandler a = String -> Effect a
130110

131111
-- | Set the current line handler function.
132112
foreign import setLineHandler
133-
:: forall eff a
113+
:: forall a
134114
. Interface
135-
-> LineHandler (readline :: READLINE | eff) a
136-
-> Eff (readline :: READLINE | eff) Unit
115+
-> LineHandler a
116+
-> Effect Unit

test/Main.purs

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ module Test.Main where
22

33
import Prelude
44

5-
import Control.Monad.Eff (Eff)
6-
import Control.Monad.Eff.Console (CONSOLE, log)
7-
import Control.Monad.Eff.Exception (EXCEPTION)
5+
import Effect (Effect)
6+
import Effect.Console (log)
87

9-
import Node.ReadLine (READLINE, prompt, close, setLineHandler, setPrompt, noCompletion, createConsoleInterface)
8+
import Node.ReadLine (prompt, close, setLineHandler, setPrompt, noCompletion, createConsoleInterface)
109

11-
main :: forall eff. Eff (readline :: READLINE, console :: CONSOLE, exception :: EXCEPTION | eff) Unit
10+
main :: Effect Unit
1211
main = do
1312
interface <- createConsoleInterface noCompletion
1413
setPrompt "> " 2 interface

0 commit comments

Comments
 (0)