Using GADT's to maintain invariant in GHC libraries
compiler/utils/OrdList.lhs using a GADT to preserve some invariants stated only in comments — an excellent chance for
ghc to eat its own proverbial dog food I feel :)
The type signatures remain the same so it should be a drop-in replacement but it does use some GHC features that are too recent (closed type families in particular, the
IsList instance can be removed) making it ineligible for inclusion I believe.
#ghc suggested that I submit a patch anyway and that it could be implemented at a later date (they said
ghc must be able to be compiled by the last two previous major versions), if this is useful then I will translate
Bag.hls which has the same invariants but more complicated functions.