<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>It should not. Not even when forced.<br>
<br>
I have seen an `Integer` constructors presented to me, for
example:<br>
<br>
module Ex where<br>
<br>
foo :: Bool -> Integer -> Integer<br>
foo True i = i<br>
<br>
With GHC-8.8 the warning is good:<br>
<br>
% ghci-8.8.4 -Wall Ex.hs <br>
GHCi, version 8.8.4: <a class="moz-txt-link-freetext" href="https://www.haskell.org/ghc/">https://www.haskell.org/ghc/</a> :? for help<br>
Loaded GHCi configuration from /home/phadej/.ghci<br>
[1 of 1] Compiling Ex ( Ex.hs, interpreted )<br>
<br>
Ex.hs:4:1: warning: [-Wincomplete-patterns]<br>
Pattern match(es) are non-exhaustive<br>
In an equation for ‘foo’: Patterns not matched: False _<br>
|<br>
4 | foo True i = i<br>
| ^^^^^^^^^^^^^^<br>
<br>
With GHC-8.10 is straight up awful.<br>
I'm glad I don't have to explain it to any beginner,<br>
or person who don't know how Integer is implemented.<br>
(9.2 is about as bad too).<br>
<br>
% ghci-8.10.4 -Wall Ex.hs<br>
GHCi, version 8.10.4: <a class="moz-txt-link-freetext" href="https://www.haskell.org/ghc/">https://www.haskell.org/ghc/</a> :? for
help<br>
Loaded GHCi configuration from /home/phadej/.ghci<br>
[1 of 1] Compiling Ex ( Ex.hs, interpreted )<br>
<br>
Ex.hs:4:1: warning: [-Wincomplete-patterns]<br>
Pattern match(es) are non-exhaustive<br>
In an equation for ‘foo’:<br>
Patterns not matched:<br>
False (integer-gmp-1.0.3.0:GHC.Integer.Type.S# _)<br>
False (integer-gmp-1.0.3.0:GHC.Integer.Type.Jp# _)<br>
False (integer-gmp-1.0.3.0:GHC.Integer.Type.Jn# _)<br>
|<br>
4 | foo True i = i<br>
| ^^^<br>
<br>
- Oleg<br>
<br>
</p>
<div class="moz-cite-prefix">On 9.11.2021 15.17, Sebastian Graf
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAAS+=P8uEkt_tiNfcia1WxNmJzF2OXvJkpf-oGuGrJEKqmxQQg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hi Devs,</div>
<div><br>
</div>
<div>In <a
href="https://gitlab.haskell.org/ghc/ghc/-/issues/20642"
moz-do-not-send="true">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 class="gmail-code gmail-highlight" 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">
</span></pre>
<pre class="gmail-code gmail-highlight" lang="haskell"><span style="font-family:arial,sans-serif">Instead of saying</span>
<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>
</pre>
<pre class="gmail-code gmail-highlight" lang="haskell"><span style="font-family:arial,sans-serif">We now say</span>
<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>
</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"
moz-do-not-send="true">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>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
ghc-devs mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a>
</pre>
</blockquote>
</body>
</html>