Add Arg{Min,Max} pattern synonyms to Data.Semigroup
Mario Blažević
mblazevic at stilo.com
Fri Apr 21 21:42:32 UTC 2017
On 2017-04-18 08:52 AM, Edward Kmett 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.
I'm (-1) until I'm convinced that the phrasing-around approach works.
Can you spell it out?
> 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
> <mailto: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
> <https://ghc.haskell.org/trac/ghc/ticket/13572>
>
More information about the Libraries
mailing list