<div dir="ltr">Yes, you're the last to learn about it; we were all wondering when you would figure it out. ;-)<div><br></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></div><div>f (A1 {}) = ...</div><div><br></div><div>but then hlint yells at me.  (Yes, I'm aware I can turn off individual hlint warnings. =)</div><div><br></div><div>-Brent</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 30, 2023 at 7:47 AM Noon van der Silk <<a href="mailto:noonsilk@gmail.com">noonsilk@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">Sometimes I have a type like:<div><br></div><div>    data A = A1 Int | A2 Int Int</div><div><br></div><div>Then if I want to do pattern matching and ignore the parameters I do:</div><div><br></div><div>    f (A1 _) = ..</div><div>    f (A2 _ _) = ...</div><div><br></div><div>But that's annoying; I need to remember how many parameters each one has!</div><div><br></div><div>Yesterday I learned I can just do this:</div><div><br></div><div>    f A1 {} = ...</div><div>    f A2 {} = ...</div><div><br></div><div>And GHC is happy.</div><div><br></div><div>Is this expected? Am I the last to learn about this trick?</div><div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr">Noon van der Silk, ن<br><br><a href="http://silky.github.io/" target="_blank">http://silky.github.io/</a><br><br>"My programming language is kindness."</div></div></div></div></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" rel="noreferrer" 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.</blockquote></div>