[Haskell-cafe] Strange quirk with {} syntax?

Noon van der Silk noonsilk at gmail.com
Thu Nov 30 13:46:30 UTC 2023

Sometimes I have a type like:

    data A = A1 Int | A2 Int Int

Then if I want to do pattern matching and ignore the parameters I do:

    f (A1 _) = ..
    f (A2 _ _) = ...

But that's annoying; I need to remember how many parameters each one has!

Yesterday I learned I can just do this:

    f A1 {} = ...
    f A2 {} = ...

And GHC is happy.

Is this expected? Am I the last to learn about this trick?

Noon van der Silk, ن


"My programming language is kindness."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20231130/76464a91/attachment.html>

More information about the Haskell-Cafe mailing list