Default module header `module Main where`

Iavor Diatchki iavor.diatchki at gmail.com
Tue May 16 20:25:16 UTC 2017


One potential difference between the two is that the current behavior
allows the `Main` module to import `main` from another module, while the
new behavior would fail in that case.

For example, a file that has only a single line:

    import SomeOtherModule(main)

This still seems like a fairly unusual corner case (with an obvious work
around), so I don't think it matters much, but I thought I'd mention it so
that we are aware of it.






On Tue, May 16, 2017 at 7:18 AM, Joachim Breitner <mail at joachim-breitner.de>
wrote:

> Hi,
>
> a very small proposal to be considered for Haskell':
>
> Currently, the report states
>
>     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’.
>
> I propose to change that to
>
>     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 where’.
>
> The rationale is that a main-less main module is still useful, e.g.
> when you are working a lot in GHCi, and offload a few extensions to a
> separate file. Currently, tools like hdevtools will complain about a
> missing main function when editing such a file.
>
> It would also work better with GHC’s -main-is flag, and avoid problems
> like the one described in https://ghc.haskell.org/trac/ghc/ticket/13704
>
>
> I don’t see any downsides. When compiling to a binary, implementations
> are still able to detect that a Main module is not imported by any
> other module and only the main function is used, and optimize as if
> only main were exported.
>
> Greetings,
> Joachim
>
>
>
> --
> Joachim “nomeata” Breitner
>   mail at joachim-breitner.dehttps://www.joachim-breitner.de/
>   XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
>   Debian Developer: nomeata at debian.org
> _______________________________________________
> Haskell-prime mailing list
> Haskell-prime at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-prime/attachments/20170516/0c22e88d/attachment.html>


More information about the Haskell-prime mailing list