@@ -1043,12 +1043,32 @@ build information fields (see the section on `build information`_).
10431043
10441044.. pkg-field :: main-is: filename (required)
10451045
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+
10521072
10531073 Starting with ``cabal-version: 1.18 `` this field supports
10541074 specifying a C, C++, or objC source file as the main entry point.
@@ -1105,7 +1125,7 @@ field.
11051125 even if that file is generated using a preprocessor. The source file
11061126 must be relative to one of the directories listed in
11071127 :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 .
11091129
11101130Test suites using the ``detailed-0.9 `` interface are modules exporting
11111131the symbol ``tests :: IO [Test] ``. The ``Test `` type is exported by the
@@ -1264,8 +1284,8 @@ standard output and error channels.
12641284 even if that file is generated using a preprocessor. The source file
12651285 must be relative to one of the directories listed in
12661286 :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 .
12691289
12701290Example:
12711291"""""""""""""""""""""""""""""""""""""""""""""""""""""""
0 commit comments