File tree 5 files changed +11
-15
lines changed
5 files changed +11
-15
lines changed Original file line number Diff line number Diff line change 6
6
],
7
7
"repository" : {
8
8
"type" : " git" ,
9
- "url" : " git@ github.com: purescript-node/purescript-node-readline.git"
9
+ "url" : " git:// github.com/ purescript-node/purescript-node-readline.git"
10
10
},
11
11
"license" : " MIT" ,
12
12
"ignore" : [
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ A function which handles input from the user.
34
34
#### ` setLineHandler `
35
35
36
36
``` 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
38
38
```
39
39
40
40
Set the current line handler function.
Original file line number Diff line number Diff line change 3
3
4
4
// module Node.ReadLine
5
5
6
- exports . setLineHandler = function ( callback ) {
7
- return function ( readline ) {
6
+ exports . setLineHandler = function ( readline ) {
7
+ return function ( callback ) {
8
8
return function ( ) {
9
9
readline . removeAllListeners ( 'line' ) ;
10
10
readline . on ( 'line' , function ( line ) {
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ type Completer eff = String -> Eff (console :: CONSOLE | eff) { completions :: A
22
22
type LineHandler eff a = String -> Eff (console :: CONSOLE | eff ) a
23
23
24
24
-- | 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
26
26
27
27
-- | Prompt the user for input on the specified `Interface`.
28
28
foreign import prompt :: forall eff . Interface -> Eff (console :: CONSOLE | eff ) Interface
Original file line number Diff line number Diff line change @@ -10,15 +10,11 @@ import Node.ReadLine
10
10
main = do
11
11
interface <- createInterface noCompletion
12
12
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
-
22
13
setPrompt " > " 2 interface
23
14
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
You can’t perform that action at this time.
0 commit comments