Whoosh? :-)<br><br><div class="gmail_quote">On Sun, Apr 1, 2012 at 3:54 PM, Greg Weber <span dir="ltr">&lt;<a href="mailto:greg@gregweber.info">greg@gregweber.info</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Gershom,<br>
<br>
This sounds very interesting even if I have no idea what you are<br>
talking about :)<br>
Please create a proposal linked from this page:<br>
<a href="http://hackage.haskell.org/trac/ghc/wiki/Records" target="_blank">http://hackage.haskell.org/trac/ghc/wiki/Records</a><br>
The first thing you should probably do is explain the programmer&#39;s<br>
point of view. That ensures that we are all going through the<br>
requirements phase correctly.<br>
I can assure you that haskell prime would not accept a records change<br>
until it is first implemented in GHC or another Haskell compiler.<br>
<br>
Thanks,<br>
Greg Weber<br>
<div><div class="h5"><br>
On Sat, Mar 31, 2012 at 11:14 PM, Gershom B &lt;<a href="mailto:gershomb@gmail.com">gershomb@gmail.com</a>&gt; wrote:<br>
&gt; The records discussion has been really complicated and confusing. But<br>
&gt; I have a suggestion that should provide a great deal of power to<br>
&gt; records, while being mostly[1] backwards-compatible with Haskell 2010.<br>
&gt; Consider this example:<br>
&gt;<br>
&gt;    data A a = A{a:a, aa::a, aaa :: a -&gt; A (a -&gt; a)}<br>
&gt;    data B a = B{aaa :: a -&gt; A (a -&gt; a), a :: A}<br>
&gt;<br>
&gt; Now what is the type of this?<br>
&gt;<br>
&gt;    aaaa aaaaa a aa = aaaaa{a = a, aaa = aa}<br>
&gt;<br>
&gt; Using standard Haskell typeclasses this is a difficult question to<br>
&gt; answer. The types of aaaa for A and B do not unify in an obvious way.<br>
&gt; However, while they are intensionally quite distinct, they unify<br>
&gt; trivially extensionally. The obvious thing to do is then to extend the<br>
&gt; type system with extensional equality on record functions.<br>
&gt;<br>
&gt; Back when Haskell was invented, extensional equality was thought to be<br>
&gt; hard. But purity was thought to be hard too, and so were Monads. Now,<br>
&gt; we know that function existentionality is easy. In fact, if we add the<br>
&gt; Univalence Axiom to GHC[2], then this is enough to get function<br>
&gt; existensionality. This is a well-known result of Homotopy Type<br>
&gt; Theory[3], which is a well-explored approach that has existed for at<br>
&gt; least a few years and produced more than one paper[4]. Homotopy Type<br>
&gt; Theory is so sound and well understood that it has even been<br>
&gt; formalized in Coq.<br>
&gt;<br>
&gt; Once we extend GHC with homotopies, it turns out that records reduce<br>
&gt; to mere syntactic sugar, and there is a natural proof of their<br>
&gt; soundness (Appendix A). Furthermore, there is a canonical projection<br>
&gt; for any group of fields (Appendix B). Even better, we can make &quot;.&quot;<br>
&gt; into the identity path operator, unifying its uses in composition and<br>
&gt; projection. In fact, with extended (parenthesis-free) section rules,<br>
&gt; &quot;.&quot; can also be used to terminate expressions, making Haskell friendly<br>
&gt; not only to programmers coming from Java, but also to those coming<br>
&gt; from Prolog!<br>
&gt;<br>
&gt; After some initial feedback, I&#39;m going to create a page for the<br>
&gt; Homotopy Extensional Records Proposal (HERP) on trac. There are really<br>
&gt; only a few remaining questions. 1) Having introduced homotopies, why<br>
&gt; not go all the way and introduce dependent records? In fact, are HERP<br>
&gt; and Dependent Extensional Records Proposal (DERP) already isomorphic?<br>
&gt; My suspicion is that HERP is isomorphic, but DERP is not. However, I<br>
&gt; can only get away with my proof using Scott-free semantics. 2) Which<br>
&gt; trac should I post this too? Given how well understood homotopy type<br>
&gt; theory is, I&#39;m tempted to bypass GHC entirely and propose this for<br>
&gt; haskell-prime. 3) What syntax should we use to represent homotopies?<br>
&gt; See extend discussion in Appendix C.<br>
&gt;<br>
&gt; HTH HAND,<br>
&gt; Gershom<br>
&gt;<br>
&gt; [1] To be precise, 100% of Haskell 2010 programs should, usually, be<br>
&gt; able to be rewritten to work with this proposal with a minimal set of<br>
&gt; changes[1a].<br>
&gt;<br>
&gt; [1a] A minimal set of changes is defined as the smallest set of<br>
&gt; changes necessary to make to a Haskell 2010 program such that it works<br>
&gt; with this proposal. We can arrive at these changes by the following<br>
&gt; procedure: 1) Pick a change[1b]. 2) Is it minimal? If so keep it. 3)<br>
&gt; are we done? If not, make another change.<br>
&gt;<br>
&gt; [1b] To do this constructively, we need an order. I suggest the lo<br>
&gt; mein, since noodles give rise to a free soda.<br>
&gt;<br>
&gt; [2] I haven&#39;t looked at the source, but I would suggest putting it in<br>
&gt; the file Axioms.hs.<br>
&gt;<br>
&gt; [3] <a href="http://homotopytypetheory.org/" target="_blank">http://homotopytypetheory.org/</a><br>
&gt;<br>
&gt; [4] <a href="http://arxiv.org/" target="_blank">http://arxiv.org/</a><br>
&gt;<br>
&gt;<br>
&gt; *Appendix A: A Natural Proof of the Soundness of HERP<br>
&gt;<br>
&gt; Take the category of all types in HERP, with functions as morphisms.<br>
&gt; Call it C. Take the category of all sound expressions in HERP, with<br>
&gt; functions as morphisms. Call it D. Define a full functor from C to D.<br>
&gt; Call it F. Define a faithful functor on C and D. Call it G. Draw the<br>
&gt; following diagram.<br>
&gt;<br>
&gt; F(X)----F(Y)<br>
&gt; |          |<br>
&gt; |          |<br>
&gt; |          |<br>
&gt; G(X)----G(Y)<br>
&gt;<br>
&gt; Define the arrows such that everything commutes.<br>
&gt;<br>
&gt;<br>
&gt; *Appendix B: Construction of a Canonical Projection for Any Group of Fields.<br>
&gt;<br>
&gt; 1) Take the fields along the homotopy to an n-ball.<br>
&gt; 2) Pack them loosely with newspaper and gunpowder.<br>
&gt; 3) Project them from a cannon.<br>
&gt;<br>
&gt; In an intuitionistic logic, the following simplification is possible:<br>
&gt;<br>
&gt; 1) Use your intuition.<br>
&gt;<br>
&gt;<br>
&gt; *Appendix C: Homotopy Syntax<br>
&gt;<br>
&gt; Given that we already are using the full unicode set, what syntax<br>
&gt; should we use to distinguish paths and homotopies? At first, I thought<br>
&gt; we could avoid providing any syntax for homotopies at all. Haskell is<br>
&gt; a language with type inference, so we should just be able to infer<br>
&gt; paths and homotopies behind the scenes by adding homotopies to the<br>
&gt; type system. That&#39;s a very nice answer in theory. But in the real<br>
&gt; world, when we&#39;re writing code that solves actual problems,<br>
&gt; theoretical niceties break down. What if a user wants to use a<br>
&gt; nonstandard homotopy?<br>
&gt;<br>
&gt; Why should we stop them just because we&#39;re too lazy to come up with a<br>
&gt; good syntax? I then realized that we keep running out of syntax<br>
&gt; because we&#39;ve limited ourselves to unicode. Instead, I propose we add<br>
&gt; a potentially infinite universe of identifiers: youtube videos. For<br>
&gt; example, the higher inductive type for a circle can be written as:<br>
&gt;<br>
&gt; homotopyType <a href="http://www.youtube.com/watch?v=dQw4w9WgXcQ" target="_blank">http://www.youtube.com/watch?v=dQw4w9WgXcQ</a> where<br>
&gt;    Base ::: <a href="http://www.youtube.com/watch?v=dQw4w9WgXcQ" target="_blank">http://www.youtube.com/watch?v=dQw4w9WgXcQ</a><br>
&gt;    Loop ::: <a href="http://www.youtube.com/watch?v=J---aiyznGQ" target="_blank">http://www.youtube.com/watch?v=J---aiyznGQ</a> Base Base<br>
&gt;<br>
&gt; Note that the urls do not use SSL. For portability reasons, I propose<br>
&gt; that SSL only be enabled as an optional extension.<br>
&gt;<br>
&gt; _______________________________________________<br>
</div></div>&gt; Glasgow-haskell-users mailing list<br>
&gt; <a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Gregory Collins &lt;<a href="mailto:greg@gregorycollins.net" target="_blank">greg@gregorycollins.net</a>&gt;<br>