[GHC] #9241: Add a"same" function to Data.Eq

#9241: Add a"same" function to Data.Eq ------------------------------------+------------------------------------- Reporter: mhwombat | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: Prelude | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- Add a"same" function to Data.Eq that parallels the "comparing" function in Data.Ord. For example: -- | -- > same p x y = (p x) == (p y) -- -- Useful combinator for use in conjunction with the @xxxBy@ family -- of functions from "Data.List", for example: -- -- > ... groupBy (same fst) ... same :: (Eq a) => (b -> a) -> b -> b -> Bool same p x y = (p x) == (p y) For a closer parallel, I suppose "same" could return "Equality" (similar to "Ordering"), and the functions "nubBy", "deleteBy", "deleteFirstsBy", "unionBy", "intersectBy" and "groupBy" should take (a -> a -> Equality) (a -> a -> Bool). But I don't know if there's any benefit to that. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9241 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9241: Add a"same" function to Data.Eq -------------------------------------+------------------------------------ Reporter: mhwombat | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: libraries/base | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by hvr): * cc: hvr, ekmett (added) * component: Prelude => libraries/base Old description:
Add a"same" function to Data.Eq that parallels the "comparing" function in Data.Ord. For example:
-- | -- > same p x y = (p x) == (p y) -- -- Useful combinator for use in conjunction with the @xxxBy@ family -- of functions from "Data.List", for example: -- -- > ... groupBy (same fst) ... same :: (Eq a) => (b -> a) -> b -> b -> Bool same p x y = (p x) == (p y)
For a closer parallel, I suppose "same" could return "Equality" (similar to "Ordering"), and the functions "nubBy", "deleteBy", "deleteFirstsBy", "unionBy", "intersectBy" and "groupBy" should take (a -> a -> Equality) (a -> a -> Bool). But I don't know if there's any benefit to that.
New description: Add a"same" function to Data.Eq that parallels the "comparing" function in Data.Ord. For example: {{{#!hs -- | -- > same p x y = (p x) == (p y) -- -- Useful combinator for use in conjunction with the @xxxBy@ family -- of functions from "Data.List", for example: -- -- > ... groupBy (same fst) ... same :: (Eq a) => (b -> a) -> b -> b -> Bool same p x y = (p x) == (p y) }}} For a closer parallel, I suppose "same" could return "Equality" (similar to "Ordering"), and the functions "nubBy", "deleteBy", "deleteFirstsBy", "unionBy", "intersectBy" and "groupBy" should take (a -> a -> Equality) (a -> a -> Bool). But I don't know if there's any benefit to that. -- Comment: What's the benefit of `same p` over {{{(==) `on` p}}}? {{{#!hs ((==) `on`) :: Eq b => (a -> b) -> a -> a -> Bool }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9241#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9241: Add a"same" function to Data.Eq -------------------------------------+------------------------------------ Reporter: mhwombat | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: libraries/base | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by rwbarton): Additions to base should go through the http://www.haskell.org/haskellwiki/Library_submissions process. Also, see #979 which suggests adding the same function under the name `equating`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9241#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9241: Add a"same" function to Data.Eq -------------------------------------+------------------------------------ Reporter: mhwombat | Owner: Type: feature request | Status: new Priority: low | Milestone: Component: libraries/base | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by ekmett): I agree that this should go through the libraries@ process. For the record I'm also on the `equating` bandwagon, but keep in mind `comparing` was created before `on` was discovered, so when this has come up for discussion before `comparing` was being left around as a historical artifact than as a model to copy. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9241#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9241: Add a"same" function to Data.Eq -------------------------------------+------------------------------------- Reporter: mhwombat | Owner: Type: feature | Status: closed request | Milestone: Priority: low | Version: 7.8.2 Component: | Keywords: libraries/base | Operating System: Unknown/Multiple Resolution: duplicate | Type of failure: None/Unknown Differential Revisions: | Test Case: Architecture: | Blocking: Unknown/Multiple | Difficulty: Unknown | Blocked By: | Related Tickets: | -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => duplicate Comment: Also see #9330 and http://www.haskell.org/pipermail/libraries/2014-July/023283.html. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9241#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC