fixed an error
|
@ -69,8 +69,9 @@
|
|||
<section class="slide">
|
||||
<div style="text-align:center; position:absolute; top: 2em; font-size: .9em; width: 100%">
|
||||
<h1 style="position: relative;">Category Theory <span class="and">&</span> Programming</h1>
|
||||
<author><em class="base01">by</em> Yann Esposito</author>
|
||||
<div style="font-size:.5em">
|
||||
<div><em class="base01">for</em> <a href="http://www.meetup.com/riviera-scala-clojure">Rivieria Scala Clojure</a> (Note this presentation uses Haskell)</div>
|
||||
<author><em class="base01">by</em> <a href="http://yannesposito.com">Yann Esposito</a></author>
|
||||
<div style="font-size:.8em">
|
||||
<twitter>
|
||||
<a href="http://twitter.com/yogsototh">@yogsototh</a>,
|
||||
</twitter>
|
||||
|
@ -80,7 +81,7 @@
|
|||
</div>
|
||||
<div class="base01" style="font-size: .5em; font-weight: 400; font-variant:italic">
|
||||
<div class="button" style="margin: .5em auto;border: solid 2px; padding: 5px; width: 8em; border-radius: 1em; background:rgba(255,255,255,0.05);" onclick="javascript:gofullscreen();">ENTER FULLSCREEN</div>
|
||||
HTML presentation: use arrows, space to navigate.
|
||||
HTML presentation: use arrows, space, swipe to navigate.
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
@ -703,35 +704,33 @@ Haskell types is fractal:</p>
|
|||
<p><img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/> <em>A natural transformation:</em> familly η ; \(η_X\in\hom{\D}\) for \(X\in\ob{\C}\) s.t.</p>
|
||||
<p>ex: between Haskell functors; <code>F a -> G a</code><br />Rearragement functions only.</p>
|
||||
</section>
|
||||
|
||||
|
||||
<section class="slide">
|
||||
<h2 id="natural-transformation-examples-14">Natural Transformation Examples (1/4)</h2>
|
||||
<pre><code class="haskell small">data Tree a = Empty | Node a [Tree a]
|
||||
toTree :: [a] -> Tree a
|
||||
toTree [] = Empty
|
||||
toTree (x:xs) = Node x [toTree xs]</pre>
|
||||
<pre><code class="haskell small">data List a = Nil | Cons a (List a)
|
||||
toList :: [a] -> Tree a
|
||||
toList [] = Nil
|
||||
toList (x:xs) = Cons x (toList xs)</pre>
|
||||
</code>
|
||||
<p><code>toTree</code> is a natural transformation. It is also a morphism from <code>[]</code> to <code>Tree</code> in the Category of \(\Hask\) endofunctors.</p>
|
||||
<p><code>toList</code> is a natural transformation. It is also a morphism from <code>[]</code> to <code>List</code> in the Category of \(\Hask\) endofunctors.</p>
|
||||
<img style="float:left;width:30%" src="categories/img/mp/nattrans-list-tree.png" alt="natural transformation commutative diagram"/>
|
||||
<figure style="float:right;width:60%">
|
||||
<img style="width:40%" src="categories/img/mp/list-tree-endofunctor-morphism.png" alt="natural transformation commutative diagram"/>
|
||||
</figure>
|
||||
|
||||
|
||||
</section>
|
||||
<section class="slide">
|
||||
<h2 id="natural-transformation-examples-24">Natural Transformation Examples (2/4)</h2>
|
||||
<pre><code class="haskell small">data Tree a = Empty | Node a [Tree a]
|
||||
toList :: Tree a -> [a]
|
||||
toList Empty = []
|
||||
toList (Node x l) = [x] ++ concat (map toList l)</pre>
|
||||
<pre><code class="haskell small">data List a = Nil | Cons a (List a)
|
||||
toHList :: List a -> [a]
|
||||
toHList Nil = []
|
||||
toHList (Cons x xs) = x:toHList xs</pre>
|
||||
</code>
|
||||
<p><code>toList</code> is a natural transformation. It is also a morphism from <code>Tree</code> to <code>[]</code> in the Category of \(\Hask\) endofunctors.</p>
|
||||
<p><code>toHList</code> is a natural transformation. It is also a morphism from <code>List</code> to <code>[]</code> in the Category of \(\Hask\) endofunctors.</p>
|
||||
<img style="float:left;width:30%" src="categories/img/mp/nattrans-tree-list.png" alt="natural transformation commutative diagram"/>
|
||||
<figure style="float:right;width:60%">
|
||||
<img style="width:40%" src="categories/img/mp/tree-list-endofunctor-morphism.png" alt="natural transformation commutative diagram"/> <figcaption><code>toList . toTree = id</code> <span class="and">&</span> <code>toTree . toList = id</code> <span style="visibility:hidden"><span class="and">&</span></span><br/> therefore <code>[]</code> <span class="and">&</span> <code>Tree</code> are <span class="yellow">isomorph</span>. </figcaption>
|
||||
<img style="width:40%" src="categories/img/mp/tree-list-endofunctor-morphism.png" alt="natural transformation commutative diagram"/> <figcaption><code>toList . toHList = id</code> <span class="and">&</span> <code>toHList . toList = id</code> <span style="visibility:hidden"><span class="and">&</span></span><br/> therefore <code>[]</code> <span class="and">&</span> <code>List</code> are <span class="orange">isomorph</span>. </figcaption>
|
||||
</figure>
|
||||
|
||||
|
||||
</section>
|
||||
<section class="slide">
|
||||
<h2 id="natural-transformation-examples-34">Natural Transformation Examples (3/4)</h2>
|
||||
|
@ -1072,10 +1071,49 @@ depth = cata phi where
|
|||
});
|
||||
</script>
|
||||
<!-- Y theme -->
|
||||
<script src="js/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script src="js/highlight/highlight.pack.js"></script>
|
||||
<script>
|
||||
hljs.initHighlightingOnLoad();
|
||||
</script>
|
||||
<script>
|
||||
// --- Google analytics ---
|
||||
function analytics() {
|
||||
// add an event to all link for google analytics
|
||||
$('a').click(function () {
|
||||
// tell analytics to save event
|
||||
try {
|
||||
var identifier=$(this).attr('id') ;
|
||||
var href=$(this).attr('href')
|
||||
var label="";
|
||||
if ( typeof( identifier ) != 'undefined' ) {
|
||||
label=label+'[id]:'+identifier
|
||||
category='JSLink'
|
||||
}
|
||||
if ( typeof( href ) != 'undefined' ) {
|
||||
label=label+' [href]:'+href
|
||||
if ( href[0] == '#' ) {
|
||||
category='Anchor';
|
||||
} else {
|
||||
category='Link';
|
||||
}
|
||||
}
|
||||
_gaq.push(['_trackEvent', category, 'clicked', label]);
|
||||
// console.log('[tracked]: ' + category + ' ; clicked ; ' + label );
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
// pause to allow google script to run
|
||||
var date = new Date();
|
||||
var curDate = null;
|
||||
do {
|
||||
curDate = new Date();
|
||||
} while(curDate-date < 300);
|
||||
});
|
||||
}
|
||||
$(document).ready(function(){ analytics(); });
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 780 KiB After Width: | Height: | Size: 774 KiB |
Before Width: | Height: | Size: 501 KiB After Width: | Height: | Size: 491 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 208 KiB After Width: | Height: | Size: 205 KiB |
Before Width: | Height: | Size: 376 KiB After Width: | Height: | Size: 372 KiB |
Before Width: | Height: | Size: 292 KiB After Width: | Height: | Size: 292 KiB |
Before Width: | Height: | Size: 869 KiB After Width: | Height: | Size: 863 KiB |
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 210 KiB |
Before Width: | Height: | Size: 179 KiB After Width: | Height: | Size: 176 KiB |
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 331 KiB |
Before Width: | Height: | Size: 914 KiB After Width: | Height: | Size: 914 KiB |
Before Width: | Height: | Size: 819 KiB After Width: | Height: | Size: 813 KiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 968 KiB After Width: | Height: | Size: 962 KiB |
Before Width: | Height: | Size: 328 KiB After Width: | Height: | Size: 325 KiB |
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 2.6 MiB |
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
Before Width: | Height: | Size: 2 MiB After Width: | Height: | Size: 2 MiB |
Before Width: | Height: | Size: 907 KiB After Width: | Height: | Size: 900 KiB |
Before Width: | Height: | Size: 255 KiB After Width: | Height: | Size: 253 KiB |
Before Width: | Height: | Size: 282 KiB After Width: | Height: | Size: 276 KiB |
|
@ -3,5 +3,5 @@ resize(.8cm);
|
|||
list=origin;
|
||||
tree=list shifted (gu,0);
|
||||
drawState(list,"\mathtt{[]}");
|
||||
drawState(tree,"\mathtt{Tree}");
|
||||
drawEdgeAngle(list,tree,"\mathtt{toTree}",30);
|
||||
drawState(tree,"\mathtt{List}");
|
||||
drawEdgeAngle(list,tree,"\mathtt{toList}",30);
|
||||
|
|
Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 254 KiB |
Before Width: | Height: | Size: 392 KiB After Width: | Height: | Size: 386 KiB |
Before Width: | Height: | Size: 399 KiB After Width: | Height: | Size: 377 KiB |
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 328 KiB |
|
@ -6,16 +6,16 @@ path ac,ab;
|
|||
|
||||
label(btex $\mathtt{[a]}$ etex,z0);
|
||||
label(btex $\mathtt{[b]}$ etex,z1);
|
||||
label(btex $\mathtt{Tree\ a}$ etex,z2 shifted (-u,0));
|
||||
label(btex $\mathtt{Tree\ b}$ etex,z3 shifted (u,0));
|
||||
label(btex $\mathtt{List\ a}$ etex,z2 shifted (-u,0));
|
||||
label(btex $\mathtt{List\ b}$ etex,z3 shifted (u,0));
|
||||
|
||||
drawEdge(z0,z1,"\mathtt{fmap_{[]}\ f}");
|
||||
drawEdge(z2,z3,"\mathtt{fmap_{Tree}\ f}");
|
||||
drawEdge(z2,z3,"\mathtt{fmap_{List}\ f}");
|
||||
ab:=edge(z0,z2);
|
||||
drawarrow ab;
|
||||
label.lft(btex $\mathtt{toTree}$ etex,midpoint(ab));
|
||||
label.lft(btex $\mathtt{toList}$ etex,midpoint(ab));
|
||||
|
||||
ac:=edge(z1,z3);
|
||||
drawarrow ac;
|
||||
label.rt(btex $\mathtt{toTree}$ etex,midpoint(ac));
|
||||
label.rt(btex $\mathtt{toList}$ etex,midpoint(ac));
|
||||
|
||||
|
|
Before Width: | Height: | Size: 300 KiB After Width: | Height: | Size: 297 KiB |
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 330 KiB |
|
@ -6,18 +6,18 @@ path ac,ab;
|
|||
|
||||
label(btex $\mathtt{[a]}$ etex,z0);
|
||||
label(btex $\mathtt{[b]}$ etex,z1);
|
||||
label(btex $\mathtt{Tree\ a}$ etex,z2 shifted (-u,0));
|
||||
label(btex $\mathtt{Tree\ b}$ etex,z3 shifted (u,0));
|
||||
label(btex $\mathtt{List\ a}$ etex,z2 shifted (-u,0));
|
||||
label(btex $\mathtt{List\ b}$ etex,z3 shifted (u,0));
|
||||
|
||||
drawEdge(z0,z1,"\mathtt{fmap_{[]}\ f}");
|
||||
drawEdge(z2,z3,"\mathtt{fmap_{Tree}\ f}");
|
||||
drawEdge(z2,z3,"\mathtt{fmap_{List}\ f}");
|
||||
ab:=edge(z0,z2);
|
||||
drawarrow ab;
|
||||
label.lft(btex $\mathtt{toTree}$ etex,midpoint(ab));
|
||||
label.lft(btex $\mathtt{toList}$ etex,midpoint(ab));
|
||||
|
||||
ac:=edge(z1,z3);
|
||||
drawarrow ac;
|
||||
label.rt(btex $\mathtt{toTree}$ etex,midpoint(ac));
|
||||
label.rt(btex $\mathtt{toList}$ etex,midpoint(ac));
|
||||
|
||||
drawoptions(withcolor yellow);
|
||||
path abb,acb;
|
||||
|
@ -25,5 +25,5 @@ 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{toList}$ etex,midpoint(abb));
|
||||
label.lft(btex $\mathtt{toList}$ etex,midpoint(acb));
|
||||
label.rt(btex $\mathtt{toHList}$ etex,midpoint(abb));
|
||||
label.lft(btex $\mathtt{toHList}$ etex,midpoint(acb));
|
||||
|
|
Before Width: | Height: | Size: 352 KiB After Width: | Height: | Size: 344 KiB |
Before Width: | Height: | Size: 233 KiB After Width: | Height: | Size: 231 KiB |
Before Width: | Height: | Size: 374 KiB After Width: | Height: | Size: 372 KiB |
Before Width: | Height: | Size: 342 KiB After Width: | Height: | Size: 339 KiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.4 MiB |
Before Width: | Height: | Size: 679 KiB After Width: | Height: | Size: 673 KiB |
Before Width: | Height: | Size: 387 KiB After Width: | Height: | Size: 383 KiB |
Before Width: | Height: | Size: 396 KiB After Width: | Height: | Size: 374 KiB |
|
@ -3,7 +3,7 @@ resize(.8cm);
|
|||
list=origin;
|
||||
tree=list shifted (gu,0);
|
||||
drawState(list,"\mathtt{[]}");
|
||||
drawState(tree,"\mathtt{Tree}");
|
||||
drawEdgeAngle(list,tree,"\mathtt{toTree}",30);
|
||||
drawState(tree,"\mathtt{List}");
|
||||
drawEdgeAngle(list,tree,"\mathtt{toList}",30);
|
||||
drawoptions(withcolor yellow);
|
||||
drawEdgeAngle(tree,list,"\mathtt{toList}",30);
|
||||
drawEdgeAngle(tree,list,"\mathtt{toHList}",30);
|
||||
|
|
Before Width: | Height: | Size: 352 KiB After Width: | Height: | Size: 357 KiB |
0
deck2pdf.sh
Normal file → Executable file
|
@ -15,8 +15,8 @@ page.onLoadFinished = function(status) {
|
|||
}
|
||||
|
||||
page.viewportSize = {
|
||||
width: 960,
|
||||
height: 522
|
||||
width: 1920,
|
||||
height: 1044
|
||||
};
|
||||
|
||||
slideCount = page.evaluate(function() {
|
||||
|
@ -24,8 +24,8 @@ page.onLoadFinished = function(status) {
|
|||
|
||||
$('html').removeClass('csstransitions cssreflections');
|
||||
$('html, body').css({
|
||||
'width': 960,
|
||||
'height': 522,
|
||||
'width': 1920,
|
||||
'height': 1044,
|
||||
'overflow': 'hidden'
|
||||
});
|
||||
$.deck('.slide');
|
||||
|
|
58
deck2png.js.back
Normal file
|
@ -0,0 +1,58 @@
|
|||
var webpage = require('webpage'),
|
||||
page = webpage.create(),
|
||||
system = require('system'),
|
||||
url = system.args[1] || 'index.html',
|
||||
fs = require('fs'),
|
||||
imageSources = [],
|
||||
imageTags;
|
||||
|
||||
page.onLoadFinished = function(status) {
|
||||
var slideCount;
|
||||
|
||||
if (status !== 'success') {
|
||||
console.log('Target file not found.');
|
||||
phantom.exit();
|
||||
}
|
||||
|
||||
page.viewportSize = {
|
||||
width: 960,
|
||||
height: 522
|
||||
};
|
||||
|
||||
slideCount = page.evaluate(function() {
|
||||
var $ = window.jQuery;
|
||||
|
||||
$('html').removeClass('csstransitions cssreflections');
|
||||
$('html, body').css({
|
||||
'width': 960,
|
||||
'height': 522,
|
||||
'overflow': 'hidden'
|
||||
});
|
||||
$.deck('.slide');
|
||||
return $.deck('getSlides').length;
|
||||
});
|
||||
|
||||
fs.makeDirectory('temp-slides');
|
||||
|
||||
for (var i = 0; i < slideCount; i++) {
|
||||
var src = 'temp-slides/output-' + i + '.png';
|
||||
imageSources.push(src);
|
||||
console.log('Rendering slide #' + i);
|
||||
page.render(src);
|
||||
page.evaluate(function() {
|
||||
var $ = window.jQuery;
|
||||
$.deck('next');
|
||||
});
|
||||
}
|
||||
|
||||
imageTags = imageSources.map(function(src) {
|
||||
return '<img src="' + src + '" style="dispay:block;" width="100%">';
|
||||
});
|
||||
|
||||
var output = imageTags.join('') + '<style>*{margin:0;padding:0}</style>';
|
||||
fs.write('temp-output.html', output, 'w');
|
||||
|
||||
phantom.exit();
|
||||
};
|
||||
|
||||
page.open(url);
|
4
jquery-1.7.2.min.js.back
Normal file
4
modernizr.custom.js.back
Normal file
BIN
output.pdf
|
@ -4,12 +4,12 @@ var webpage = require('webpage'),
|
|||
|
||||
page.open('temp-output.html', function(status) {
|
||||
page.viewportSize = {
|
||||
width: 960,
|
||||
height: 522
|
||||
width: 1920,
|
||||
height: 1044
|
||||
};
|
||||
page.paperSize = {
|
||||
width: 960,
|
||||
height: 522
|
||||
width: 1920,
|
||||
height: 1044
|
||||
};
|
||||
page.render('output.pdf');
|
||||
|
||||
|
|
19
png2pdf.js.back
Normal file
|
@ -0,0 +1,19 @@
|
|||
var webpage = require('webpage'),
|
||||
page = webpage.create(),
|
||||
fs = require('fs');
|
||||
|
||||
page.open('temp-output.html', function(status) {
|
||||
page.viewportSize = {
|
||||
width: 960,
|
||||
height: 522
|
||||
};
|
||||
page.paperSize = {
|
||||
width: 960,
|
||||
height: 522
|
||||
};
|
||||
page.render('output.pdf');
|
||||
|
||||
fs.removeTree('temp-slides');
|
||||
fs.remove('temp-output.html');
|
||||
phantom.exit();
|
||||
});
|