Haskell 或 GHC 的主要定义在哪里?
Where is Haskell's or GHC's main defined?
在Haskell中,编译程序的执行从执行模块Main
中的main
开始。此函数必须是 IO ()
.
类型
哪个标准或参考定义了以上内容?
比较C++(参考C11标准(ISO/IEC9899:2011)5.1.2.2.1程序启动(p:13)):
Every C program [...] contains the definition [...] of a function called main, which is the designated start of the program.
Haskell 2010 and Haskell 98 没有正式定义 main
(尽管有几个函数示例称为 main
),而是说:
We leave as implementation dependent the ways in which Haskell programs are to be manipulated, interpreted, compiled, etc.
GHC User's Guide 指示用户创建一个 main
函数,但从未提及其所需的类型或它是程序执行的开始。有对 Main
模块的引用,但没有对 main
函数的引用。
比较C++(参考C11标准(ISO/IEC9899:2011)5.1.2.2.1程序启动(p:13)):
Every C program [...] contains the definition [...] of a function called main, which is the designated start of the program.
哪个标准或参考说 main
是 Haskell 程序执行的开始?
A Haskell program is a collection of modules, one of which, by convention, must be called Main
and must export the value main
. The value of the program is the value of the identifier main
in module Main
, which must be a computation of type IO τ
for some type τ
(see Chapter 7). When the program is executed, the computation main
is performed, and its result (of type τ
) is discarded.
https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#dx11-98001
在Haskell中,编译程序的执行从执行模块Main
中的main
开始。此函数必须是 IO ()
.
哪个标准或参考定义了以上内容?
比较C++(参考C11标准(ISO/IEC9899:2011)5.1.2.2.1程序启动(p:13)):
Every C program [...] contains the definition [...] of a function called main, which is the designated start of the program.
Haskell 2010 and Haskell 98 没有正式定义 main
(尽管有几个函数示例称为 main
),而是说:
We leave as implementation dependent the ways in which Haskell programs are to be manipulated, interpreted, compiled, etc.
GHC User's Guide 指示用户创建一个 main
函数,但从未提及其所需的类型或它是程序执行的开始。有对 Main
模块的引用,但没有对 main
函数的引用。
比较C++(参考C11标准(ISO/IEC9899:2011)5.1.2.2.1程序启动(p:13)):
Every C program [...] contains the definition [...] of a function called main, which is the designated start of the program.
哪个标准或参考说 main
是 Haskell 程序执行的开始?
A Haskell program is a collection of modules, one of which, by convention, must be called
Main
and must export the valuemain
. The value of the program is the value of the identifiermain
in moduleMain
, which must be a computation of typeIO τ
for some typeτ
(see Chapter 7). When the program is executed, the computationmain
is performed, and its result (of typeτ
) is discarded.
https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#dx11-98001