<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">I think of it like this:</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><ul><li>The core of the proposal is a way to map the value returned by `main` to an exit code.</li><li>The status quo is that it is always mapped to zero.</li><li>Your (2) continues with the status quo but adds a warning for return types other than () and Void. Not worth doing in my view.</li><li>The type-class idea provides a general way to map the return value to an exit code. Good plan.<br></li><li>I think we have to gate the extension, because currently a program with `main :: IO ExitCode` will always return exit code 0; but with the type-class thing it'll return the specified exit code. A change in behaviour.</li><li>With no extension, but warning (<b>not </b>erroring), old programs (with say `main :: IO Bool`) may start to warn; that's OK. It's easy to fix in a backward compatible way. It's a bit like any other new warning.</li></ul><div>Another possible plan, call it (4) in your list is: <b>if `main :: IO ExitCode` then use that exit code. For all other types, return exit code 0</b>. That is simpler than the type class story, but you don't list it as a possibility.</div><div><br></div><div>My top picks are:</div><div><ul><li>(4) just make main :: IO ExitCode special</li><li>(1c) Type class form, gated by an extension, with warning for non-instance types<br></li><ul><li>Without the extension, today's behaviour (000000); </li><li>with the extension, warn if the return type is no an instance (TTWTWT).</li></ul></ul><div>Sadly, neither of these is in your list,, but those are the two that seem plausible to me.</div><div><br></div><div>I feel we should be involving Shea, and indeed the wider community. If a bunch of actual users had strong opinions, I would immediately withdraw mine. I don't feel strongly.<br></div><div><br></div><div>Simon<br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 26 Mar 2024 at 15:24, Arnaud Spiwack <<a href="mailto:arnaud.spiwack@tweag.io">arnaud.spiwack@tweag.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Of course I'll ask Shea, but I want to gather thoughts first. Hence my call for a vote. If I may make a final attempt at defining the options I layed out. If it doesn't work, I'll change my strategy.<br></div><div><br></div><div>Legend:</div><div>- 0: main exits with exit code 0 (success)<br></div><div>- E: type error</div><div>- W: a warning is emitted</div><div>- T: the `ExitStatus` type class is used to select the exit code. (On Void and (), T and 0 are the same thing)<br></div><div>- N: not available under this alternative<br></div><div><br></div><div>Your examples:</div><div><div style="font-family:tahoma,sans-serif">
<div style="font-family:tahoma,sans-serif">module Ex1 where { ..; main :: IO Void }</div>
<div style="font-family:tahoma,sans-serif">module Ex2 where { ..; main :: IO () }</div>
module Ex3 where { ..; main :: IO Int }</div><div style="font-family:tahoma,sans-serif">module Ex4 where { ...; main :: IO ExitCode } -- ExitCode exists already</div><div style="font-family:tahoma,sans-serif">module Ex5 where { ...; main :: IO Bool } -- No ExitStatus instance for Bool<br></div><div style="font-family:tahoma,sans-serif">module Ex6 where { ...; data T = ..; main :: IO T; instance ExitStatus T where ... }</div><div style="font-family:tahoma,sans-serif"><br></div><div style="font-family:tahoma,sans-serif">Alternatives:</div><div style="font-family:tahoma,sans-serif"><div>1a. TT0T0T (this is Shea's preferred proposal)<br></div><div>1b. -XNoWombat: 000000 / -XWombat TTETET<br></div><div>2. 00WWWN</div><div>3a. -XNoWombat: 00WWWW / -XWombat: TTETET</div><div>3b. -XNoWombat: 00WWWW / -XWombat: TTWTWT</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 26 Mar 2024 at 12:57, Simon Peyton Jones <<a href="mailto:simon.peytonjones@gmail.com" target="_blank">simon.peytonjones@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:tahoma,sans-serif">I'm sorry Arnaud, but my brain is insufficiently large to accommodate the implications of five different briefly specified options. Would you (or Shea) like to specify them more precisely, perhaps on GH since email threads are harder to follow (and it allows others to contribute). I think it would help to give some examples to illustrate the consequences of each.</div><div style="font-family:tahoma,sans-serif"><br></div><div style="font-family:tahoma,sans-serif">Here's the kind of thing I mean (below).</div><div style="font-family:tahoma,sans-serif"><br></div><div style="font-family:tahoma,sans-serif">Also can we check with Shea that he is content with these options? It's his proposal</div><div style="font-family:tahoma,sans-serif"><br></div><div style="font-family:tahoma,sans-serif">Simon</div><div style="font-family:tahoma,sans-serif"><br></div><div style="font-family:tahoma,sans-serif"><br></div><div style="font-family:tahoma,sans-serif">
<div style="font-family:tahoma,sans-serif">module Ex1 where { ..; main :: IO Void }</div>
<div style="font-family:tahoma,sans-serif">module Ex2 where { ..; main :: IO () }</div>
module Ex3 where { ..; main :: IO Int }</div><div style="font-family:tahoma,sans-serif">module Ex4 where { ...; main :: IO ExitCode } -- ExitCode exists already</div><div style="font-family:tahoma,sans-serif">module Ex5 where { ...; main :: IO Bool } -- No ExitStatus instance for Bool<br></div><div style="font-family:tahoma,sans-serif">module Ex6 where { ...; data T = ..; main :: IO T; instance ExitStatus T where ... }</div><div style="font-family:tahoma,sans-serif"><br></div><div style="font-family:tahoma,sans-serif"><b>Option 1:
a warning when main isn't at type IO () or IO Void</b><br></div><div style="font-family:tahoma,sans-serif"><ul><li>A warning on Ex3-6.</li><li>Ex4 returns exit code 0<br></li><li>Is this warning on by default? Can it be suppressed? (Rather than provide -Wnoxxx flag, we could just say "change the code to return ()"</li></ul><div><b>Option 2:
New type-class-based behaviour without extension
</b></div></div><div style="font-family:tahoma,sans-serif"><ul><li>Ex1,2,4.6 work fine</li><li>Ex4 returns the specified exit code.</li><li>Ex3, and Ex5 yields "no instance for ExitStatus Int" (and Bool resp)</li></ul><div><b>Option 2a: Like Option 2 but with warning</b></div><div><ul><li>Ex3 and Ex5 yield a warning not at error; but run fine<br></li></ul></div><div>
<div><b>Option 3:
New type-class-based behaviour with extension <br></b></div><div><ul><li>Without -XWombat: like Option 1</li><li>With -XWombat: like Option </li></ul><div>
<div><b>Option 3a: Like Option 3 but with warning</b></div><div><ul><li>
With -XWombat, Ex3 and Ex5 yield a warning not at error; but run fine
</li></ul></div>
</div></div>
</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 26 Mar 2024 at 09:35, Arnaud Spiwack <<a href="mailto:arnaud.spiwack@tweag.io" target="_blank">arnaud.spiwack@tweag.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Alright, so here are the plausible alternatives</div><div><br></div><div>1a. New type-class-based behaviour without extension</div><div>1b. New type-class-based behaviour gated by an extension</div><div>2. Just a warning (when main isn't at type IO () or IO Void)</div><div>3a. A warning + the new type-class-based behaviour gated by an extension. With the extension, types that don't implement the type class raise an error.</div><div>3b. A warning + the new type-class-based behaviour gated by an extension.
With the extension, types that don't implement the type class raise a warning (which could have a different phrasing than without the extension).</div><div><br></div><div>Let's vote!<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 22 Mar 2024 at 15:30, Malte Ott <<a href="mailto:malte.ott@maralorn.de" target="_blank">malte.ott@maralorn.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2024-03-22 08:58, Arnaud Spiwack wrote:<br>
> @Malte, in my opinion, with the extension on, types which are not covered<br>
> by the type class should error out.<br>
<br>
Ah, I see. Well, I am fine either way.<br>
<br>
I just don’t see much value in deciding for the user which code problems are<br>
unacceptable. Especially since this will make the corresponding language<br>
extension more breaking and thus harder to make the default.<br>
Others have voiced similar opinions in the GitHub thread.<br>
<br>
Best<br>
Malte<br>
_______________________________________________<br>
ghc-steering-committee mailing list<br>
<a href="mailto:ghc-steering-committee@haskell.org" target="_blank">ghc-steering-committee@haskell.org</a><br>
<a href="https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee" rel="noreferrer" target="_blank">https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee</a><br>
</blockquote></div><br clear="all"><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Arnaud Spiwack<br>Director, Research at <a href="https://moduscreate.com" rel="noopener noreferrer" target="_blank">https://moduscreate.com</a> and <a href="https://tweag.io" rel="noopener noreferrer" target="_blank">https://tweag.io</a>.</div></div>
_______________________________________________<br>
ghc-steering-committee mailing list<br>
<a href="mailto:ghc-steering-committee@haskell.org" target="_blank">ghc-steering-committee@haskell.org</a><br>
<a href="https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee" rel="noreferrer" target="_blank">https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee</a><br>
</blockquote></div>
</blockquote></div><br clear="all"><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Arnaud Spiwack<br>Director, Research at <a href="https://moduscreate.com" rel="noopener noreferrer" target="_blank">https://moduscreate.com</a> and <a href="https://tweag.io" rel="noopener noreferrer" target="_blank">https://tweag.io</a>.</div></div></div>
</blockquote></div></div>