因为没有主模块,所以不会生成任何输出 [英] No output will be generated because there is no Main module
本文介绍了因为没有主模块,所以不会生成任何输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一个名为Test
的简单模块:
I wrote a simple module called Test
:
module Test (main) where
main =
putStrLn "Hello"
但是,当我尝试通过以下命令行进行编译时:
However, when i try to compile it via the following command line:
ghc Test.hs -o my-program
我收到以下错误:
[1 of 1] Compiling Test ( Test.hs, Test.o )
<no location info>: error:
output was redirected with -o, but no output will be generated because there is no Main module.
推荐答案
ghc
将假定main
位于名为Main
的模块中(如编译器所说).
ghc
will assume that the main
is located in a module called Main
(like the compiler says).
ghc
但是具有选项 -main-is
,您可以在其中指定main
函数所在模块的名称.因此,您可以使用以下代码进行编译:
ghc
however has an option -main-is
where you can specify the name of the module where the main
function is located. So you can compile with:
ghc -main-is Test Test.hs -o my-program
这篇关于因为没有主模块,所以不会生成任何输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文