Skip to content

Commit

Permalink
Merged with upstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
AphonicChaos committed Aug 10, 2015
2 parents 584ce83 + a712652 commit 7639208
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"repository": {
"type": "git",
"url": "git@github.com:purescript-node/purescript-node-readline.git"
"url": "git://github.com/purescript-node/purescript-node-readline.git"
},
"license": "MIT",
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion docs/Node/ReadLine.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ A function which handles input from the user.
#### `setLineHandler`

``` purescript
setLineHandler :: forall eff a. LineHandler eff a -> Interface -> Eff (console :: CONSOLE | eff) Interface
setLineHandler :: forall eff a. Interface -> LineHandler eff a -> Eff (console :: CONSOLE | eff) Interface
```

Set the current line handler function.
Expand Down
4 changes: 2 additions & 2 deletions src/Node/ReadLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

// module Node.ReadLine

exports.setLineHandler = function(callback) {
return function(readline) {
exports.setLineHandler = function(readline) {
return function(callback) {
return function() {
readline.removeAllListeners('line');
readline.on('line', function(line) {
Expand Down
2 changes: 1 addition & 1 deletion src/Node/ReadLine.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Completer eff = String -> Eff (console :: CONSOLE | eff) { completions :: A
type LineHandler eff a = String -> Eff (console :: CONSOLE | eff) a

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

-- | Prompt the user for input on the specified `Interface`.
foreign import prompt :: forall eff. Interface -> Eff (console :: CONSOLE | eff) Interface
Expand Down
16 changes: 6 additions & 10 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ import Node.ReadLine
main = do
interface <- createInterface noCompletion

let
lineHandler s = do
if s == "quit"
then do
close interface
else do
log $ "You typed: " ++ s
prompt interface

setPrompt "> " 2 interface
prompt interface
setLineHandler lineHandler interface
setLineHandler interface $ \s ->
if s == "quit"
then close interface
else do
log $ "You typed: " ++ s
prompt interface

0 comments on commit 7639208

Please sign in to comment.