@@ -21,11 +21,10 @@ module Node.ReadLine
21
21
22
22
import Prelude
23
23
24
+ import Data.Options (Options , Option , (:=), options , opt )
24
25
import Effect (Effect )
25
-
26
+ import Effect.Uncurried ( EffectFn1 , EffectFn2 , EffectFn3 , runEffectFn1 , runEffectFn2 , runEffectFn3 )
26
27
import Foreign (Foreign )
27
- import Data.Options (Options , Option , (:=), options , opt )
28
-
29
28
import Node.Process (stdin , stdout )
30
29
import Node.Stream (Readable , Writable )
31
30
@@ -85,32 +84,36 @@ noCompletion :: Completer
85
84
noCompletion s = pure { completions: [] , matched: s }
86
85
87
86
-- | Prompt the user for input on the specified `Interface`.
88
- foreign import prompt :: Interface -> Effect Unit
87
+ prompt :: Interface -> Effect Unit
88
+ prompt iface = runEffectFn1 promptImpl iface
89
+
90
+ foreign import promptImpl :: EffectFn1 (Interface ) (Unit )
89
91
90
92
-- | Writes a query to the output, waits
91
93
-- | for user input to be provided on input, then invokes
92
94
-- | the callback function
93
- foreign import question
94
- :: String
95
- -> (String -> Effect Unit )
96
- -> Interface
97
- -> Effect Unit
95
+ question :: String -> (String -> Effect Unit ) -> Interface -> Effect Unit
96
+ question text cb iface = runEffectFn3 questionImpl iface text cb
97
+
98
+ foreign import questionImpl :: EffectFn3 (Interface ) (String ) ((String -> Effect Unit )) Unit
98
99
99
100
-- | Set the prompt.
100
- foreign import setPrompt
101
- :: String
102
- -> Interface
103
- -> Effect Unit
101
+ setPrompt :: String -> Interface -> Effect Unit
102
+ setPrompt newPrompt iface = runEffectFn2 setPromptImpl iface newPrompt
103
+
104
+ foreign import setPromptImpl :: EffectFn2 ( Interface ) ( String ) ( Unit )
104
105
105
106
-- | Close the specified `Interface`.
106
- foreign import close :: Interface -> Effect Unit
107
+ close :: Interface -> Effect Unit
108
+ close iface = runEffectFn1 closeImpl iface
109
+
110
+ foreign import closeImpl :: EffectFn1 (Interface ) (Unit )
107
111
108
112
-- | A function which handles each line of input.
109
113
type LineHandler a = String -> Effect a
110
114
111
115
-- | Set the current line handler function.
112
- foreign import setLineHandler
113
- :: forall a
114
- . LineHandler a
115
- -> Interface
116
- -> Effect Unit
116
+ setLineHandler :: forall a . LineHandler a -> Interface -> Effect Unit
117
+ setLineHandler cb iface = runEffectFn2 setLineHandlerImpl iface cb
118
+
119
+ foreign import setLineHandlerImpl :: forall a . EffectFn2 (Interface ) (LineHandler a ) (Unit )
0 commit comments