Skip to content

Commit 213989c

Browse files
committed
Updates for 0.12
1 parent 2a4628c commit 213989c

File tree

3 files changed

+33
-54
lines changed

3 files changed

+33
-54
lines changed

bower.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"package.json"
1717
],
1818
"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"
19+
"purescript-console": "#compiler/0.12",
20+
"purescript-node-streams": "#compiler/0.12",
21+
"purescript-node-process": "#compiler/0.12",
22+
"purescript-options": "#compiler/0.12",
23+
"purescript-foreign": "#compiler/0.12"
2424
}
2525
}

src/Node/ReadLine.purs

Lines changed: 24 additions & 44 deletions
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

Lines changed: 4 additions & 5 deletions
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)