On Sun, Jun 27, 2010 at 6:45 PM, Max Bolingbroke <span dir="ltr">&lt;<a href="mailto:batterseapower@hotmail.com">batterseapower@hotmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 27 June 2010 22:20, Edward Kmett &lt;<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>&gt; wrote:<br>
&gt; I&#39;ve pointed out the Codensity Set monad on the Haskell channel.<br>
<br>
</div>I spend no time on #haskell but clearly I should :)<br>
<div class="im"><br>
&gt; It is an<br>
&gt; interesting novelty, but it unfortunately has somewhat funny semantics in<br>
&gt; that the intermediate sets that you obtain are based on what you would get<br>
&gt; if you reparenthesized all of your binds and associating them to the right.<br>
<br>
</div>But by the monad laws this is a totally fine thing to do, so this<br>
shouldn&#39;t lead to any unfortunate behaviour in practice, I hope.</blockquote><div><br></div><div>Actually the resulting behavior _is_ rather unfortunate because it never collapses the contained values until you go through the &#39;normalization by evaluation&#39; phase and lower it back down. So even even if you only generate 2 elements at each step, (which are already present in the set!), and run the calculation for 100 operations or so you can take longer that the life expectancy of the universe to terminate. ;)</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">Can you cast any light on the connection with NBE? It seems like a</div>
deep and powerful connection, so I&#39;m sure it must correspond to some<br>
interesting categorical principal.<br></blockquote><div><br></div><div>You&#39;re looking at initial objects in various categories, effectively these are given rise to by colimits, and as initial objects, there exist morphisms from them to all other objects in their respective categories. The trick is learning to see the category you&#39;re asking for in the right terms.</div>
<div><br></div><div>For instance Mendler-style catamorphisms, can serve as the &quot;mother of all folds&quot;</div><div><span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 13px; line-height: 19px; "><blockquote>
<pre style="line-height: normal; ">type MendlerAlgebra f c = forall a. (a -&gt; c) -&gt; f a -&gt; c</pre></blockquote><blockquote><pre style="line-height: normal; ">mcata :: MendlerAlgebra f c -&gt; Mu f -&gt; c </pre><pre style="line-height: normal; ">
mcata phi = phi (mcata phi) . outF   </pre></blockquote></span></div><div><a href="http://knol.google.com/k/catamorphisms#">http://knol.google.com/k/catamorphisms#</a></div><div><br></div><div>and like many of these constructs in Haskell, is built around a Kan extension (or in this case, you can see it more directly as the contravariant Yoneda lemma in negative position). </div>
<div><br></div><div>-Edward Kmett</div></div>