@@ -19,12 +19,11 @@ module Node.ReadLine
1919 , close
2020 ) where
2121
22- import Prelude (return , (<>), ($))
22+ import Prelude (Unit , return , (<>), ($))
2323import Control.Monad.Eff (Eff )
2424import Control.Monad.Eff.Console (CONSOLE )
2525import Control.Monad.Eff.Exception (EXCEPTION )
2626import Data.Foreign (Foreign )
27- import Data.Maybe (Maybe (Just))
2827import Data.Options (Options , Option , (:=), options , opt )
2928import Node.Process (stdin , stdout )
3029import Node.Stream (Readable , Writable )
@@ -39,8 +38,9 @@ foreign import data READLINE :: !
3938
4039foreign 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`
4646data InterfaceOptions
@@ -66,11 +66,13 @@ type Completer eff = String -> Eff eff { completions :: Array String
6666
6767-- | Builds an interface with the specified options.
6868createInterface :: 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
7476createInterface 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
8992createConsoleInterface 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`.
97100foreign 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.
102107foreign 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`.
109116foreign 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.
114123type LineHandler eff a = String -> Eff eff a
115124
116125-- | Set the current line handler function.
117126foreign 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