<div dir="ltr"><div>> <span>But actually I had hoped we can come up with something more 
general and less ad-hoc than the behavior of 8.8. Maybe there isn't and 
8.8 already lived in the sweet spot.</span></div><div><span><br></span></div><div><span>I think that it's quite fine (maybe desirable even) for error and warning messages to be ad hoc.<br></span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 10, 2021 at 8:29 AM Sebastian Graf <<a href="mailto:sgraf1337@gmail.com">sgraf1337@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><div>I agree in principle, but then what about data types with strict fields? E.g.</div><div><br></div><div>data SMaybe a = SNothing | SJust !a</div><div><br></div><div>f :: SMaybe Bool -> ()</div><div>f SNothing = ()</div><div><br></div><div>Today, we'd suggest `SJust _`.</div><div>But the checker can't differentiate between evaluation done by a pattern-match of the user vs. something like a strict field that was unlifted to begin with.</div><div>So we'd suggest `SJust True` and `SJust False`.</div><div><span><br></span></div><div><span>Similarly, we'd case split unlifted data types by default, but not lifted data types.</span></div><div><span><br></span></div><div><span>I think I can easily make the whole function (`GHC.HsToCore.Pmc.Solver.generateInhabitingPatterns`) dependent on whether it's called from an EmptyCase or not, to recover the behavior pre-8.10.<br>But actually I had hoped we can come up with something more general and less ad-hoc than the behavior of 8.8. Maybe there isn't and 8.8 already lived in the sweet spot.</span></div><div><div><div></div></div></div>
<div><br></div>
<div>------ Originalnachricht ------</div>
<div>Von: "Richard Eisenberg" <<a href="mailto:lists@richarde.dev" target="_blank">lists@richarde.dev</a>></div>
<div>An: "Sebastian Graf" <<a href="mailto:sgraf1337@gmail.com" target="_blank">sgraf1337@gmail.com</a>></div>
<div>Cc: "ghc-devs" <<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a>></div>
<div>Gesendet: 10.11.2021 04:44:50</div>
<div>Betreff: Re: Case split uncovered patterns in warnings or not?</div><div><br></div>
<div id="gmail-m_5670611891134861423x8358848d446e436" style="overflow-wrap: break-word;"><blockquote cite="http://010f017d07f2c3df-5a0fe22c-63b6-4191-97b3-2ea484ca6a4a-000000@us-east-2.amazonses.com" type="cite" class="gmail-m_5670611891134861423cite2">
Maybe the answer should depend on whether the scrutinee has already been forced. The new output ("We now say", below) offers up patterns that will change the strictness behavior of the code. The old output did not.<div><br></div><div>Reading the link below, I see that, previously, there was an inconsistency with -XEmptyCase, which *did* unroll one level of constructor. But maybe that made sense because -XEmptyCase is strict (unlike normal case).</div><div><br></div><div>I'm just saying this because I think listing the constructors in the -XEmptyCase case is a good practice, but otherwise I think they're clutterful... and strictness is a perhaps more principled way of making this distinction.</div><div><br></div><div>Richard<br><div><br><blockquote type="cite"><div>On Nov 9, 2021, at 8:17 AM, Sebastian Graf <<a href="mailto:sgraf1337@gmail.com" target="_blank">sgraf1337@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div>Hi Devs,</div><div><br></div><div>In <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/20642" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/issues/20642</a> we saw that GHC >= 8.10 outputs pattern match warnings a little differently than it used to. Example from there:</div><div><br></div><div><pre lang="haskell"><span id="gmail-m_5670611891134861423gmail-LC1" lang="haskell"><span>{-# OPTIONS_GHC -Wincomplete-uni-patterns #-}</span></span>
<span id="gmail-m_5670611891134861423gmail-LC2" lang="haskell"></span>
<span id="gmail-m_5670611891134861423gmail-LC3" lang="haskell"><span>foo</span> <span>::</span> <span>[</span><span>a</span><span>]</span> <span>-></span> <span>[</span><span>a</span><span>]</span></span>
<span id="gmail-m_5670611891134861423gmail-LC4" lang="haskell"><span>foo</span> <span>[]</span> <span>=</span> <span>[]</span></span>
<span id="gmail-m_5670611891134861423gmail-LC5" lang="haskell"><span>foo</span> <span>xs</span> <span>=</span> <span>ys</span></span>
<span id="gmail-m_5670611891134861423gmail-LC6" lang="haskell">  <span>where</span></span>
<span id="gmail-m_5670611891134861423gmail-LC7" lang="haskell">  <span>(</span><span>_</span><span>,</span> <span>ys</span><span>@</span><span>(</span><span>_</span><span>:</span><span>_</span><span>))</span> <span>=</span> <span>splitAt</span> <span>0</span> <span>xs</span></span>
<span id="gmail-m_5670611891134861423gmail-LC8" lang="haskell"></span>
<span id="gmail-m_5670611891134861423gmail-LC9" lang="haskell"><span>main</span> <span>::</span> <span>IO</span> <span>()</span></span>
<span id="gmail-m_5670611891134861423gmail-LC10" lang="haskell"><span>main</span> <span>=</span> <span>putStrLn</span> <span>$</span> <span>foo</span> <span>$</span> <span>"Hello, coverage checker!"</span></span><span style="font-family:arial,sans-serif"><br></span></pre><pre lang="haskell"><span style="font-family:arial,sans-serif">Instead of saying</span><br><br><span id="gmail-m_5670611891134861423gmail-LC1" lang="plaintext">ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]</span>
<span id="gmail-m_5670611891134861423gmail-LC2" lang="plaintext">    Pattern match(es) are non-exhaustive</span>
<span id="gmail-m_5670611891134861423gmail-LC3" lang="plaintext">    In a pattern binding: Patterns not matched: (_, [])</span>
<br></pre><pre lang="haskell"><span style="font-family:arial,sans-serif">We now say</span><br><br><span id="gmail-m_5670611891134861423gmail-LC50" lang="plaintext">ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]</span>
<span id="gmail-m_5670611891134861423gmail-LC51" lang="plaintext">    Pattern match(es) are non-exhaustive</span>
<span id="gmail-m_5670611891134861423gmail-LC52" lang="plaintext">    In a pattern binding:</span>
<span id="gmail-m_5670611891134861423gmail-LC53" lang="plaintext">        Patterns of type ‘([a], [a])’ not matched:</span>
<span id="gmail-m_5670611891134861423gmail-LC54" lang="plaintext">            ([], [])</span>
<span id="gmail-m_5670611891134861423gmail-LC55" lang="plaintext">            ((_:_), [])</span>
<br></pre>E.g., newer versions do (one) case split on pattern variables that haven't even been scrutinised by the pattern match. That amounts to quantitatively more pattern suggestions and for each variable a list of constructors that could be matched on.<br>The motivation for the change is outlined in <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/20642#note_390110" target="_blank">https://gitlab.haskell.org/ghc/ghc/-/issues/20642#note_390110</a>, but I could easily be swayed not to do the case split. Which arguably is less surprising, as Andreas Abel points out.<br><br>Considering the other examples from my post, which would you prefer?<br><br>Cheers,<br>Sebastian</div></div>
_______________________________________________<br>ghc-devs mailing list<br><a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br></div></blockquote></div><br></div></blockquote></div>
</div>_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>