Skip to content

Commit

Permalink
Add 'question' function (#13)
Browse files Browse the repository at this point in the history
* Added 'question' function

* Added missing semicolons.

* Added missing semicolons. Added missing effect to question callback.

* Added missing effect to question callback.
  • Loading branch information
dgendill authored and paf31 committed Aug 22, 2017
1 parent 82e87ee commit 2a4628c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Node/ReadLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ exports.prompt = function (readline) {
};
};

exports.question = function(text) {
return function(callback) {
return function(readline) {
return function() {
readline.question(text, function(result) {
callback(result)();
});
};
};
};
};

exports.setPrompt = function (prompt) {
return function (length) {
return function (readline) {
Expand Down
11 changes: 11 additions & 0 deletions src/Node/ReadLine.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Node.ReadLine
, setPrompt
, setLineHandler
, close
, question
) where

import Prelude
Expand Down Expand Up @@ -100,6 +101,16 @@ foreign import prompt
. Interface
-> Eff (readline :: READLINE | eff) Unit

-- | Writes a query to the output, waits
-- | for user input to be provided on input, then invokes
-- | the callback function
foreign import question
:: forall eff
. String
-> (String -> Eff (readline :: READLINE | eff) Unit)
-> Interface
-> Eff (readline :: READLINE | eff) Unit

-- | Set the prompt.
foreign import setPrompt
:: forall eff
Expand Down

0 comments on commit 2a4628c

Please sign in to comment.