Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 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 Expand Up @@ -45,4 +45,4 @@ exports.createInterface = function(completer) {
}
});
};
};
};
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
9 changes: 3 additions & 6 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import Node.ReadLine
main = do
interface <- createInterface noCompletion

let
lineHandler s = do
log $ "You typed: " ++ s
prompt interface

setPrompt "> " 2 interface
prompt interface
setLineHandler lineHandler interface
setLineHandler interface $ \s -> do
log $ "You typed: " ++ s
prompt interface