【发布时间】:2020-02-04 04:19:55
【问题描述】:
考虑shell :: String -> CreateProcess。例如:
Prelude System.IO System.Process> shell "pwd"
CreateProcess {cmdspec = ShellCommand "pwd", cwd = Nothing, env = Nothing, std_in = Inherit, std_out = Inherit, std_err = Inherit, close_fds = False, create_group = False, delegate_ctlc = False, detach_console = False, create_new_console = False, new_session = False, child_group = Nothing, child_user = Nothing, use_process_jobs = False}
我正在尝试修改 CreateProcess 的记录参数,但出现 REPL 错误:
Prelude System.IO System.Process> shell "pwd" { cwd = "/home" }
<interactive>:7:7: error:
• Couldn't match type ‘CreateProcess’ with ‘[Char]’
Expected type: String
Actual type: CreateProcess
• In the first argument of ‘shell’, namely ‘"pwd" {cwd = "/home"}’
In the expression: shell "pwd" {cwd = "/home"}
In an equation for ‘it’: it = shell "pwd" {cwd = "/home"}
<interactive>:7:21: error:
• Couldn't match expected type ‘Maybe FilePath’
with actual type ‘[Char]’
• In the ‘cwd’ field of a record
In the first argument of ‘shell’, namely ‘"pwd" {cwd = "/home"}’
In the expression: shell "pwd" {cwd = "/home"}
【问题讨论】:
标签: shell haskell record read-eval-print-loop