<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Kan Extensions III: As Ends and Coends</title>
	<atom:link href="http://comonad.com/reader/2008/kan-extension-iii/feed/" rel="self" type="application/rss+xml" />
	<link>http://comonad.com/reader/2008/kan-extension-iii/</link>
	<description>types, (co)monads, substructural logic</description>
	<lastBuildDate>Sun, 24 Jan 2010 18:33:30 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Edward Kmett</title>
		<link>http://comonad.com/reader/2008/kan-extension-iii/comment-page-1/#comment-12490</link>
		<dc:creator>Edward Kmett</dc:creator>
		<pubDate>Sun, 18 Oct 2009 21:35:55 +0000</pubDate>
		<guid isPermaLink="false">http://comonad.com/reader/2008/kan-extension-iii/#comment-12490</guid>
		<description>Wren: Fixed!</description>
		<content:encoded><![CDATA[<p>Wren: Fixed!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wren ng thornton</title>
		<link>http://comonad.com/reader/2008/kan-extension-iii/comment-page-1/#comment-12474</link>
		<dc:creator>wren ng thornton</dc:creator>
		<pubDate>Sun, 18 Oct 2009 04:15:21 +0000</pubDate>
		<guid isPermaLink="false">http://comonad.com/reader/2008/kan-extension-iii/#comment-12474</guid>
		<description>Just a minor typo note:

&gt; newtype RanT f g c m m&#039; = (c -&gt; K m) -&gt; T m&#039;

Should be:

&gt; newtype RanT k t c m m&#039; = (c -&gt; k m) -&gt; t m&#039;

right?</description>
		<content:encoded><![CDATA[<p>Just a minor typo note:</p>
<p>&gt; newtype RanT f g c m m&#8217; = (c -&gt; K m) -&gt; T m&#8217;</p>
<p>Should be:</p>
<p>&gt; newtype RanT k t c m m&#8217; = (c -&gt; k m) -&gt; t m&#8217;</p>
<p>right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sigfpe</title>
		<link>http://comonad.com/reader/2008/kan-extension-iii/comment-page-1/#comment-6418</link>
		<dc:creator>sigfpe</dc:creator>
		<pubDate>Thu, 26 Feb 2009 05:29:19 +0000</pubDate>
		<guid isPermaLink="false">http://comonad.com/reader/2008/kan-extension-iii/#comment-6418</guid>
		<description>All of the various types of naturality (including dinaturality and extranaturality) seem to arise as free theorems but I&#039;ve not seen a paper spelling this out clearly - at least not in a form I&#039;d recognise. I can&#039;t tell if it&#039;s because nobody has figured it the details, or if the papers are just over my head.</description>
		<content:encoded><![CDATA[<p>All of the various types of naturality (including dinaturality and extranaturality) seem to arise as free theorems but I&#8217;ve not seen a paper spelling this out clearly &#8211; at least not in a form I&#8217;d recognise. I can&#8217;t tell if it&#8217;s because nobody has figured it the details, or if the papers are just over my head.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edward Kmett</title>
		<link>http://comonad.com/reader/2008/kan-extension-iii/comment-page-1/#comment-6414</link>
		<dc:creator>Edward Kmett</dc:creator>
		<pubDate>Thu, 26 Feb 2009 02:02:48 +0000</pubDate>
		<guid isPermaLink="false">http://comonad.com/reader/2008/kan-extension-iii/#comment-6414</guid>
		<description>Hey Dan,

Fixed the LanT definition. (Woops!) 

Re the dinatural transformation piece, I&#039;m not as deep as I used to be in this area, so I&#039;ll go back and see what I can dig up from whatever notes I still have from when I wrote this. I recall it seeming quite obvious at the time, but now I can only barely remember what dinaturality is. :) I&#039;d be quite surprised (and pleased) if you came up with a counterexample, however. ;)</description>
		<content:encoded><![CDATA[<p>Hey Dan,</p>
<p>Fixed the LanT definition. (Woops!) </p>
<p>Re the dinatural transformation piece, I&#8217;m not as deep as I used to be in this area, so I&#8217;ll go back and see what I can dig up from whatever notes I still have from when I wrote this. I recall it seeming quite obvious at the time, but now I can only barely remember what dinaturality is. :) I&#8217;d be quite surprised (and pleased) if you came up with a counterexample, however. ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan P</title>
		<link>http://comonad.com/reader/2008/kan-extension-iii/comment-page-1/#comment-6412</link>
		<dc:creator>Dan P</dc:creator>
		<pubDate>Thu, 26 Feb 2009 00:45:15 +0000</pubDate>
		<guid isPermaLink="false">http://comonad.com/reader/2008/kan-extension-iii/#comment-6412</guid>
		<description>Now that I&#039;ve been thinking about these things I can point out a tiny tiny typo:

data LanT k t c m m&#039; = LanT (k m -&gt; c) (t m)

should probably be

data LanT k t c m m&#039; = LanT (k m -&gt; c) (t m&#039;)

though it makes no difference in the definition of Lan.

On a less trivial level, I still don&#039;t know what theorem I could quote to justify that, say,

type DinaturalFromObject x s = x -&gt; forall a. s a a

defines dinaturals from a constant functor. For a specific choice of s dinaturality is a free theorem. But how do you uniformly prove this for all s, implemented in Haskell, with the right c/contravariance in the arguments?</description>
		<content:encoded><![CDATA[<p>Now that I&#8217;ve been thinking about these things I can point out a tiny tiny typo:</p>
<p>data LanT k t c m m&#8217; = LanT (k m -&gt; c) (t m)</p>
<p>should probably be</p>
<p>data LanT k t c m m&#8217; = LanT (k m -&gt; c) (t m&#8217;)</p>
<p>though it makes no difference in the definition of Lan.</p>
<p>On a less trivial level, I still don&#8217;t know what theorem I could quote to justify that, say,</p>
<p>type DinaturalFromObject x s = x -&gt; forall a. s a a</p>
<p>defines dinaturals from a constant functor. For a specific choice of s dinaturality is a free theorem. But how do you uniformly prove this for all s, implemented in Haskell, with the right c/contravariance in the arguments?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edward Kmett</title>
		<link>http://comonad.com/reader/2008/kan-extension-iii/comment-page-1/#comment-1685</link>
		<dc:creator>Edward Kmett</dc:creator>
		<pubDate>Sat, 14 Jun 2008 13:16:50 +0000</pubDate>
		<guid isPermaLink="false">http://comonad.com/reader/2008/kan-extension-iii/#comment-1685</guid>
		<description>Well, you can look at the Codensity monad (Ran m m) of a monad m as a weaker form of ContT which isn&#039;t allowed to use the type of the ultimate return value to &#039;pull any tricks&#039;. Consequently, it has fewer inhabitants than ContT and we can say more about them. My favorite example so far is in:

http://wwwtcs.inf.tu-dresden.de/~voigt/mpc08.pdf

That paper shows that you can substitute a reference to the Codensity monad of a free monad in many places where you&#039;d use the original free monad and change the asymptotic performance of the resulting algorithm because the continuation &#039;linearizes&#039; the cost of repeatedly traversing the tree by piling the cost up in the continuation so you only traverse once.

I&#039;d conjecture that the left Kan extension of a cofree comonad should let us pile up the cost of mapping or extending cofree comonads similarly. Though here I have yet to actually generate any performance results here due to other distractions.

We _can_ however definitely do the same thing with the Yoneda and Coyoneda lemmas. The resulting (co)monads fit very closely to the operational characteristics of the base monad. 

If you transform a monad with Yoneda you get a monad that has the same overall costs for return and &gt;&gt;=, but where if your monad had a non constant cost for map (such as in the free monad of anything other than the trivial functor that maps everything to _&#124;_), you can fuse the costs of all of your maps together by accumulating them and applying them all at once during the next (&gt;&gt;=) (or when you extract f from the Yoneda f). 

Similarly CoYoneda accumulates maps for comonads, which is a win if map is expensive (such as in the cofree comonad case).

You can get a feel for why this works by looking at:

http://comonad.com/haskell/category-extras/src/Control/Functor/Yoneda.hs

and noting what fmap does and how &gt;&gt;= works for Yoneda. and how fmap and extend work for CoYoneda.

In category-extras I have generalized all of the constructive algorithmic morphisms that use the free monad or cofree comonad (histomorphisms, futumorphisms, dynamorphisms, chronomorphisms) to support the codensity monad of the free monad, density comonad of the cofree comonad, Yoneda of the free monad, Coyoneda of the cofree comonad, etc by defining a couple of extra typeclasses that express their &#039;Free-Like&#039; behavior in the spirit of the above linked paper by Voigtlaender in 

http://comonad.com/haskell/category-extras/src/Control/Monad/Free.hs

The generalization can be seen in use here:

http://comonad.com/haskell/category-extras/src/Control/Morphism/Futu.hs

and the instances for Codensity here:

http://comonad.com/haskell/category-extras/src/Control/Monad/Codensity.hs</description>
		<content:encoded><![CDATA[<p>Well, you can look at the Codensity monad (Ran m m) of a monad m as a weaker form of ContT which isn&#8217;t allowed to use the type of the ultimate return value to &#8216;pull any tricks&#8217;. Consequently, it has fewer inhabitants than ContT and we can say more about them. My favorite example so far is in:</p>
<p><a href="http://wwwtcs.inf.tu-dresden.de/~voigt/mpc08.pdf" rel="nofollow">http://wwwtcs.inf.tu-dresden.de/~voigt/mpc08.pdf</a></p>
<p>That paper shows that you can substitute a reference to the Codensity monad of a free monad in many places where you&#8217;d use the original free monad and change the asymptotic performance of the resulting algorithm because the continuation &#8216;linearizes&#8217; the cost of repeatedly traversing the tree by piling the cost up in the continuation so you only traverse once.</p>
<p>I&#8217;d conjecture that the left Kan extension of a cofree comonad should let us pile up the cost of mapping or extending cofree comonads similarly. Though here I have yet to actually generate any performance results here due to other distractions.</p>
<p>We _can_ however definitely do the same thing with the Yoneda and Coyoneda lemmas. The resulting (co)monads fit very closely to the operational characteristics of the base monad. </p>
<p>If you transform a monad with Yoneda you get a monad that has the same overall costs for return and >>=, but where if your monad had a non constant cost for map (such as in the free monad of anything other than the trivial functor that maps everything to _|_), you can fuse the costs of all of your maps together by accumulating them and applying them all at once during the next (>>=) (or when you extract f from the Yoneda f). </p>
<p>Similarly CoYoneda accumulates maps for comonads, which is a win if map is expensive (such as in the cofree comonad case).</p>
<p>You can get a feel for why this works by looking at:</p>
<p><a href="http://comonad.com/haskell/category-extras/src/Control/Functor/Yoneda.hs" rel="nofollow">http://comonad.com/haskell/category-extras/src/Control/Functor/Yoneda.hs</a></p>
<p>and noting what fmap does and how >>= works for Yoneda. and how fmap and extend work for CoYoneda.</p>
<p>In category-extras I have generalized all of the constructive algorithmic morphisms that use the free monad or cofree comonad (histomorphisms, futumorphisms, dynamorphisms, chronomorphisms) to support the codensity monad of the free monad, density comonad of the cofree comonad, Yoneda of the free monad, Coyoneda of the cofree comonad, etc by defining a couple of extra typeclasses that express their &#8216;Free-Like&#8217; behavior in the spirit of the above linked paper by Voigtlaender in </p>
<p><a href="http://comonad.com/haskell/category-extras/src/Control/Monad/Free.hs" rel="nofollow">http://comonad.com/haskell/category-extras/src/Control/Monad/Free.hs</a></p>
<p>The generalization can be seen in use here:</p>
<p><a href="http://comonad.com/haskell/category-extras/src/Control/Morphism/Futu.hs" rel="nofollow">http://comonad.com/haskell/category-extras/src/Control/Morphism/Futu.hs</a></p>
<p>and the instances for Codensity here:</p>
<p><a href="http://comonad.com/haskell/category-extras/src/Control/Monad/Codensity.hs" rel="nofollow">http://comonad.com/haskell/category-extras/src/Control/Monad/Codensity.hs</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Grant B</title>
		<link>http://comonad.com/reader/2008/kan-extension-iii/comment-page-1/#comment-1682</link>
		<dc:creator>Grant B</dc:creator>
		<pubDate>Fri, 13 Jun 2008 22:41:48 +0000</pubDate>
		<guid isPermaLink="false">http://comonad.com/reader/2008/kan-extension-iii/#comment-1682</guid>
		<description>I&#039;m curious as to how you would motivate Kan extensions as a functional programming (specifically Haskell) tool.  The right Kan extension almost looks like the CPS-transform of &quot;a&quot;, except with variant answer types.  Shan&#039;s &lt;a href=&quot;http://www.cs.rutgers.edu/~ccshan/dissertation/book.pdf&quot; rel=&quot;nofollow&quot;&gt;thesis&lt;/a&gt; on page 73 shows how the ordinary function type is modified via the presence of delimited control into something like a right Kan extension.

Care to shed some light on this (and its dual)?</description>
		<content:encoded><![CDATA[<p>I&#8217;m curious as to how you would motivate Kan extensions as a functional programming (specifically Haskell) tool.  The right Kan extension almost looks like the CPS-transform of &#8220;a&#8221;, except with variant answer types.  Shan&#8217;s <a href="http://www.cs.rutgers.edu/~ccshan/dissertation/book.pdf" rel="nofollow">thesis</a> on page 73 shows how the ordinary function type is modified via the presence of delimited control into something like a right Kan extension.</p>
<p>Care to shed some light on this (and its dual)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan P</title>
		<link>http://comonad.com/reader/2008/kan-extension-iii/comment-page-1/#comment-1489</link>
		<dc:creator>Dan P</dc:creator>
		<pubDate>Tue, 27 May 2008 20:45:21 +0000</pubDate>
		<guid isPermaLink="false">http://comonad.com/reader/2008/kan-extension-iii/#comment-1489</guid>
		<description>Hey! Stop writing posts faster than I can read them :-)</description>
		<content:encoded><![CDATA[<p>Hey! Stop writing posts faster than I can read them :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Grant B.</title>
		<link>http://comonad.com/reader/2008/kan-extension-iii/comment-page-1/#comment-1481</link>
		<dc:creator>Grant B.</dc:creator>
		<pubDate>Tue, 27 May 2008 10:27:22 +0000</pubDate>
		<guid isPermaLink="false">http://comonad.com/reader/2008/kan-extension-iii/#comment-1481</guid>
		<description>Awesome! This helped my understanding a lot, thanks.</description>
		<content:encoded><![CDATA[<p>Awesome! This helped my understanding a lot, thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
