<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 9, 2021, at 8:17 AM, Sebastian Graf <<a href="mailto:sgraf1337@gmail.com" class="">sgraf1337@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi Devs,</div><div class=""><br class=""></div><div class="">In <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/20642" class="">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 class=""><br class=""></div><div class=""><pre class="gmail-highlight gmail-code" lang="haskell"><span id="gmail-LC1" class="gmail-line" lang="haskell"><span class="gmail-cp">{-# OPTIONS_GHC -Wincomplete-uni-patterns #-}</span></span>
<span id="gmail-LC2" class="gmail-line" lang="haskell"></span>
<span id="gmail-LC3" class="gmail-line" lang="haskell"><span class="gmail-n">foo</span> <span class="gmail-o">::</span> <span class="gmail-p">[</span><span class="gmail-n">a</span><span class="gmail-p">]</span> <span class="gmail-o">-></span> <span class="gmail-p">[</span><span class="gmail-n">a</span><span class="gmail-p">]</span></span>
<span id="gmail-LC4" class="gmail-line" lang="haskell"><span class="gmail-n">foo</span> <span class="gmail-kt">[]</span> <span class="gmail-o">=</span> <span class="gmail-kt">[]</span></span>
<span id="gmail-LC5" class="gmail-line" lang="haskell"><span class="gmail-n">foo</span> <span class="gmail-n">xs</span> <span class="gmail-o">=</span> <span class="gmail-n">ys</span></span>
<span id="gmail-LC6" class="gmail-line" lang="haskell"> <span class="gmail-kr">where</span></span>
<span id="gmail-LC7" class="gmail-line" lang="haskell"> <span class="gmail-p">(</span><span class="gmail-kr">_</span><span class="gmail-p">,</span> <span class="gmail-n">ys</span><span class="gmail-o">@</span><span class="gmail-p">(</span><span class="gmail-kr">_</span><span class="gmail-o">:</span><span class="gmail-kr">_</span><span class="gmail-p">))</span> <span class="gmail-o">=</span> <span class="gmail-n">splitAt</span> <span class="gmail-mi">0</span> <span class="gmail-n">xs</span></span>
<span id="gmail-LC8" class="gmail-line" lang="haskell"></span>
<span id="gmail-LC9" class="gmail-line" lang="haskell"><span class="gmail-n">main</span> <span class="gmail-o">::</span> <span class="gmail-kt">IO</span> <span class="gmail-nb">()</span></span>
<span id="gmail-LC10" class="gmail-line" lang="haskell"><span class="gmail-n">main</span> <span class="gmail-o">=</span> <span class="gmail-n">putStrLn</span> <span class="gmail-o">$</span> <span class="gmail-n">foo</span> <span class="gmail-o">$</span> <span class="gmail-s">"Hello, coverage checker!"</span></span><span style="font-family:arial,sans-serif" class=""><br class=""></span></pre><pre class="gmail-highlight gmail-code" lang="haskell"><span style="font-family:arial,sans-serif" class="">Instead of saying</span><br class=""><br class=""><span id="gmail-LC1" class="gmail-line" lang="plaintext">ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]</span>
<span id="gmail-LC2" class="gmail-line" lang="plaintext"> Pattern match(es) are non-exhaustive</span>
<span id="gmail-LC3" class="gmail-line" lang="plaintext"> In a pattern binding: Patterns not matched: (_, [])</span>
<br class=""></pre><pre class="gmail-highlight gmail-code" lang="haskell"><span style="font-family:arial,sans-serif" class="">We now say</span><br class=""><br class=""><span id="gmail-LC50" class="gmail-line" lang="plaintext">ListPair.hs:7:3: warning: [-Wincomplete-uni-patterns]</span>
<span id="gmail-LC51" class="gmail-line" lang="plaintext"> Pattern match(es) are non-exhaustive</span>
<span id="gmail-LC52" class="gmail-line" lang="plaintext"> In a pattern binding:</span>
<span id="gmail-LC53" class="gmail-line" lang="plaintext"> Patterns of type ‘([a], [a])’ not matched:</span>
<span id="gmail-LC54" class="gmail-line" lang="plaintext"> ([], [])</span>
<span id="gmail-LC55" class="gmail-line" lang="plaintext"> ((_:_), [])</span>
<br class=""></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 class="">The motivation for the change is outlined in <a href="https://gitlab.haskell.org/ghc/ghc/-/issues/20642#note_390110" class="">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 class=""><br class="">Considering the other examples from my post, which would you prefer?<br class=""><br class="">Cheers,<br class="">Sebastian</div></div>
_______________________________________________<br class="">ghc-devs mailing list<br class=""><a href="mailto:ghc-devs@haskell.org" class="">ghc-devs@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs<br class=""></div></blockquote></div><br class=""></div></body></html>