<html><head></head><body><div class="ydpcdba6240yahoo-style-wrap" style="font-family:courier new, courier, monaco, monospace, sans-serif;font-size:13px;"><div></div>
<div dir="ltr" data-setdir="false">Like others, this caught me by surprise, but now I use it regularly.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">I use hlint to advise me on the quality of my Haskell code. I have learned many, many good ideas from hlint.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">As of a few years ago, hlint begins to recommend changing f (A3 _ _ _) = ... to f A3 {} = ... as soon as there are three or more components.</div><div><br></div>
</div><div id="yahoo_quoted_1921610760" class="yahoo_quoted">
<div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
<div>
On Thursday, November 30, 2023 at 09:12:09 AM EST, Brent Yorgey <byorgey@gmail.com> wrote:
</div>
<div><br></div>
<div><br></div>
<div><div id="yiv4016296061"><div><div dir="ltr">Yes, you're the last to learn about it; we were all wondering when you would figure it out. ;-)<div><br clear="none"></div><div>It's definitely "folklore", I can't remember where I first learned about it. I agree with Tom that it's surprising (but nice) that it works even with data types that were not declared using record syntax. I also always find it surprising that record update or matching binds more tightly than function application, so that no parentheses are needed. Sometimes I feel like it would actually look nicer to write </div><div><br clear="none"></div><div>f (A1 {}) = ...</div><div><br clear="none"></div><div>but then hlint yells at me. (Yes, I'm aware I can turn off individual hlint warnings. =)</div><div><br clear="none"></div><div>-Brent</div></div><br clear="none"><div class="yiv4016296061gmail_quote"><div id="yiv4016296061yqt39986" class="yiv4016296061yqt1484390762"><div dir="ltr" class="yiv4016296061gmail_attr">On Thu, Nov 30, 2023 at 7:47 AM Noon van der Silk <<a rel="nofollow noopener noreferrer" shape="rect" ymailto="mailto:noonsilk@gmail.com" target="_blank" href="mailto:noonsilk@gmail.com">noonsilk@gmail.com</a>> wrote:<br clear="none"></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;" class="yiv4016296061gmail_quote"><div dir="ltr">Sometimes I have a type like:<div><br clear="none"></div><div> data A = A1 Int | A2 Int Int</div><div><br clear="none"></div><div>Then if I want to do pattern matching and ignore the parameters I do:</div><div><br clear="none"></div><div> f (A1 _) = ..</div><div> f (A2 _ _) = ...</div><div><br clear="none"></div><div>But that's annoying; I need to remember how many parameters each one has!</div><div><br clear="none"></div><div>Yesterday I learned I can just do this:</div><div><br clear="none"></div><div> f A1 {} = ...</div><div> f A2 {} = ...</div><div><br clear="none"></div><div>And GHC is happy.</div><div><br clear="none"></div><div>Is this expected? Am I the last to learn about this trick?</div><div><div><br clear="none"></div><span class="yiv4016296061gmail_signature_prefix">-- </span><br clear="none"><div dir="ltr" class="yiv4016296061gmail_signature"><div dir="ltr"><div dir="ltr">Noon van der Silk, ن<br clear="none"><br clear="none"><a rel="nofollow noopener noreferrer" shape="rect" target="_blank" href="http://silky.github.io/">http://silky.github.io/</a><br clear="none"><br clear="none">"My programming language is kindness."</div></div></div></div></div>
_______________________________________________<br clear="none">
Haskell-Cafe mailing list<br clear="none">
To (un)subscribe, modify options or view archives go to:<br clear="none">
<a rel="nofollow noopener noreferrer" shape="rect" target="_blank" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br clear="none">
Only members subscribed via the mailman list are allowed to post.</blockquote></div></div>
</div></div><div class="yqt1484390762" id="yqt51348">_______________________________________________<br clear="none">Haskell-Cafe mailing list<br clear="none">To (un)subscribe, modify options or view archives go to:<br clear="none"><a shape="rect" 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 clear="none">Only members subscribed via the mailman list are allowed to post.</div></div>
</div>
</div></body></html>