我有代码
main :: IO()
main = runInputT defaultSettings loop
where
--loop :: InputT IO ()
loop = do
minput <- getInputLine "$ "
case minput of
Nothing -> return ()
Just input -> process $ words input
loop
Run Code Online (Sandbox Code Playgroud)
进程具有类型定义
process :: [String] -> IO ()
Run Code Online (Sandbox Code Playgroud)
但是我得到错误:
• Couldn't match type ‘IO’ with ‘InputT m’
Expected type: InputT m ()
Actual type: IO ()
• In the expression: process $ words input
In a case alternative: Just input -> process $ …Run Code Online (Sandbox Code Playgroud) 我目前有以下代码:
main :: IO ()
main = do
(_, Just so, _, _) <- createProcess (proc "ls" ["."]) { std_out = CreatePipe }
_ <- createProcess (proc "sort" []) { std_in = so }
print "foo"
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
Couldn't match expected type ‘StdStream’
with actual type ‘GHC.IO.Handle.Types.Handle’
In the ‘std_in’ field of a record
In the first argument of ‘createProcess’, namely
‘(proc "sort" []) {std_in = so}’
In a stmt of a 'do' block:
_ <- createProcess ((proc "sort" []) {std_in …Run Code Online (Sandbox Code Playgroud) 如果我有这样的事情:
main :: IO ()
main = do
hSetBuffering stdin NoBuffering
c <- getChar
Run Code Online (Sandbox Code Playgroud)
我将如何比较c,看看我是否有一个转义序列,如箭头键或ctrl加一个键.
谢谢