[GHC] #13823: Use NonEmpty lists in more places in the GHC API

#13823: Use NonEmpty lists in more places in the GHC API -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #8782 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- After GHC 8.2 is released and we drop support for building GHC with 7.10, we should try to use `Data.List.NonEmpty` in more places in the GHC API. I ran into this issue recently when using some functions from `ListSetOps`: {{{#!hs removeDups :: (a -> a -> Ordering) -> [a] -> ([a], [[a]]) findDupsEq :: (a -> a -> Bool) -> [a] -> [[a]] equivClasses :: (a -> a -> Ordering) -> [a] -> [[a]] }}} These type signatures are terrible. Really, they should be: {{{#!hs removeDups :: (a -> a -> Ordering) -> [a] -> ([a], [NonEmpty a]) findDupsEq :: (a -> a -> Bool) -> [a] -> [NonEmpty a] equivClasses :: (a -> a -> Ordering) -> [a] -> [NonEmpty a] }}} Since 90% of the time, the first thing you do after finding duplicates is to take a representative from the duplicate set. With lists, this requires the partial operation `head`, but with `NonEmpty`, this can be total like it was intended to be. I'm sure there are other places in the API that could benefit from `NonEmpty`, so if you have any suggestions, please leave them here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13823 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13823: Use NonEmpty lists in more places in the GHC API -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: RyanGlScott Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #8782 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * owner: (none) => RyanGlScott -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13823#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13823: Use NonEmpty lists in more places in the GHC API -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: RyanGlScott Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #8782 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): I've never found using `NonEmpty` to be worthwhile with Haskell's type system and in general I think we should be looking to remove `ListSetOps` rather than spending time making the API better. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13823#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13823: Use NonEmpty lists in more places in the GHC API -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: RyanGlScott Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #8782 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Well, I'm looking to avoid partially retrieving the representative of a list of duplicates, by hook or by crook. Do you have an idea in mind for a better `ListSetOps` replacement? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13823#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13823: Use NonEmpty lists in more places in the GHC API -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: RyanGlScott Type: task | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #8782 | Differential Rev(s): Phab:D3823 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3823 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13823#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13823: Use NonEmpty lists in more places in the GHC API
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: RyanGlScott
Type: task | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #8782 | Differential Rev(s): Phab:D3823
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#13823: Use NonEmpty lists in more places in the GHC API -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: RyanGlScott Type: task | Status: closed Priority: normal | Milestone: 8.4.1 Component: Compiler | Version: 8.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #8782 | Differential Rev(s): Phab:D3823 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: patch => closed * resolution: => fixed * milestone: => 8.4.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13823#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC