<div dir="ltr">Yes I agree with Tom; it's at least a bit unexpected because unlike with records, there is (if I understand well) nothing I can write inside the {} that would actually be valid for that type.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 30 Nov 2023 at 14:06, Tom Ellis <<a href="mailto:tom-lists-haskell-cafe-2023@jaguarpaw.co.uk">tom-lists-haskell-cafe-2023@jaguarpaw.co.uk</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">It was unexpected to me because A1 and A2 were not defined as record<br>
constructors.  (Since I discovered it I now use it regularly; it's<br>
very nice.)<br>
<br>
On Thu, Nov 30, 2023 at 02:58:43PM +0100, David Kraeutmann wrote:<br>
> Yes. You're just using record pattern match with no records. Why would it be<br>
> unexpected?<br>
> <br>
> On 30.11.2023 14:46, Noon van der Silk wrote:<br>
> > Sometimes I have a type like:<br>
> > <br>
> >     data A = A1 Int | A2 Int Int<br>
> > <br>
> > Then if I want to do pattern matching and ignore the parameters I do:<br>
> > <br>
> >     f (A1 _) = ..<br>
> >     f (A2 _ _) = ...<br>
> > <br>
> > But that's annoying; I need to remember how many parameters each one has!<br>
> > <br>
> > Yesterday I learned I can just do this:<br>
> > <br>
> >     f A1 {} = ...<br>
> >     f A2 {} = ...<br>
> > <br>
> > And GHC is happy.<br>
> > <br>
> > Is this expected? Am I the last to learn about this trick?<br>
_______________________________________________<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><br clear="all"><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>