<div dir="ltr"><div class="gmail_default" style="font-family:times new roman,serif;font-size:large">I've decided to stick with case and pattern matching as Henning suggested in his original reply.</div><div class="gmail_default" style="font-family:times new roman,serif;font-size:large"><br></div><div class="gmail_default" style="font-family:times new roman,serif;font-size:large">Thanks</div><div class="gmail_default" style="font-family:times new roman,serif;font-size:large"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 20, 2024 at 12:30 PM Andrew Lelechenko <<a href="mailto:andrew.lelechenko@gmail.com">andrew.lelechenko@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>Hi George,<div><br></div><div>If you do not want to pattern match on `ys`, the simplest solution is to do what the GHC warning suggests you to do and use `drop 1` instead of `tail`. Another alternative is `Data.List.uncons` followed by `Data.Maybe.maybe`. </div><div><br></div><div>Best regards,</div><div>Andrew<br><div><br><blockquote type="cite"><div>On 20 Apr 2024, at 13:28, George Colpitts <<a href="mailto:george.colpitts@gmail.com" target="_blank">george.colpitts@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">Thanks for everybody's replies</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">To give more context the original code from Ch. 12 of Bird's <i>Thinking Functionally with Haskell</i> was:</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><blockquote style="font-family:Arial,Helvetica,sans-serif;font-size:small;margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br>let (xs, ys) = break (== ch) str in</div></blockquote><div class="gmail_default">         if null ys then [] else [(xs, tail ys)])</div></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">I replaced it with </div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">let (xs, ys@(_ : t)) = break (== ch) str in</div></blockquote><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">         if null ys then [] else [(xs, t)])<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 16, 2024 at 10:51 AM George Colpitts <<a href="mailto:george.colpitts@gmail.com" target="_blank">george.colpitts@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 class="gmail_default" style="font-family:"times new roman",serif;font-size:large">ghc should be able to deduce correct use of partial functions and not give a warning in such cases, e.g. in 9.8.2<br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">     if null ys then [] else [(xs,tail ys)])</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">gets a warning</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">      warning: [GHC-63394] [-Wx-partial]</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">but it is clear that this use of tail will never be a problem so IMHO that line of code should not get a warning. </div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">Does anybody know if there is a plan or enhancement request to eliminate such warnings? </div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">Cheers</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large">George</div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div><div class="gmail_default" style="font-family:"times new roman",serif;font-size:large"><br></div></div>
</blockquote></div>
_______________________________________________<br>Haskell-Cafe mailing list<br>To (un)subscribe, modify options or view archives go to:<br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>Only members subscribed via the mailman list are allowed to post.</div></blockquote></div><br></div></div></blockquote></div>