GHC: Ticket #8782: Using GADT's to maintain invariant in GHC libraries
http://ghc.haskell.org/trac/ghc/ticket/8782
<p>
I rewrote <tt>compiler/utils/OrdList.lhs</tt> using a GADT to preserve some invariants stated only in comments — an excellent chance for <tt>ghc</tt> to eat its own proverbial dog food I feel :)
</p>
<p>
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 <tt>IsList</tt> instance can be removed) making it ineligible for inclusion I believe.
</p>
<p>
hvr on <tt>#ghc</tt> suggested that I submit a patch anyway and that it could be implemented at a later date (they said <tt>ghc</tt> must be able to be compiled by the last two previous major versions), if this is useful then I will translate <tt>Bag.hls</tt> which has the same invariants but more complicated functions.
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/8782
Trac 1.0.9Iceland_jackThu, 13 Feb 2014 13:35:19 GMTattachment set
http://ghc.haskell.org/trac/ghc/ticket/8782
http://ghc.haskell.org/trac/ghc/ticket/8782
<ul>
<li><strong>attachment</strong>
set to <em>OrdList.lhs</em>
</li>
</ul>
<p>
Rewritten version of ./compiler/utils/OrdList.lhs
</p>
TicketIceland_jackThu, 13 Feb 2014 13:37:11 GMTstatus changed
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:1
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:1
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>patch</em>
</li>
</ul>
TicketgoldfireThu, 13 Feb 2014 15:00:43 GMT
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:2
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:2
<p>
Yay! I've been wanting to do this sort of thing for some time, but always had more pressing things on my plate.
</p>
<p>
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.)
</p>
<p>
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.
</p>
TicketthoughtpoliceTue, 19 Aug 2014 12:28:14 GMTstatus changed; milestone set
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:3
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:3
<ul>
<li><strong>status</strong>
changed from <em>patch</em> to <em>infoneeded</em>
</li>
<li><strong>milestone</strong>
set to <em>7.10.1</em>
</li>
</ul>
<p>
Iceland_Jack, now that HEAD requires 7.6 to bootstrap (<a class="changeset" href="http://ghc.haskell.org/trac/ghc/changeset/527bcc41630918977c73584d99125ff164400695/ghc" title="build: require GHC 7.6 for bootstrapping
Summary:
Per the usual ...">527bcc41630918977c73584d99125ff164400695</a>), 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 <tt>git</tt> format (Note you'll also need some minor changes like instances, see <a class="changeset" href="http://ghc.haskell.org/trac/ghc/changeset/93b1a43ebe8bf145b35e903966d4a62b7847f213/ghc" title="Add Output instance for OrdList">93b1a43ebe8bf145b35e903966d4a62b7847f213</a>)? That would be great.
</p>
TicketIceland_jackThu, 21 Aug 2014 08:46:35 GMTattachment set
http://ghc.haskell.org/trac/ghc/ticket/8782
http://ghc.haskell.org/trac/ghc/ticket/8782
<ul>
<li><strong>attachment</strong>
set to <em>0001-Updated-implementation-of-OrdList-8751.patch</em>
</li>
</ul>
TicketIceland_jackThu, 21 Aug 2014 08:52:14 GMT
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:4
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:4
<p>
I removed some exported functions like <tt>mapOL</tt> (that only appears in a comment) and <tt>foldrOL</tt> and <tt>foldlOL</tt> (replacing occurrences with <tt>Data.Foldable.foldr</tt> and <tt>Data.Foldable.foldl</tt>.
</p>
<p>
Other functions like (<tt>concatOL</tt>, <tt>appOL</tt>, <tt>fromOL</tt>, ...) could as well be dropped in favour of the <tt>Monoid</tt> and <tt>IsList</tt> methods in the future, but they are used substantially more than the ones I replaced so I decided against it.
</p>
TicketrwbartonFri, 22 Aug 2014 14:00:29 GMT
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:5
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:5
<p>
Can we keep <tt>foldlOL</tt> and <tt>foldrOL</tt>? The GHC source tends to prefer monomorphic functions over polymorphic ones when the polymorphism is not needed. (See for example Simon's email <a class="ext-link" href="http://www.haskell.org/pipermail/ghc-devs/2014-August/006081.html"><span class="icon"></span>here</a>.)
</p>
TicketthomieWed, 24 Sep 2014 14:53:38 GMTstatus changed
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:6
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:6
<ul>
<li><strong>status</strong>
changed from <em>infoneeded</em> to <em>patch</em>
</li>
</ul>
TicketthoughtpoliceWed, 19 Nov 2014 23:26:50 GMTstatus changed
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:7
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:7
<ul>
<li><strong>status</strong>
changed from <em>patch</em> to <em>infoneeded</em>
</li>
</ul>
<p>
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.
</p>
TicketthoughtpoliceWed, 19 Nov 2014 23:31:29 GMTstatus changed
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:8
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:8
<ul>
<li><strong>status</strong>
changed from <em>infoneeded</em> to <em>new</em>
</li>
</ul>
TicketIceland_jackMon, 24 Nov 2014 09:30:19 GMT
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:9
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:9
<p>
No problem, I'm busy at the moment but I'll sort it out in good time.
</p>
TicketthoughtpoliceTue, 23 Dec 2014 13:33:22 GMTmilestone changed
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:10
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:10
<ul>
<li><strong>milestone</strong>
changed from <em>7.10.1</em> to <em>7.12.1</em>
</li>
</ul>
<p>
Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.
</p>
TicketthoughtpoliceTue, 23 Dec 2014 13:33:22 GMT
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:11
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:11
<p>
Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.
</p>
TicketthoughtpoliceFri, 11 Sep 2015 08:38:26 GMTmilestone changed
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:12
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:12
<ul>
<li><strong>milestone</strong>
changed from <em>7.12.1</em> to <em>8.0.1</em>
</li>
</ul>
<p>
Milestone renamed
</p>
TicketthomieFri, 22 Jan 2016 10:23:05 GMTowner set
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:13
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:13
<ul>
<li><strong>owner</strong>
set to <em>Iceland_jack</em>
</li>
</ul>
<p>
Iceland_jack: what is the status?
</p>
TicketthomieSun, 24 Jan 2016 18:07:53 GMTmilestone deleted
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:14
http://ghc.haskell.org/trac/ghc/ticket/8782#comment:14
<ul>
<li><strong>milestone</strong>
<em>8.0.1</em> deleted
</li>
</ul>
Ticket