@@ -21,11 +21,10 @@ module Node.ReadLine
2121
2222import Prelude
2323
24+ import Data.Options (Options , Option , (:=), options , opt )
2425import Effect (Effect )
25-
26+ import Effect.Uncurried ( EffectFn1 , EffectFn2 , EffectFn3 , runEffectFn1 , runEffectFn2 , runEffectFn3 )
2627import Foreign (Foreign )
27- import Data.Options (Options , Option , (:=), options , opt )
28-
2928import Node.Process (stdin , stdout )
3029import Node.Stream (Readable , Writable )
3130
@@ -85,32 +84,36 @@ noCompletion :: Completer
8584noCompletion s = pure { completions: [] , matched: s }
8685
8786-- | 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 )
8991
9092-- | Writes a query to the output, waits
9193-- | for user input to be provided on input, then invokes
9294-- | 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
9899
99100-- | 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 )
104105
105106-- | 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 )
107111
108112-- | A function which handles each line of input.
109113type LineHandler a = String -> Effect a
110114
111115-- | 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