#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 <ryan.gl.scott@…>): In [changeset:"7d699782bf6148c115a49b5f31ada9bd7c32a7d6/ghc" 7d69978/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="7d699782bf6148c115a49b5f31ada9bd7c32a7d6" Use NonEmpty lists to represent lists of duplicate elements Summary: Three functions in `ListSetOps` which compute duplicate elements represent lists of duplicates of `[a]`. This is a really bad way to go about things, because these lists are guaranteed to always have at least one element (the "representative" of the duplicates), and several places in the GHC API call `head` (a partial function) on these lists of duplicates to retrieve the representative. This changes the representation of duplicates to `NonEmpty` lists instead, which allow for many partial uses of `head` to be made total. Fixes #13823. Test Plan: ./validate Reviewers: bgamari, austin, goldfire Reviewed By: bgamari Subscribers: goldfire, rwbarton, thomie GHC Trac Issues: #13823 Differential Revision: https://phabricator.haskell.org/D3823 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13823#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler