Default module header `module Main where`
Mario Blažević
mblazevic at stilo.com
Wed May 24 16:14:44 UTC 2017
On 2017-05-24 10:28 AM, Joachim Breitner wrote:
>> I've ended up uncertain, so I'll just throw it out there: are unused
>> value warnings affected by this proposal?
>
> that is a very good point, thanks for raising it. I have two different
> answers:
>
> A) You are right. Everything is exported, so without an explicit module
> header, unused value warnings would not happen. This is undesirable,
> and thus this proposal should probably be killed.
>
> B) Warnings are not specified by the report, and the implementation is
> free to warn about unused bindings in a headerless Main module, based
> on the implementation’s knowledge that even though these are exported,
> they are not used.
I would say
B') Warnings are not specified by the report.
We can pretty much stop there. If you want to go deeper, IMO the
compiler should just suppress the warnings by default. A headerless
module would normally be used only for examples and quick tests, unused
binding warnings would be a nuisance for that use case.
> But answer B is less convincing in the corner case of Main being
> mutually recursive with another module. (Who would do that without
> naming Main? But yes, it is a problem.)
When dicussing a software-engineering issue like compiler warnings, as
opposed to a language-design issue, it doesn't make sense to concentrate
on corner cases. A non-root Main module is already a corner case. A
non-root header-less Main module is a corner inside a corner case.
Whoever does that may miss some compiler warnings, depending on the
compiler implementation. I won't lose any sleep over that. If the
compiler developers do, they have the option to issue the unused-binding
warnings only when a header-less module is imported.
More information about the Haskell-prime
mailing list