Skip to content

Commit 7639208

Browse files
committed
Merged with upstream.
2 parents 584ce83 + a712652 commit 7639208

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"repository": {
88
"type": "git",
9-
"url": "git@github.com:purescript-node/purescript-node-readline.git"
9+
"url": "git://github.com/purescript-node/purescript-node-readline.git"
1010
},
1111
"license": "MIT",
1212
"ignore": [

docs/Node/ReadLine.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ A function which handles input from the user.
3434
#### `setLineHandler`
3535

3636
``` purescript
37-
setLineHandler :: forall eff a. LineHandler eff a -> Interface -> Eff (console :: CONSOLE | eff) Interface
37+
setLineHandler :: forall eff a. Interface -> LineHandler eff a -> Eff (console :: CONSOLE | eff) Interface
3838
```
3939

4040
Set the current line handler function.

src/Node/ReadLine.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
// module Node.ReadLine
55

6-
exports.setLineHandler = function(callback) {
7-
return function(readline) {
6+
exports.setLineHandler = function(readline) {
7+
return function(callback) {
88
return function() {
99
readline.removeAllListeners('line');
1010
readline.on('line', function(line) {

src/Node/ReadLine.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Completer eff = String -> Eff (console :: CONSOLE | eff) { completions :: A
2222
type LineHandler eff a = String -> Eff (console :: CONSOLE | eff) a
2323

2424
-- | Set the current line handler function.
25-
foreign import setLineHandler :: forall eff a. LineHandler eff a -> Interface -> Eff (console :: CONSOLE | eff) Interface
25+
foreign import setLineHandler :: forall eff a. Interface -> LineHandler eff a -> Eff (console :: CONSOLE | eff) Interface
2626

2727
-- | Prompt the user for input on the specified `Interface`.
2828
foreign import prompt :: forall eff. Interface -> Eff (console :: CONSOLE | eff) Interface

test/Main.purs

+6-10
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@ import Node.ReadLine
1010
main = do
1111
interface <- createInterface noCompletion
1212

13-
let
14-
lineHandler s = do
15-
if s == "quit"
16-
then do
17-
close interface
18-
else do
19-
log $ "You typed: " ++ s
20-
prompt interface
21-
2213
setPrompt "> " 2 interface
2314
prompt interface
24-
setLineHandler lineHandler interface
15+
setLineHandler interface $ \s ->
16+
if s == "quit"
17+
then close interface
18+
else do
19+
log $ "You typed: " ++ s
20+
prompt interface

0 commit comments

Comments
 (0)