updated organization

This commit is contained in:
Yann Esposito 2012-12-07 14:54:45 +01:00
parent 6e08bf59be
commit 9d41f9821c
40 changed files with 272 additions and 84 deletions

View file

@ -648,20 +648,26 @@ Haskell types is fractal:</p>
</li></ul>
</section>
<section class="slide">
<h2 id="category-of-endofunctors">Category of Endofunctors</h2>
<p>All endofunctors of \(\C\) form the category \(\E_\C\) of endofunctors of \(\C\).</p>
<img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/>
<ul>
<li>\(\ob{\E_\C}\): endofunctors of \(\C\) ; \(F:\C→\C\)</li>
<li>\(\hom{\E_\C}\): natural transformations
<ul>
<li>η familly \(η_X\in\hom{\C}\) for \(X\in\ob{\C}\) s.t.</li>
<li>for Haskell functors: <code>F a -&gt; G a</code>.<br />Rearragement functions only.</li>
</ul></li>
</ul>
<h2 id="category-of-hask-endofunctors">Category of \(\Hask\) Endofunctors</h2>
<img src="categories/img/mp/cat-hask-endofunctor.png" alt="Category of Hask endofunctors" />
</section>
<section class="slide">
<h2 id="natural-transformation-examples-13">Natural Transformation Examples (1/3)</h2>
<h2 id="category-of-functors">Category of Functors</h2>
<p>If \(\C\) is <em>small</em> (\(\hom{\C}\) is a set). All functors from \(\C\) to some category \(\D\) form the category \(\mathrm{Func}(\C,\D)\).</p>
<img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/>
<ul>
<li>\(\ob{\mathrm{Func}(\C,\D)}\): Functors \(F:\C→\D\)</li>
<li>\(\hom{\mathrm{Func}(\C,\D)}\): <em>natural transformations</em>
<ul>
<li>η familly \(η_X\in\hom{\D}\) for \(X\in\ob{\C}\) s.t.</li>
<li>ex: between Haskel functors; <code>F a -&gt; G a</code><br />Rearragement functions only.</li>
</ul></li>
<li>∘: Functor composition</li>
</ul>
<p>\(\mathrm{Func}(\C,\C)\) is the category of endofunctors of \(\C\).</p>
</section>
<section class="slide">
<h2 id="natural-transformation-examples-14">Natural Transformation Examples (1/4)</h2>
<pre><code class="haskell">data Tree a = Empty | Node a [Tree a]
toTree :: [a] -> Tree a
toTree [] = Empty
@ -676,7 +682,7 @@ toTree (x:xs) = Node x [toTree xs]</pre>
</section>
<section class="slide">
<h2 id="natural-transformation-examples-23">Natural Transformation Examples (2/3)</h2>
<h2 id="natural-transformation-examples-24">Natural Transformation Examples (2/4)</h2>
<pre><code class="haskell">data Tree a = Empty | Node a [Tree a]
toList :: Tree a -> [a]
toList Empty = []
@ -691,17 +697,29 @@ toList (Node x l) = [x] ++ concat (map toList l)</pre>
</section>
<section class="slide">
<h2 id="natural-transformation-examples-33">Natural Transformation Examples (3/3)</h2>
<pre><code class="haskell">
toMaybe :: [a] -> Maybe a ; mToList :: Maybe a -> [a]
toMaybe [] = Nothing ; mToList Nothing = []
toMaybe (x:xs) = Just x ; mToList Just x = [x]
</pre>
<h2 id="natural-transformation-examples-34">Natural Transformation Examples (3/4)</h2>
<pre><code class="haskell">toMaybe :: [a] -> Maybe a
toMaybe [] = Nothing
toMaybe (x:xs) = Just x</pre>
</code>
<p><code>toMaybe</code> is a natural transformation. It is also a morphism from <code>[]</code> to <code>Maybe</code> in the Category of \(\) endofunctors.</p>
<img style="float:left;width:50%" src="categories/img/mp/nattrans-list-maybe.png" alt="natural transformation commutative diagram"/>
<figure style="float:right;width:40%">
<img src="categories/img/mp/list-maybe-endofunctor-morphism.png" alt="natural transformation commutative diagram"/> <figcaption>There is <span class="red">no isomorphism</span>.<br/> Hint: <code>Bool</code> lists longer than 1. </figcaption>
<img src="categories/img/mp/list-maybe-endofunctor-morphism.png" alt="natural transformation commutative diagram"/>
</figure>
</section>
<section class="slide">
<h2 id="natural-transformation-examples-44">Natural Transformation Examples (4/4)</h2>
<pre><code class="haskell">mToList :: Maybe a -> [a]
mToList Nothing = []
mToList Just x = [x]</pre>
</code>
<p><code>toMaybe</code> is a natural transformation. It is also a morphism from <code>[]</code> to <code>Maybe</code> in the Category of \(\) endofunctors.</p>
<img style="float:left;width:50%" src="categories/img/mp/nattrans-maybe-list.png" alt="natural transformation commutative diagram"/>
<figure style="float:right;width:40%">
<img src="categories/img/mp/maybe-list-endofunctor-morphsm.png" alt="relation between [] and Maybe"/> <figcaption>There is <span class="red">no isomorphism</span>.<br/> Hint: <code>Bool</code> lists longer than 1. </figcaption>
</figure>

View file

@ -1,11 +0,0 @@
<h2 id="category-of-endofunctors">Category of Endofunctors</h2>
<p>All endofunctors of \(\C\) form the category \(\E_\C\) of endofunctors of \(\C\).</p>
<img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/>
<ul>
<li>\(\ob{\E_\C}\): endofunctors of \(\C\) ; \(F:\C→\C\)</li>
<li>\(\hom{\E_\C}\): natural transformations
<ul>
<li>η familly \(η_X\in\hom{\C}\) for \(X\in\ob{\C}\) s.t.</li>
<li>for Haskell functors: <code>F a -&gt; G a</code>.<br />Rearragement functions only.</li>
</ul></li>
</ul>

View file

@ -1,15 +0,0 @@
Category of Endofunctors
------------------------
All endofunctors of \\(\\C\\)
form the category \\(\\E\_\\C\\)
of endofunctors of \\(\\C\\).
<img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/>
- \\(\\ob{\\E\_\\C}\\): endofunctors of \\(\\C\\) ; \\(F:\\C→\\C\\)
- \\(\\hom{\\E\_\\C}\\): natural transformations
- η familly \\(η\_X\\in\\hom{\\C}\\) for \\(X\\in\\ob{\\C}\\) s.t.
- for Haskell functors: `F a -> G a`.
Rearragement functions only.

View file

@ -0,0 +1,2 @@
<h2 id="category-of-hask-endofunctors">Category of \(\Hask\) Endofunctors</h2>
<img src="categories/img/mp/cat-hask-endofunctor.png" alt="Category of Hask endofunctors" />

View file

@ -0,0 +1,4 @@
Category of \\(\\Hask\\) Endofunctors
------------------------------------
<img src="categories/img/mp/cat-hask-endofunctor.png" alt="Category of Hask endofunctors" />

View file

@ -0,0 +1,13 @@
<h2 id="category-of-functors">Category of Functors</h2>
<p>If \(\C\) is <em>small</em> (\(\hom{\C}\) is a set). All functors from \(\C\) to some category \(\D\) form the category \(\mathrm{Func}(\C,\D)\).</p>
<img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/>
<ul>
<li>\(\ob{\mathrm{Func}(\C,\D)}\): Functors \(F:\C→\D\)</li>
<li>\(\hom{\mathrm{Func}(\C,\D)}\): <em>natural transformations</em>
<ul>
<li>η familly \(η_X\in\hom{\D}\) for \(X\in\ob{\C}\) s.t.</li>
<li>ex: between Haskel functors; <code>F a -&gt; G a</code><br />Rearragement functions only.</li>
</ul></li>
<li>∘: Functor composition</li>
</ul>
<p>\(\mathrm{Func}(\C,\C)\) is the category of endofunctors of \(\C\).</p>

View file

@ -0,0 +1,18 @@
Category of Functors
------------------------
If \\(\\C\\) is _small_ (\\(\\hom{\\C}\\) is a set).
All functors from \\(\\C\\) to some category \\(\\D\\)
form the category \\(\\mathrm{Func}(\\C,\\D)\\).
<img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/>
- \\(\\ob{\\mathrm{Func}(\\C,\\D)}\\): Functors \\(F:\\C→\\D\\)
- \\(\\hom{\\mathrm{Func}(\\C,\\D)}\\): _natural transformations_
- η familly \\(η\_X\\in\\hom{\\D}\\) for \\(X\\in\\ob{\\C}\\) s.t.
- ex: between Haskel functors; `F a -> G a`
Rearragement functions only.
- ∘: Functor composition
\\(\\mathrm{Func}(\\C,\\C)\\) is the category of endofunctors of \\(\\C\\).

View file

@ -1,4 +1,4 @@
<h2 id="natural-transformation-examples-13">Natural Transformation Examples (1/3)</h2>
<h2 id="natural-transformation-examples-14">Natural Transformation Examples (1/4)</h2>
<pre><code class="haskell">data Tree a = Empty | Node a [Tree a]
toTree :: [a] -> Tree a
toTree [] = Empty

View file

@ -1,4 +1,4 @@
Natural Transformation Examples (1/3)
Natural Transformation Examples (1/4)
------------------------------------
<pre><code class="haskell">data Tree a = Empty | Node a [Tree a]

View file

@ -1,14 +0,0 @@
<h2 id="natural-transformation-examples-33">Natural Transformation Examples (3/3)</h2>
<pre><code class="haskell">
toMaybe :: [a] -> Maybe a ; mToList :: Maybe a -> [a]
toMaybe [] = Nothing ; mToList Nothing = []
toMaybe (x:xs) = Just x ; mToList Just x = [x]
</pre>
</code>
<p><code>toMaybe</code> is a natural transformation. It is also a morphism from <code>[]</code> to <code>Maybe</code> in the Category of \(\) endofunctors.</p>
<img style="float:left;width:50%" src="categories/img/mp/nattrans-list-maybe.png" alt="natural transformation commutative diagram"/>
<figure style="float:right;width:40%">
<img src="categories/img/mp/list-maybe-endofunctor-morphism.png" alt="natural transformation commutative diagram"/> <figcaption>There is <span class="red">no isomorphism</span>.<br/> Hint: <code>Bool</code> lists longer than 1. </figcaption>
</figure>

View file

@ -1,4 +1,4 @@
<h2 id="natural-transformation-examples-23">Natural Transformation Examples (2/3)</h2>
<h2 id="natural-transformation-examples-24">Natural Transformation Examples (2/4)</h2>
<pre><code class="haskell">data Tree a = Empty | Node a [Tree a]
toList :: Tree a -> [a]
toList Empty = []

View file

@ -1,4 +1,4 @@
Natural Transformation Examples (2/3)
Natural Transformation Examples (2/4)
------------------------------------
<pre><code class="haskell">data Tree a = Empty | Node a [Tree a]

View file

@ -0,0 +1,12 @@
<h2 id="natural-transformation-examples-34">Natural Transformation Examples (3/4)</h2>
<pre><code class="haskell">toMaybe :: [a] -> Maybe a
toMaybe [] = Nothing
toMaybe (x:xs) = Just x</pre>
</code>
<p><code>toMaybe</code> is a natural transformation. It is also a morphism from <code>[]</code> to <code>Maybe</code> in the Category of \(\) endofunctors.</p>
<img style="float:left;width:50%" src="categories/img/mp/nattrans-list-maybe.png" alt="natural transformation commutative diagram"/>
<figure style="float:right;width:40%">
<img src="categories/img/mp/list-maybe-endofunctor-morphism.png" alt="natural transformation commutative diagram"/>
</figure>

View file

@ -1,11 +1,9 @@
Natural Transformation Examples (3/3)
Natural Transformation Examples (3/4)
-------------------------------------
<pre><code class="haskell">
toMaybe :: [a] -> Maybe a ; mToList :: Maybe a -> [a]
toMaybe [] = Nothing ; mToList Nothing = []
toMaybe (x:xs) = Just x ; mToList Just x = [x]
</pre></code>
<pre><code class="haskell">toMaybe :: [a] -> Maybe a
toMaybe [] = Nothing
toMaybe (x:xs) = Just x</pre></code>
`toMaybe` is a natural transformation.
@ -14,7 +12,4 @@ It is also a morphism from `[]` to `Maybe` in the Category of \\(\Hask\\) endofu
<img style="float:left;width:50%" src="categories/img/mp/nattrans-list-maybe.png" alt="natural transformation commutative diagram"/>
<figure style="float:right;width:40%">
<img src="categories/img/mp/list-maybe-endofunctor-morphism.png" alt="natural transformation commutative diagram"/>
<figcaption>There is <span class="red">no isomorphism</span>.<br/>
Hint: <code>Bool</code> lists longer than 1.
</figcaption>
</figure>

View file

@ -0,0 +1,12 @@
<h2 id="natural-transformation-examples-44">Natural Transformation Examples (4/4)</h2>
<pre><code class="haskell">mToList :: Maybe a -> [a]
mToList Nothing = []
mToList Just x = [x]</pre>
</code>
<p><code>toMaybe</code> is a natural transformation. It is also a morphism from <code>[]</code> to <code>Maybe</code> in the Category of \(\) endofunctors.</p>
<img style="float:left;width:50%" src="categories/img/mp/nattrans-maybe-list.png" alt="natural transformation commutative diagram"/>
<figure style="float:right;width:40%">
<img src="categories/img/mp/maybe-list-endofunctor-morphsm.png" alt="relation between [] and Maybe"/> <figcaption>There is <span class="red">no isomorphism</span>.<br/> Hint: <code>Bool</code> lists longer than 1. </figcaption>
</figure>

View file

@ -0,0 +1,18 @@
Natural Transformation Examples (4/4)
-------------------------------------
<pre><code class="haskell">mToList :: Maybe a -> [a]
mToList Nothing = []
mToList Just x = [x]</pre></code>
`toMaybe` is a natural transformation.
It is also a morphism from `[]` to `Maybe` in the Category of \\(\Hask\\) endofunctors.
<img style="float:left;width:50%" src="categories/img/mp/nattrans-maybe-list.png" alt="natural transformation commutative diagram"/>
<figure style="float:right;width:40%">
<img src="categories/img/mp/maybe-list-endofunctor-morphsm.png" alt="relation between [] and Maybe"/>
<figcaption>There is <span class="red">no isomorphism</span>.<br/>
Hint: <code>Bool</code> lists longer than 1.
</figcaption>
</figure>

View file

@ -0,0 +1,108 @@
% DPI 180
pair int,bool,func,intlist,list;
resize(.8cm);
int=origin;
% drawoptions (withcolor baseOne withpen pencircle scaled 1.2);
intlist=int shifted (gu,0);
func=int shifted (0,-.6gu);
bool=func shifted (gu,0);
list=func shifted (2u,0);
drawLoopPoint(int,int shifted (0,1.6u),"\mathtt{sqrt}");
drawEdge(int,int,"\mathtt{id}");
drawEdgeAngle(int,bool,"\mathtt{odd}",-30);
drawEdgeAngle(int,bool,"\mathtt{even}",30);
drawEdge(intlist,intlist,"\mathtt{tail}");
drawEdge(intlist,int,"\mathtt{length}");
% ---------- F ----------------
pair decal;
pair fint,fbool,ffunc,fintlist,flist;
decal := (-1.2gu,-1.5gu);
fint=int shifted decal;
fintlist=intlist shifted decal;
ffunc= func shifted decal;
fbool= bool shifted decal;
flist= list shifted decal;
drawLoopPoint(fint,fint shifted (0,1.9u),"\scriptstyle\mathtt{fmap\ sqrt}");
drawEdge(fint,fint,"\scriptstyle\mathtt{fmap\ id}");
drawEdgeAngle(fint,fbool,"\scriptstyle\mathtt{fmap\ odd}",-30);
drawEdgeAngle(fint,fbool,"\scriptstyle\mathtt{fmap\ even}",30);
drawEdge(fintlist,fintlist,"\scriptstyle\mathtt{fmap\ tail}");
drawEdge(fintlist,fint,"\scriptstyle\mathtt{fmap\ length}");
drawblock(fint,fbool,"\mathtt{F}");
pair ff;
ff = .5[fint,fintlist] shifted (0,u);
path b;
b := block(origin,origin);
draw b scaled .5 shifted ff;
label.top(btex $\mathtt{F\ F}$ etex, blockLabelPosition(b)) scaled .5 shifted ff;
draw b scaled .25 shifted ff;
label.top(btex $\mathtt{F\ F\ F}$ etex, blockLabelPosition(b)) scaled .25 shifted ff;
% ------------ G --------------
pair gdecal;
pair gint,gbool,gfunc,gintlist,glist;
gdecal := (1.2gu,-1.5gu);
gint=int shifted gdecal;
gintlist=intlist shifted gdecal;
gfunc= func shifted gdecal;
gbool= bool shifted gdecal;
glist= list shifted gdecal;
drawLoopPoint(gint,gint shifted (0,1.9u),"\scriptstyle\mathtt{fmap\ sqrt}");
drawEdge(gint,gint,"\scriptstyle\mathtt{fmap\ id}");
drawEdgeAngle(gint,gbool,"\scriptstyle\mathtt{fmap\ odd}",-30);
drawEdgeAngle(gint,gbool,"\scriptstyle\mathtt{fmap\ even}",30);
drawEdge(gintlist,gintlist,"\scriptstyle\mathtt{fmap\ tail}");
drawEdge(gintlist,gint,"\scriptstyle\mathtt{fmap\ length}");
drawblock(gint,gbool,"\mathtt{G}");
pair gf;
gf = .5[gint,gintlist] shifted (0,u);
path b;
b := block(origin,origin);
draw b scaled .5 shifted gf;
label.top(btex $\mathtt{G\ G}$ etex, blockLabelPosition(b)) scaled .5 shifted gf;
draw b scaled .25 shifted gf;
label.top(btex $\mathtt{G\ G\ G}$ etex, blockLabelPosition(b)) scaled .25 shifted gf;
drawState(int,"\mathtt{Int}");
drawState(intlist,"\mathtt{[Int]}");
drawState(func,"\mathtt{a\rightarrow b}");
drawState(list,"\mathtt{[a]}");
drawState(bool,"\mathtt{Bool}");
drawState(fint,"\mathtt{F\ Int}");
drawState(fintlist,"\mathtt{F\ [Int]}");
drawState(ffunc,"\mathtt{F\ a\rightarrow b}");
drawState(flist,"\mathtt{F\ [a]}");
drawState(fbool,"\mathtt{F\ Bool}");
drawState(gint,"\mathtt{G\ Int}");
drawState(gintlist,"\mathtt{G\ [Int]}");
drawState(gfunc,"\mathtt{G\ a\rightarrow b}");
drawState(glist,"\mathtt{G\ [a]}");
drawState(gbool,"\mathtt{G\ Bool}");
drawoptions(withcolor yellow);
label.top(btex $I$ etex, .5[int,intlist] shifted (0,u));
drawoptions(withpen pencircle scaled 2bp withcolor yellow);
ahlength:=.3u;
drawEdgeAngle(.5[int,func] shifted (-.5u,0), ff shifted (0,2.2u), "?", -30);
drawEdgeAngle(ff shifted (-u,2.2u), .5[int,func] shifted (-.5u,u), "?", 30);
drawEdgeAngle(.5[intlist,bool] shifted (.5u,0), gf shifted (0,2.2u), "?", 30);
drawEdgeAngle(gf shifted (u,2.2u), .5[intlist,bool] shifted (.5u,u), "?", -30);
drawEdgeAngle(.5[fintlist,fbool] shifted (1.1u,u), .5[gint,gfunc] shifted (-1.1u,u), "?", 30);
drawEdgeAngle(.5[gint,gfunc] shifted (-1.1u,u), .5[fintlist,fbool] shifted (1.1u,u), "?", 30);

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 KiB

View file

@ -64,9 +64,15 @@ for fpfic in $listfic; do
| sed 's/green/s_green/g' > $tmp
[[ -e $old ]] && diff $tmp $old >/dev/null && { echo " identical"; continue }
print -- "[$PWD]: mpost $tmp && convert -density 300 $tmp.1 $png"
dpi=$(grep '% DPI' $tmp | awk '{print $3}')
[[ $dpi = "" ]] && dpi=600
print
print "[DPI]: $dpi"
print -- "[$PWD]: mpost $tmp && convert -density $dpi $tmp.1 $png"
mpost --tex=latex $tmp && \
convert -colorspace rgb -density 600 $eps '(' +clone -background black -shadow 90x4+0+1 ')' +swap -background none -layers merge +repage $png && \
convert -colorspace rgb -density $dpi $eps '(' +clone -background black -shadow 90x4+0+1 ')' +swap -background none -layers merge +repage $png && \
\cp -f $png $scriptdir && \
\cp -f $tmp $old && \
echo "updated"

View file

@ -1,8 +1,8 @@
pair tree,list;
resize(.8cm);
list=origin;
tree=list shifted (gu,0);
drawState(list,"\mathtt{[]}");
drawState(tree,"\mathtt{Maybe}");
drawEdgeAngle(list,tree,"\mathtt{toMaybe}",30);
drawEdgeAngle(tree,list,"\mathtt{mToList}",30);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 KiB

After

Width:  |  Height:  |  Size: 282 KiB

View file

@ -0,0 +1,9 @@
pair tree,list;
resize(.8cm);
list=origin;
tree=list shifted (gu,0);
drawState(list,"\mathtt{[]}");
drawState(tree,"\mathtt{Maybe}");
drawEdgeAngle(list,tree,"\mathtt{toMaybe}",30);
drawEdgeAngle(tree,list,"\mathtt{mToList}",30);

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 KiB

View file

@ -18,11 +18,3 @@ label.lft(btex $\mathtt{toMaybe}$ etex,midpoint(ab));
ac:=edge(z1,z3);
drawarrow ac;
label.rt(btex $\mathtt{toMaybe}$ etex,midpoint(ac));
path abb,acb;
abb:=edge(z2 shifted (.2u,0),z0 shifted (.2u,0));
acb:=edge(z3 shifted (-.2u,0),z1 shifted (-.2u,0));
drawarrow abb;
drawarrow acb;
label.rt(btex $\mathtt{mToList}$ etex,midpoint(abb));
label.lft(btex $\mathtt{mToList}$ etex,midpoint(acb));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 KiB

After

Width:  |  Height:  |  Size: 334 KiB

View file

@ -0,0 +1,21 @@
z0=(0,0);
z1=(1.5gu,0);
z2=(0,-gu);
z3=(1.5gu,-gu);
path ac,ab;
label(btex $\mathtt{[a]}$ etex,z0);
label(btex $\mathtt{[b]}$ etex,z1);
label(btex $\mathtt{Maybe\ a}$ etex,z2 shifted (-u,0));
label(btex $\mathtt{Maybe\ b}$ etex,z3 shifted (u,0));
drawEdge(z0,z1,"\mathtt{fmap_{[]}\ f}");
drawEdge(z2,z3,"\mathtt{fmap_{Maybe}\ f}");
path abb,acb;
abb:=edge(z2 shifted (.2u,0),z0 shifted (.2u,0));
acb:=edge(z3 shifted (-.2u,0),z1 shifted (-.2u,0));
drawarrow abb;
drawarrow acb;
label.rt(btex $\mathtt{mToList}$ etex,midpoint(abb));
label.lft(btex $\mathtt{mToList}$ etex,midpoint(acb));

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB