Haskell “命令”;ghc“;返回的变量不在范围内

Haskell “命令”;ghc“;返回的变量不在范围内,haskell,ghc,Haskell,Ghc,我从Haskell开始,在尝试用Haskell编译.ghci文件时遇到了这个奇怪的错误消息。我有一个非常简单的代码,例如: main = do putStrLn "Greetings! What is your name?" inpStr <- getLine putStrLn $ "Welcome to Haskell, " ++ inpStr ++ "!" 我不确定出了什么问题,命令“:load”工作正常并找到我的文件。此错误消息似乎是在GHCi提示符下键入“

我从Haskell开始,在尝试用Haskell编译.ghci文件时遇到了这个奇怪的错误消息。我有一个非常简单的代码,例如:

main = do
    putStrLn "Greetings! What is your name?"
    inpStr <- getLine
    putStrLn $ "Welcome to Haskell, " ++ inpStr ++ "!"

我不确定出了什么问题,命令“:load”工作正常并找到我的文件。

此错误消息似乎是在GHCi提示符下键入“
runghc basicio
”生成的:

GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from ...
> runghc basicio

<interactive>:3:1: error: Variable not in scope: runghc :: t0 -> t

<interactive>:3:8: error: Variable not in scope: basicio
>
GHCi,8.6.5版:http://www.haskell.org/ghc/ :? 求救 已从加载的GHCi配置。。。 >龙格基西奥酒店 :3:1:错误:变量不在范围内:runghc::t0->t :3:8:错误:变量不在范围内:basicio >
但是,
runghc
命令和编译器命令
ghc
都是直接从命令行运行的

你是如何加载文件的?您使用了哪些标志来运行
ghci
?如果ghci在shell中的
ghci
之后不添加任何标志,则直接运行它。我尝试过的编译命令只是
ghc basicio.hs
。是否加载了
:{
:}
之间的多行语句。参考:我将代码保存到名为
basicio.hs
的文件中,并尝试编译该文件。所以我想我不需要“:{:}”如果你用
ghcibasicio.hs
加载它会怎么样。如果我写
:l basicio.hs
:load basicio.hs
,则无法复制它。
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from ...
> runghc basicio

<interactive>:3:1: error: Variable not in scope: runghc :: t0 -> t

<interactive>:3:8: error: Variable not in scope: basicio
>