[GHC] #8782: Using GADT's to maintain invariant in GHC libraries

#8782: Using GADT's to maintain invariant in GHC libraries ------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: task | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 7.9 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------ Reporter: Iceland_jack | Owner: Type: task | Status: patch Priority: lowest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by Iceland_jack): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------ Reporter: Iceland_jack | Owner: Type: task | Status: patch Priority: lowest | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by goldfire): Yay! I've been wanting to do this sort of thing for some time, but always had more pressing things on my plate. Yes, we absolutely need to keep GHC compiling with the previous two major versions. BUT, I think at this point, that includes down to 7.4, which has !DataKinds. (I wouldn't use 7.4's !PolyKinds so much, but simple promoted datatypes worked well.) For something like closed type families, you could always keep your newfangled implemented in, but commented out, with a note to switch the implementations at a later date. The particular closed type family in your patch is easily written as an open one, so there's no need to delay the whole patch, I think. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: infoneeded Type: task | Milestone: 7.10.1 Priority: lowest | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: patch => infoneeded * milestone: => 7.10.1 Comment: Iceland_Jack, now that HEAD requires 7.6 to bootstrap (527bcc41630918977c73584d99125ff164400695), I think this change can go in as long as the patch is changed to use an actual open type family. Would you mind doing that, and also submitting the patch in `git` format (Note you'll also need some minor changes like instances, see 93b1a43ebe8bf145b35e903966d4a62b7847f213)? That would be great. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: infoneeded Type: task | Milestone: 7.10.1 Priority: lowest | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): I removed some exported functions like `mapOL` (that only appears in a comment) and `foldrOL` and `foldlOL` (replacing occurrences with `Data.Foldable.foldr` and `Data.Foldable.foldl`. Other functions like (`concatOL`, `appOL`, `fromOL`, ...) could as well be dropped in favour of the `Monoid` and `IsList` methods in the future, but they are used substantially more than the ones I replaced so I decided against it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: infoneeded Type: task | Milestone: 7.10.1 Priority: lowest | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by rwbarton): Can we keep `foldlOL` and `foldrOL`? The GHC source tends to prefer monomorphic functions over polymorphic ones when the polymorphism is not needed. (See for example Simon's email [http://www.haskell.org/pipermail /ghc-devs/2014-August/006081.html here].) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: patch Type: task | Milestone: 7.10.1 Priority: lowest | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * status: infoneeded => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: infoneeded Type: task | Milestone: 7.10.1 Priority: lowest | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: patch => infoneeded Comment: Hey Iceland_Jack, these patches fell out of date again. I'm very sorry for doing this once more. :( Let me know and pester the hell out of me if you're willing to rebase this again please. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: new Type: task | Milestone: 7.10.1 Priority: lowest | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: infoneeded => new -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------- Reporter: | Owner: Iceland_jack | Status: new Type: task | Milestone: 7.10.1 Priority: lowest | Version: 7.9 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): No problem, I'm busy at the moment but I'll sort it out in good time. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8782: Using GADT's to maintain invariant in GHC libraries -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Iceland_jack Type: task | Status: new Priority: lowest | Milestone: 8.0.1 Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * owner: => Iceland_jack Comment: Iceland_jack: what is the status? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8782#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC