Skip to content

Commit e40ab26

Browse files
committed
Cleanup based on Github comments
* Fix Readable row * Remove unnecessary returns Also: * Delete docs & link to Pursuit
1 parent 5e7d92c commit e40ab26

File tree

4 files changed

+30
-153
lines changed

4 files changed

+30
-153
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ A low-level PureScript interface to the Node `readline` API.
88
bower install purescript-readline
99
```
1010

11-
## Module documentation
12-
13-
- [Node.ReadLine](docs/Node/ReadLine.md)
11+
Module documentation can be found on [Pursuit](https://pursuit.purescript.org/packages/purescript-node-readline)

docs/Node/ReadLine.md

Lines changed: 0 additions & 130 deletions
This file was deleted.

src/Node/ReadLine.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* global exports */
2-
"use strict";
2+
'use strict';
33

44
// module Node.ReadLine
55

@@ -22,14 +22,12 @@ exports.createInterfaceImpl = function(options) {
2222
exports.close = function(readline) {
2323
return function() {
2424
readline.close();
25-
return readline;
2625
};
2726
};
2827

2928
exports.prompt = function(readline) {
3029
return function() {
3130
readline.prompt();
32-
return readline;
3331
};
3432
};
3533

@@ -38,7 +36,6 @@ exports.setPrompt = function(prompt) {
3836
return function(readline) {
3937
return function() {
4038
readline.setPrompt(prompt, length);
41-
return readline;
4239
};
4340
};
4441
};
@@ -51,7 +48,6 @@ exports.setLineHandler = function(readline) {
5148
readline.on('line', function(line) {
5249
callback(line)();
5350
});
54-
return readline;
5551
};
5652
};
5753
};

src/Node/ReadLine.purs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ module Node.ReadLine
1919
, close
2020
) where
2121

22-
import Prelude (return, (<>), ($))
22+
import Prelude (Unit, return, (<>), ($))
2323
import Control.Monad.Eff (Eff)
2424
import Control.Monad.Eff.Console (CONSOLE)
2525
import Control.Monad.Eff.Exception (EXCEPTION)
2626
import Data.Foreign (Foreign)
27-
import Data.Maybe (Maybe(Just))
2827
import Data.Options (Options, Option, (:=), options, opt)
2928
import Node.Process (stdin, stdout)
3029
import Node.Stream (Readable, Writable)
@@ -39,8 +38,9 @@ foreign import data READLINE :: !
3938

4039
foreign import createInterfaceImpl :: forall eff.
4140
Foreign
42-
-> Eff ( readline :: READLINE | eff )
43-
Interface
41+
-> Eff ( readline :: READLINE
42+
| eff
43+
) Interface
4444

4545
-- | Options passed to `readline`'s `createInterface`
4646
data InterfaceOptions
@@ -66,11 +66,13 @@ type Completer eff = String -> Eff eff { completions :: Array String
6666

6767
-- | Builds an interface with the specified options.
6868
createInterface :: forall r eff.
69-
Readable r eff
69+
Readable r ( readline :: READLINE
70+
| eff
71+
)
7072
-> Options InterfaceOptions
7173
-> Eff ( readline :: READLINE
72-
| eff )
73-
Interface
74+
| eff
75+
) Interface
7476
createInterface input opts = createInterfaceImpl
7577
$ options $ opts
7678
<> opt "input" := input
@@ -80,12 +82,13 @@ createConsoleInterface :: forall eff.
8082
Completer ( readline :: READLINE
8183
, console :: CONSOLE
8284
, err :: EXCEPTION
83-
| eff )
85+
| eff
86+
)
8487
-> Eff ( readline :: READLINE
8588
, console :: CONSOLE
8689
, err :: EXCEPTION
87-
| eff )
88-
Interface
90+
| eff
91+
) Interface
8992
createConsoleInterface compl = createInterface stdin $ output := stdout
9093
<> completer := compl
9194

@@ -96,25 +99,35 @@ noCompletion s = return { completions: [], matched: s }
9699
-- | Prompt the user for input on the specified `Interface`.
97100
foreign import prompt :: forall eff.
98101
Interface
99-
-> Eff ( readline :: READLINE | eff ) Interface
102+
-> Eff ( readline :: READLINE
103+
| eff
104+
) Unit
100105

101106
-- | Set the prompt.
102107
foreign import setPrompt :: forall eff.
103108
String
104109
-> Int
105110
-> Interface
106-
-> Eff ( readline :: READLINE | eff ) Interface
111+
-> Eff ( readline :: READLINE
112+
| eff
113+
) Unit
107114

108115
-- | Close the specified `Interface`.
109116
foreign import close :: forall eff.
110117
Interface
111-
-> Eff ( readline :: READLINE | eff ) Interface
118+
-> Eff ( readline :: READLINE
119+
| eff
120+
) Unit
112121

113122
-- | A function which handles each line of input.
114123
type LineHandler eff a = String -> Eff eff a
115124

116125
-- | Set the current line handler function.
117126
foreign import setLineHandler :: forall eff a.
118127
Interface
119-
-> LineHandler ( readline :: READLINE | eff ) a
120-
-> Eff ( readline :: READLINE | eff ) Interface
128+
-> LineHandler ( readline :: READLINE
129+
| eff
130+
) a
131+
-> Eff ( readline :: READLINE
132+
| eff
133+
) Unit

0 commit comments

Comments
 (0)