@@ -1043,12 +1043,32 @@ build information fields (see the section on `build information`_).
1043
1043
1044
1044
.. pkg-field :: main-is: filename (required)
1045
1045
1046
- The name of the ``.hs `` or ``.lhs `` file containing the ``Main ``
1047
- module. Note that it is the ``.hs `` filename that must be listed,
1048
- even if that file is generated using a preprocessor. The source file
1049
- must be relative to one of the directories listed in
1050
- :pkg-field: `hs-source-dirs `. Further, while the name of the file may
1051
- vary, the module itself must be named ``Main ``.
1046
+ By convention, a Haskell program must have a module called ``Main `` which
1047
+ exports an IO action named ``main ``. When the program is executed, the
1048
+ action is performed. This field specifies the name of the ``.hs `` or
1049
+ ``.lhs `` source file containing that module. It is the ``.hs `` filename that
1050
+ must be listed, even if that file is generated using a preprocessor. The
1051
+ file must be relative to one of the directories listed in
1052
+ :pkg-field: `hs-source-dirs `.
1053
+
1054
+ Further, while the name of the source file may vary, if the convention is
1055
+ being followed, the module itself must be named ``Main `` and export
1056
+ ``main ``.
1057
+
1058
+ However, GHC's ``-main-is `` option can be used to change the name of the
1059
+ relevant IO action. For example, if source file ``MyMainSourceFile.hs ``
1060
+ contains a module named ``MyMainModule `` exporting ``myMainFunc `` and that
1061
+ is to be the relevant IO action, you can specify:
1062
+
1063
+ ::
1064
+
1065
+ executable my-app
1066
+ main-is: MyMainSourceFile.hs
1067
+ ghc-options: -main-is MyMainModule.myMainFunc
1068
+ build-depends:
1069
+ base
1070
+ default-language: Haskell2010
1071
+
1052
1072
1053
1073
Starting with ``cabal-version: 1.18 `` this field supports
1054
1074
specifying a C, C++, or objC source file as the main entry point.
@@ -1105,7 +1125,7 @@ field.
1105
1125
even if that file is generated using a preprocessor. The source file
1106
1126
must be relative to one of the directories listed in
1107
1127
:pkg-field: `hs-source-dirs `. This field is analogous to the ``main-is `` field
1108
- of an executable section.
1128
+ of an executable section; see that documentation for further information .
1109
1129
1110
1130
Test suites using the ``detailed-0.9 `` interface are modules exporting
1111
1131
the symbol ``tests :: IO [Test] ``. The ``Test `` type is exported by the
@@ -1264,8 +1284,8 @@ standard output and error channels.
1264
1284
even if that file is generated using a preprocessor. The source file
1265
1285
must be relative to one of the directories listed in
1266
1286
:pkg-field: `hs-source-dirs `. This field is analogous to the ``main-is ``
1267
- field of an executable section. Further, while the name of the file may
1268
- vary, the module itself must be named `` Main `` .
1287
+ field of an executable section; see that documentation for further
1288
+ information .
1269
1289
1270
1290
Example:
1271
1291
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
0 commit comments