@@ -6,14 +6,15 @@ module StackTest.Repl
6
6
, ReplConnection (.. )
7
7
, nextPrompt
8
8
, replCommand
9
+ , replGetChar
9
10
, replGetLine
10
11
, stackRepl
11
12
-- * Reexport
12
13
, module StackTest
13
14
) where
14
15
15
16
import Control.Exception (SomeException , catch , displayException , finally )
16
- import Control.Monad (unless , when )
17
+ import Control.Monad ((>=>) , unless , when )
17
18
import Control.Monad.IO.Class (liftIO )
18
19
import Control.Monad.Trans (lift )
19
20
import Control.Monad.Trans.Reader
@@ -53,6 +54,9 @@ replCommand cmd = do
53
54
liftIO . putStrLn $ " ____> " <> cmd
54
55
liftIO $ hPutStrLn replStdinHandle cmd
55
56
57
+ replGetChar :: Repl Char
58
+ replGetChar = asks replStdout >>= liftIO . hGetChar
59
+
56
60
replGetLine :: Repl String
57
61
replGetLine = ask >>= liftIO . hGetLine . replStdout
58
62
@@ -100,7 +104,7 @@ runRepl cmd args actions = do
100
104
putStrLn " EXCEPTION in test: "
101
105
putStrLn . quote $ displayException e
102
106
putStrLn " ------[ stderr of repl ]------"
103
- withFile stderrBufPath ReadMode $ \ h -> hGetContents' h >>= putStr . quote
107
+ withFile stderrBufPath ReadMode $ hGetContents' >=> putStr . quote
104
108
putStrLn " =============================="
105
109
`finally` do
106
110
hClose stderrBufHandle
0 commit comments