<?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: Optimizing CCCs</title>
	<atom:link href="http://conal.net/blog/posts/optimizing-cccs/feed" rel="self" type="application/rss+xml" />
	<link>http://conal.net/blog/posts/optimizing-cccs</link>
	<description>Inspirations &#38; experiments, mainly about denotative/functional programming in Haskell</description>
	<lastBuildDate>Sat, 26 Sep 2020 21:06:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.17</generator>
	<item>
		<title>By: Conal Elliott &#187; Blog Archive &#187; Circuits as a bicartesian closed category</title>
		<link>http://conal.net/blog/posts/optimizing-cccs#comment-872</link>
		<dc:creator><![CDATA[Conal Elliott &#187; Blog Archive &#187; Circuits as a bicartesian closed category]]></dc:creator>
		<pubDate>Tue, 17 Sep 2013 20:27:21 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=537#comment-872</guid>
		<description><![CDATA[&lt;p&gt;[...] previous few posts have been about cartesian closed categories (CCCs). In From Haskell to hardware via cartesian [...]&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>[&#8230;] previous few posts have been about cartesian closed categories (CCCs). In From Haskell to hardware via cartesian [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: conal</title>
		<link>http://conal.net/blog/posts/optimizing-cccs#comment-871</link>
		<dc:creator><![CDATA[conal]]></dc:creator>
		<pubDate>Mon, 16 Sep 2013 18:45:03 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=537#comment-871</guid>
		<description><![CDATA[&lt;p&gt;Derek &amp; Dan: Thanks very much for the suggestions to eliminate &lt;code&gt;const&lt;/code&gt;, which felt shaky indeed!&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Derek &amp; Dan: Thanks very much for the suggestions to eliminate <code>const</code>, which felt shaky indeed!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Krejsa</title>
		<link>http://conal.net/blog/posts/optimizing-cccs#comment-870</link>
		<dc:creator><![CDATA[Dan Krejsa]]></dc:creator>
		<pubDate>Mon, 16 Sep 2013 03:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=537#comment-870</guid>
		<description><![CDATA[&lt;p&gt;A very slightly different take expanding a bit on Derek Elkin&#039;s comment.  Letting 1 (a.k.a. Unit) be the terminal object of the CCC, one can consider morphisms (1 ↣ b) as &quot;elements of b&quot; in some sense.  Then one can have a function corresponding to &#039;const&#039; applying to CCC morphisms:&lt;/p&gt;

&lt;p&gt;
&lt;pre&gt;&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const&quot; rel=&quot;nofollow&quot;&gt;const&lt;/a&gt; :: &#040;1 ↣ b&#041; -&gt; &#040;a ↣ b&#041;
&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const&quot; rel=&quot;nofollow&quot;&gt;const&lt;/a&gt; e = e ∘ it&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;where it :: a ↣ 1  is the unique morphism from a to 1.&lt;/p&gt;

&lt;p&gt;Now given CCC morphisms g :: b ↣ c  and f :: a ↣ b, we may view&lt;/p&gt;

&lt;p&gt;
&lt;pre&gt;g ∘ exr :: &#040;1 × b&#041; ↣ c&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;and let&lt;/p&gt;

&lt;p&gt;
&lt;pre&gt;g&#039; = &lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry&quot; rel=&quot;nofollow&quot;&gt;curry&lt;/a&gt; &#040;g ∘ exr&#041; :: 1 ↣ &#040;b ⇨ c&#041;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;Then&lt;/p&gt;

&lt;p&gt;
&lt;pre&gt;&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const&quot; rel=&quot;nofollow&quot;&gt;const&lt;/a&gt; g&#039; :: a ↣ &#040;b ⇨ c&#041;
&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const&quot; rel=&quot;nofollow&quot;&gt;const&lt;/a&gt; g&#039; = g&#039; ∘ it = &lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry&quot; rel=&quot;nofollow&quot;&gt;curry&lt;/a&gt; &#040;g ∘ exr&#041; ∘ it&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;and we have&lt;/p&gt;

&lt;p&gt;
&lt;pre&gt;apply ∘ &#040;&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const&quot; rel=&quot;nofollow&quot;&gt;const&lt;/a&gt; g&#039; △ f&#041;
  = apply ∘ &#040;&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry&quot; rel=&quot;nofollow&quot;&gt;curry&lt;/a&gt; &#040;g ∘ exr&#041; ∘ it △ f&#041;
  = apply ∘ &#040;&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry&quot; rel=&quot;nofollow&quot;&gt;curry&lt;/a&gt; &#040;g ∘ exr&#041; ∘ it △ &lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:id&quot; rel=&quot;nofollow&quot;&gt;id&lt;/a&gt; ∘ f&#041;
  = apply ∘ &#040;&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry&quot; rel=&quot;nofollow&quot;&gt;curry&lt;/a&gt; &#040;g ∘ exr&#041; ∘ exl △ &lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:id&quot; rel=&quot;nofollow&quot;&gt;id&lt;/a&gt; ∘ exr&#041; ∘ &#040;it △ f&#041;
  = apply ∘ &#040;&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry&quot; rel=&quot;nofollow&quot;&gt;curry&lt;/a&gt; &#040;g ∘ exr&#041; ∘ exl △ exr&#041; ∘ &#040;it △ f&#041;
  = &#040;g ∘ exr&#041; ∘ &#040;it △ f&#041;
  = g ∘ &#040;exr ∘ &#040;it △ f&#041;&#041;
  = g ∘ f&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;using the defining property of &#039;curry&#039; that for any f : c × a -&gt; b,&lt;/p&gt;

&lt;p&gt;
&lt;pre&gt;f = apply ∘ &#040;&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry&quot; rel=&quot;nofollow&quot;&gt;curry&lt;/a&gt; f ∘ exl △ exr&#041;&lt;/pre&gt;
&lt;/p&gt;

&lt;p&gt;and the result&lt;/p&gt;

&lt;p&gt;
&lt;pre&gt;h ∘ f △ k ∘ g = &#040;h ∘ exl △ k ∘ exr&#041; ∘ &#040;f △ g&#041;&lt;/pre&gt;
&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>A very slightly different take expanding a bit on Derek Elkin&#8217;s comment.  Letting 1 (a.k.a. Unit) be the terminal object of the CCC, one can consider morphisms (1 ↣ b) as &#8220;elements of b&#8221; in some sense.  Then one can have a function corresponding to &#8216;const&#8217; applying to CCC morphisms:</p>

<p>
<pre><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const" rel="nofollow">const</a> :: &#040;1 ↣ b&#041; -&gt; &#040;a ↣ b&#041;
<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const" rel="nofollow">const</a> e = e ∘ it</pre>
</p>

<p>where it :: a ↣ 1  is the unique morphism from a to 1.</p>

<p>Now given CCC morphisms g :: b ↣ c  and f :: a ↣ b, we may view</p>

<p>
<pre>g ∘ exr :: &#040;1 × b&#041; ↣ c</pre>
</p>

<p>and let</p>

<p>
<pre>g' = <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry" rel="nofollow">curry</a> &#040;g ∘ exr&#041; :: 1 ↣ &#040;b ⇨ c&#041;</pre>
</p>

<p>Then</p>

<p>
<pre><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const" rel="nofollow">const</a> g' :: a ↣ &#040;b ⇨ c&#041;
<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const" rel="nofollow">const</a> g' = g' ∘ it = <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry" rel="nofollow">curry</a> &#040;g ∘ exr&#041; ∘ it</pre>
</p>

<p>and we have</p>

<p>
<pre>apply ∘ &#040;<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:const" rel="nofollow">const</a> g' △ f&#041;
  = apply ∘ &#040;<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry" rel="nofollow">curry</a> &#040;g ∘ exr&#041; ∘ it △ f&#041;
  = apply ∘ &#040;<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry" rel="nofollow">curry</a> &#040;g ∘ exr&#041; ∘ it △ <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:id" rel="nofollow">id</a> ∘ f&#041;
  = apply ∘ &#040;<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry" rel="nofollow">curry</a> &#040;g ∘ exr&#041; ∘ exl △ <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:id" rel="nofollow">id</a> ∘ exr&#041; ∘ &#040;it △ f&#041;
  = apply ∘ &#040;<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry" rel="nofollow">curry</a> &#040;g ∘ exr&#041; ∘ exl △ exr&#041; ∘ &#040;it △ f&#041;
  = &#040;g ∘ exr&#041; ∘ &#040;it △ f&#041;
  = g ∘ &#040;exr ∘ &#040;it △ f&#041;&#041;
  = g ∘ f</pre>
</p>

<p>using the defining property of &#8216;curry&#8217; that for any f : c × a -&gt; b,</p>

<p>
<pre>f = apply ∘ &#040;<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:curry" rel="nofollow">curry</a> f ∘ exl △ exr&#041;</pre>
</p>

<p>and the result</p>

<p>
<pre>h ∘ f △ k ∘ g = &#040;h ∘ exl △ k ∘ exr&#041; ∘ &#040;f △ g&#041;</pre>
</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Derek Elkins</title>
		<link>http://conal.net/blog/posts/optimizing-cccs#comment-869</link>
		<dc:creator><![CDATA[Derek Elkins]]></dc:creator>
		<pubDate>Sat, 14 Sep 2013 06:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=537#comment-869</guid>
		<description><![CDATA[&lt;p&gt;I think your difficulty with apply/const comes from the incoherence of const in this context; it adds a kind of &quot;well-pointedness&quot; that goes beyond a CCC and goes beyond what you need for at least this example.  In a nutshell, it doesn&#039;t make sense to say &quot;const x&quot; in general since there is no way to talk about elements, x, &quot;in&quot; some object.  However, category theory does let us talk about arrows and that leads to what is sometimes called the &quot;name&quot; of an arrow (in a CCC).  Specifically,  const f = curry (f ∘ exr) which should look familiar.  From there, it&#039;s easy using the universal property of apply (as a counit of the relevant adjunction) which is: apply ∘ (curry f × id) = f.  You get:&lt;/p&gt;

&lt;pre&gt;
apply ∘ (const g △ f)
= apply ∘ (curry (g ∘ exr) △ f)             -- expand definition of const
= apply ∘ (curry (g ∘ exr) × id) ∘ (id △ f) -- naturality of fork, tacitly adding some ids
= g ∘ exr ∘ (id △ f)                        -- universal property of apply
= g ∘ f                                     -- (half of) universal property of pairs
&lt;/pre&gt;
]]></description>
		<content:encoded><![CDATA[<p>I think your difficulty with apply/const comes from the incoherence of const in this context; it adds a kind of &#8220;well-pointedness&#8221; that goes beyond a CCC and goes beyond what you need for at least this example.  In a nutshell, it doesn&#8217;t make sense to say &#8220;const x&#8221; in general since there is no way to talk about elements, x, &#8220;in&#8221; some object.  However, category theory does let us talk about arrows and that leads to what is sometimes called the &#8220;name&#8221; of an arrow (in a CCC).  Specifically,  const f = curry (f ∘ exr) which should look familiar.  From there, it&#8217;s easy using the universal property of apply (as a counit of the relevant adjunction) which is: apply ∘ (curry f × id) = f.  You get:</p>

<pre>
apply ∘ (const g △ f)
= apply ∘ (curry (g ∘ exr) △ f)             -- expand definition of const
= apply ∘ (curry (g ∘ exr) × id) ∘ (id △ f) -- naturality of fork, tacitly adding some ids
= g ∘ exr ∘ (id △ f)                        -- universal property of apply
= g ∘ f                                     -- (half of) universal property of pairs
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
