GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2021-07-15T23:00:37Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/8782Using GADT's to maintain invariant in GHC libraries2021-07-15T23:00:37ZIcelandjackUsing GADT's to maintain invariant in GHC librariesI rewrote `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 d...I rewrote `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.
hvr on `#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.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.9 |
| Type | Task |
| TypeOfFailure | OtherFailure |
| Priority | lowest |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Using GADT's to maintain invariant in GHC libraries","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.9","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Task","description":"I rewrote `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 :)\r\n\r\nThe 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.\r\n\r\nhvr on `#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.","type_of_failure":"OtherFailure","blocking":[]} -->8.0.1IcelandjackIcelandjack