diff options
author | chessai <chessai1996@gmail.com> | 2018-10-02 14:46:08 +0200 |
---|---|---|
committer | Krzysztof Gogolewski <krz.gogolewski@gmail.com> | 2018-10-02 16:00:19 +0200 |
commit | abfb91fb0ea27eb618f297b1d3ba60cfa021afe0 (patch) | |
tree | f35b012fb723e44c015a97c69c128019755fd580 /docs/users_guide/bugs.rst | |
parent | caffff1238097821cd2879f7285010a6565afd52 (diff) | |
download | haskell-abfb91fb0ea27eb618f297b1d3ba60cfa021afe0.tar.gz |
resolve T13704
Summary: allow -main-is to change export list for default module
header, allowing one to change the entry point to one's program.
Test Plan: ./validate
Reviewers: bgamari, nomeata, mpickering
Reviewed By: mpickering
Subscribers: mpickering, rwbarton, carter
GHC Trac Issues: #13704
Differential Revision: https://phabricator.haskell.org/D5189
Diffstat (limited to 'docs/users_guide/bugs.rst')
-rw-r--r-- | docs/users_guide/bugs.rst | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/users_guide/bugs.rst b/docs/users_guide/bugs.rst index aee8dc5842..0290622b62 100644 --- a/docs/users_guide/bugs.rst +++ b/docs/users_guide/bugs.rst @@ -173,6 +173,34 @@ same context. For example, this is fine: :: .. _infelicities-Modules: +Default Module headers with -main-is +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The Haskell2010 report specifies in <https://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-990005.1> that + + "An abbreviated form of module, consisting only of the module body, + is permitted. If this is used, the header is assumed to be + `module Main(main) where`." + +Consider the following program: :: + + -- file: Main.hs + program :: IO () + program = return () + +Under the report, this would fail with ``ghc -main-is Main.program Main.hs`` +with the following errors: :: + + Main.hs:1:1: error: + Not in scope: 'main' + Perhaps you meant 'min' (imported from Prelude) + + Main.hs:1:1: error: + The main IO action 'program' is not exported by module 'Main' + +GHC's flag '-main-is' allows one to change the entry point name so that +the above example would succeed. + Module system and interface files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |