Add Arg{Min,Max} pattern synonyms to Data.Semigroup

Edward Kmett ekmett at gmail.com
Tue Apr 18 12:52:46 UTC 2017


I'm personally weakly +1 on this. It makes the combination of Arg and Max
much more convenient to use and points directly to how to use it without
code duplication. The potential downside is using a big scary extension in
what will become a fairly mainstream module in 8.4, but I think we can
phrase our way around the issue when it comes to the libraries part of
Haskell-Prime.

This opens the door to possibly being smarter about the existing
Data.Monoid.First (and Last), encoding them as pattern synonyms for Maybe
(Data.Semigroup.First a) (or Last) as well, but we'd likely need to give
that a lot more thought / testing.

-Edward

On Thu, Apr 13, 2017 at 3:22 PM, Baldur Blöndal <baldurpet at gmail.com> wrote:

> Add (explicitly-bidirectional record) pattern synonyms to Data.Semigroup:
>
> pattern ArgMin :: a -> b -> ArgMin a b pattern ArgMin {minArg, minValue} =
> Min (Arg minArg minValue)
>
> pattern ArgMax :: a -> b -> ArgMax a b pattern ArgMax {maxArg, maxValue} =
> Max (Arg maxArg maxValue)
>
> As described in https://ghc.haskell.org/trac/ghc/ticket/13572
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20170418/b1aeef69/attachment.html>


More information about the Libraries mailing list