[GHC] #13572: Add ArgMin / ArgMax pattern synonyms

#13572: Add ArgMin / ArgMax pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: | Version: 8.0.1 libraries/base | Keywords: | Operating System: Unknown/Multiple PatternSynonyms | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs import Data.Semigroup pattern ArgMin :: a -> b -> ArgMin a b pattern ArgMin a b = Min (Arg a b) pattern ArgMax :: a -> b -> ArgMax a b pattern ArgMax a b = Max (Arg a b) }}} Or even record pattern synonyms, à la [https://github.com/energyflowanalysis/efa-2.1/blob/3eb86c0b6b2d2fb66cd5b76ce... this] {{{#!hs 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) }}} and we can define {{{#!hs import Data.Semigroup.Foldable argmin :: Ord k => Foldable1 f => (a -> k) -> (f a -> a) argmin f = minValue . foldMap1 (\a -> ArgMin (f a) a) argmax :: Ord k => Foldable1 f => (a -> k) -> (f a -> a) argmax f = maxValue . foldMap1 (\a -> ArgMax (f a) a) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13572 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13572: Add ArgMin / ArgMax pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by Iceland_jack: @@ -20,1 +20,1 @@ - pattern ArgMax [maxArg, maxValue} = Max (Arg maxArg maxValue) + pattern ArgMax {maxArg, maxValue} = Max (Arg maxArg maxValue) New description: {{{#!hs import Data.Semigroup pattern ArgMin :: a -> b -> ArgMin a b pattern ArgMin a b = Min (Arg a b) pattern ArgMax :: a -> b -> ArgMax a b pattern ArgMax a b = Max (Arg a b) }}} Or even record pattern synonyms, à la [https://github.com/energyflowanalysis/efa-2.1/blob/3eb86c0b6b2d2fb66cd5b76ce... this] {{{#!hs 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) }}} and we can define {{{#!hs import Data.Semigroup.Foldable argmin :: Ord k => Foldable1 f => (a -> k) -> (f a -> a) argmin f = minValue . foldMap1 (\a -> ArgMin (f a) a) argmax :: Ord k => Foldable1 f => (a -> k) -> (f a -> a) argmax f = maxValue . foldMap1 (\a -> ArgMax (f a) a) }}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13572#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13572: Add ArgMin / ArgMax pattern synonyms -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * cc: core-libraries-committee@… (added) Comment: Where are you suggesting these are added? I think this should really go through the usual [[https://wiki.haskell.org/Core_Libraries_Committee|libraries process]]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13572#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC