
#9330: Introduce shortcut for "on (==)" much like there's a shortcut for "on compare". -------------------------------------+------------------------------------- Reporter: frerich | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 7.8.2 Keywords: | Differential Revisions: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: -------------------------------------+------------------------------------- A common use case for `on` (from `Data.Function`) is to use it with `compare`, e.g. {{{compare `on` snd}}}. In fact, this pattern is so common that there's a convenient `comparing` function which provides a shortcut for this use case such that one can write {{{ #!haskell sortBy (comparing snd) }}} instead of {{{ #!haskell sortBy (compare `on` snd) }}} I think another common use case is to use `on` together with `(==)` as in {{{ #!haskell groupBy ((==) `on` snd) }}} In a similiar vein as with `comparing`, I think it would be nice if there was a function which encapsulates this use case, like {{{ #!haskell equating :: Eq b => (a -> b) -> a -> a -> Bool equating = on (==) }}} such that one can write {{{ #!haskell groupBy (equating snd) }}} The (IMHO fairly nice) name `equating` is not my idea but was suggested by //ClaudiusMaximus// of #haskell fame. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9330 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler