• Ryan Scott's avatar
    Use NonEmpty lists to represent lists of duplicate elements · 7d699782
    Ryan Scott authored
    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
    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
TcErrors.hs 123 KB