runghc 和 ghc 有什么区别?

What are the differences between runghc and ghc?

runghcghc有什么区别?

我 运行 一个简短的程序,似乎可以很好地编译两者,除了我用 runghc 得到以下内容,但不是普通的 ghc :

error:

  • Variable not in scope: main :: IO a0
  • Perhaps you meant `min' (imported from Prelude)

编译 runghc 中的东西,那些东西需要 Main 函数,而普通的 ghc,不需要吗?

就这些了吗?

runghc直接用于运行程序,不编译。没有 main IO 操作的文件不能是 运行,因为根据定义,运行.

没有任何内容

ghc 对不包含 main 的文件所做的是将其编译为 模块 ,以供其他 haskell 导入programs/modules - 这些当然不 运行 可用。