@@ -19,12 +19,11 @@ module Node.ReadLine
19
19
, close
20
20
) where
21
21
22
- import Prelude (return , (<>), ($))
22
+ import Prelude (Unit , return , (<>), ($))
23
23
import Control.Monad.Eff (Eff )
24
24
import Control.Monad.Eff.Console (CONSOLE )
25
25
import Control.Monad.Eff.Exception (EXCEPTION )
26
26
import Data.Foreign (Foreign )
27
- import Data.Maybe (Maybe (Just))
28
27
import Data.Options (Options , Option , (:=), options , opt )
29
28
import Node.Process (stdin , stdout )
30
29
import Node.Stream (Readable , Writable )
@@ -39,8 +38,9 @@ foreign import data READLINE :: !
39
38
40
39
foreign import createInterfaceImpl :: forall eff .
41
40
Foreign
42
- -> Eff ( readline :: READLINE | eff )
43
- Interface
41
+ -> Eff ( readline :: READLINE
42
+ | eff
43
+ ) Interface
44
44
45
45
-- | Options passed to `readline`'s `createInterface`
46
46
data InterfaceOptions
@@ -66,11 +66,13 @@ type Completer eff = String -> Eff eff { completions :: Array String
66
66
67
67
-- | Builds an interface with the specified options.
68
68
createInterface :: forall r eff .
69
- Readable r eff
69
+ Readable r ( readline :: READLINE
70
+ | eff
71
+ )
70
72
-> Options InterfaceOptions
71
73
-> Eff ( readline :: READLINE
72
- | eff )
73
- Interface
74
+ | eff
75
+ ) Interface
74
76
createInterface input opts = createInterfaceImpl
75
77
$ options $ opts
76
78
<> opt " input" := input
@@ -80,12 +82,13 @@ createConsoleInterface :: forall eff.
80
82
Completer ( readline :: READLINE
81
83
, console :: CONSOLE
82
84
, err :: EXCEPTION
83
- | eff )
85
+ | eff
86
+ )
84
87
-> Eff ( readline :: READLINE
85
88
, console :: CONSOLE
86
89
, err :: EXCEPTION
87
- | eff )
88
- Interface
90
+ | eff
91
+ ) Interface
89
92
createConsoleInterface compl = createInterface stdin $ output := stdout
90
93
<> completer := compl
91
94
@@ -96,25 +99,35 @@ noCompletion s = return { completions: [], matched: s }
96
99
-- | Prompt the user for input on the specified `Interface`.
97
100
foreign import prompt :: forall eff .
98
101
Interface
99
- -> Eff ( readline :: READLINE | eff ) Interface
102
+ -> Eff ( readline :: READLINE
103
+ | eff
104
+ ) Unit
100
105
101
106
-- | Set the prompt.
102
107
foreign import setPrompt :: forall eff .
103
108
String
104
109
-> Int
105
110
-> Interface
106
- -> Eff ( readline :: READLINE | eff ) Interface
111
+ -> Eff ( readline :: READLINE
112
+ | eff
113
+ ) Unit
107
114
108
115
-- | Close the specified `Interface`.
109
116
foreign import close :: forall eff .
110
117
Interface
111
- -> Eff ( readline :: READLINE | eff ) Interface
118
+ -> Eff ( readline :: READLINE
119
+ | eff
120
+ ) Unit
112
121
113
122
-- | A function which handles each line of input.
114
123
type LineHandler eff a = String -> Eff eff a
115
124
116
125
-- | Set the current line handler function.
117
126
foreign import setLineHandler :: forall eff a .
118
127
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