
you're inside the module, so you have access to all top-level bindings, not just to the export list. the issue with the implicit `module Main(main) where` is that it errors if main is not defined, even though that's a perfectly harmless situation. (i hope i got the question right?) On Tue, May 16, 2017 at 05:53:17PM +0000, Adam Bergmark wrote:
Date: Tue, 16 May 2017 17:53:17 +0000 From: Adam Bergmark
To: José Manuel Calderón Trilla , haskell-prime@haskell.org Subject: Re: Default module header `module Main where` GHCIs current behavior seems inconsistent with this, why is foo accessible and why don't I get an unused warning like i do if i have an explicit `module Main (main) where`?
``` $ cat Main.hs main :: IO () main = pure ()
foo :: Int foo = 1
$ ghci Main.hs -Wall GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /Users/adam.bergmark/.ghci [1 of 1] Compiling Main ( Main.hs, interpreted ) Ok, modules loaded: Main.
λ foo 1 ```
On Tue, 16 May 2017 at 19:00 José Manuel Calderón Trilla
wrote: Agreed, this sounds sensible.
Can anyone think of any unintended consequences?
-Jose
On Tue, May 16, 2017, at 09:50 AM, Iavor Diatchki wrote:
That seems fairly reasonable to me.
-Iavor
On Tue, May 16, 2017 at 7:18 AM, Joachim Breitner < mail@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@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org _______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
*_______________________________________________* Haskell-prime mailing list Haskell-prime@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
_______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
_______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-prime
-- https://zerobuzz.net/ mf@zerobuzz.net +49 179 7733 223