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

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Tue Apr 18 21:51:16 UTC 2017


On 18 April 2017 at 22:52, Edward Kmett <ekmett at gmail.com> wrote:
> 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.

I've actually been considering that recently.

I'm weakly +1 on this proposal as well.

>
> -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
>>
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


More information about the Libraries mailing list