updated hopefully simpler

This commit is contained in:
Yann Esposito 2012-12-06 18:19:52 +01:00
parent da71814e22
commit e1863f46a4
52 changed files with 131 additions and 111 deletions

View file

@ -126,7 +126,7 @@
<img class="right" src="categories/img/mindblown.gif" alt="mind blown"/>
<p>Math vocabulary used in this presentation:</p>
<blockquote>
<p>Category, Morphism, Associativity, Preorder, Functor, Endofunctor, Categorial property, Commutative diagram, Isomorph, Initial, Dual, Monoid Natural transformation, Monad, κατα-morphism, ...</p>
<p>Category, Morphism, Associativity, Preorder, Functor, Endofunctor, Categorial property, Commutative diagram, Isomorph, Initial, Dual, Monoid, Natural transformation, Monad, κατα-morphism, ...</p>
</blockquote>
<img class="right" src="categories/img/readingcat.jpg" alt="lolcat"/>
<table style="width:70%">
@ -358,21 +358,26 @@ such that for each \(f:A→B\):</p>
</li></ul>
</section>
<section class="slide">
<h2>Degenerated Categories</h2>
<img class="right" style="max-width:17%" src="categories/img/mp/monoid.png" alt="Monoids are one object categories"/>
<h3>Monoids</h3>
<p>each Monoid \((M,e,⊙): \ob{M}=\{∙\},\hom{M}=M,\circ = ⊙\)</p>
<p>one object</p>
<p>Examples: <code>(Integer,0,+)</code>, <code>(Integer,1,*)</code>, <code>(Strings,"",++)</code>, <code>(Lists,[],++)</code>, ...
</section>
<section class="slide">
<h2>Number construction</h2>
<h3>Each Numbers as a whole category</h3>
<img src="categories/img/mp/numbers.png" alt="Each number as a category"/>
</section>
<section class="slide">
<h2>Degenerated Categories: Monoids</h2>
<img class="right" style="max-width:17%" src="categories/img/mp/monoid.png" alt="Monoids are one object categories"/>
<p>Each Monoid \((M,e,⊙): \ob{M}=\{∙\},\hom{M}=M,\circ = ⊙\)</p>
<p class="yellow">Only one object.</p>
<p>Examples:</p>
<ul><li><code>(Integer,0,+)</code>,
</li><li><code>(Integer,1,*)</code>,
</li><li><code>(Strings,"",++)</code>,
</li><li>for each <code>a</code>, <code>([a],[],++)</code>
</li><li>Couple of monoids \((M×N, (0_M,0_N), (⊙_M,⊙_N))\)
</li></ul>
</section>
<section class="slide">
<h2>Degenerated Categories: Preorders</h2>
<p>each preorder \((P,≤)\):</p>
@ -387,22 +392,22 @@ such that for each \(f:A→B\):</p>
<img src="categories/img/mp/preorder.png" alt="preorder category"/>
</section>
<section class="slide">
<h2>Degenerated Categories</h2>
<h2>Degenerated Categories: Discrete Categories</h2>
<img class="right" src="categories/img/mp/set.png" alt="Any set can be a category"/>
<h3>Any Set</h3>
<p>Any set \(E: \ob{E}=E, \hom{x,y}=\{x\} ⇔ x=y \)</p>
<p><em>Only identities ; not so interesting</em></p>
<p class="yellow">Only identities</p>
</section>
<section class="slide">
<h2>Categorical Property</h2>
<h2 class="base1">Categorical Property</h2>
<p>Any property which can be expressed in term of category, objects, morphism and composition</p>
<p class="base1">Any property which can be expressed in term of category, objects, morphism and composition.</p>
<ul><li> <em class="yellow">isomorphism</em>: \(f:A→B\) which can be "undone" <em class="yellow">i.e.</em>
<ul><li> <em class="yellow">isomorphism</em>: \(f:A→B\) which can be "undone" <em>i.e.</em>
<br/> \(∃g:B→A\), \(g∘f=id_A\) <span class="and">&amp;</span> \(f∘g=id_B\)
<br/> in this case, \(A\) <span class="and">&amp;</span> \(B\) are <em class="yellow">isomorphic</em>.
</li><li> <em class="yellow">Dual</em>: reverse direction of arrows of \(\C\)
</li><li> <em class="yellow">Dual</em>: \(\D\) is \(\C\) with reversed morphisms.
</li><li> <em class="yellow">Initial</em>: \(Z\in\ob{\C}\) s.t. \(∀Y∈\ob{\C}, \#\hom{Z,Y}=1\)
<br/> Unique ("up to isormophism")
</li><li> <em class="yellow">Terminal</em>: \(T\in\ob{\C}\) s.t. \(T\) is initial in the dual of \(\C\)
@ -421,8 +426,8 @@ A <em>functor</em> <span class="yellow">\(\F\)</span> from <span class="blue">\(
<li> Associate morphisms: <span class="backblue">\(f:A\to B\)</span> to <span class="backgreen">\(\F(f) : \F(A) \to \F(B)\)</span>
such that
<ul>
<li>\( \F (\)<span class="backblue blue">\(\id_X\)</span>\() = \)<span class="backgreen"><span class="green">\(\id\)</span>\(\vphantom{\id}_{\F(}\)<span class="blue">\(\vphantom{\id}_X\)</span>\(\vphantom{\id}_{)} \)</span>,</li>
<li>\( \F (\)<span class="backblue blue">\(g∘f\)</span>\() = \)<span class="backgreen">\( \F(\)<span class="blue">\(g\)</span>\() \)<span class="green">\(\circ\)</span>\( \F(\)<span class="blue">\(f\)</span>\() \)</span></li>
<li>\( \F (\)<span class="backblue blue">\(\id_X\)</span>\()= \)<span class="backgreen"><span class="green">\(\id\)</span>\(\vphantom{\id}_{\F(}\)<span class="blue">\(\vphantom{\id}_X\)</span>\(\vphantom{\id}_{)} \)</span>,</li>
<li>\( \F (\)<span class="backblue blue">\(g∘f\)</span>\()= \)<span class="backgreen">\( \F(\)<span class="blue">\(g\)</span>\() \)<span class="green">\(\circ\)</span>\( \F(\)<span class="blue">\(f\)</span>\() \)</span></li>
</ul>
</li>
</ul>
@ -559,25 +564,16 @@ fmap head [[1,2,3],[4,5,6]] == [1,4]
</code></pre>
</section>
<section class="slide">
<h2>String like type</h2>
<pre class="haskell"><code>
data F a = Cons Char a | Nil
-- examples :
-- Cons 'c' 32 :: F Int
-- Cons 'c' (\x -> x*x) :: F (Int -> Int)
-- Cons 'c' (Cons 'a' (\x -> x*x)) :: F (F (Int -> Int))
-- Cons 'c' (Cons 'c' Nil) :: F (F (F))
-- note String is the fixed point of F: F(F(F(...)))
instance Functor F where
fmap :: (a -> b) -> [a] -> [b]
fmap f (Cons c x) = Cons c (f x)
fmap f Nil = Nil
fmap (+1) (Cons 'c' 3) == Cons 'c' 4
fmap (+1) Nil == Nil
fmap head (Cons 'c' [1,2,3])== Cons 'c' 1
</code></pre>
<h2 id="haskell-functors-for-the-programmer">Haskell Functors for the programmer</h2>
<p><code>Functor</code> is a type class used for types that can be mapped over.</p>
<ul>
<li>Containers: <code>[]</code>, Trees, Map, HashMap...</li>
<li>Smart containers:
<ul>
<li><code>Maybe a</code>: help to handle absence of <code>a</code>.<br />Ex: <code>safeDiv x 0 ⇒ Nothing</code></li>
<li><code>Either String a</code>: help to handle errors<br />Ex: <code>reportDiv x 0 ⇒ Left &quot;Division by 0!&quot;</code></li>
</ul></li>
</ul>
</section>
<section class="slide">
<h2>Haskell Functor intuition</h2>
@ -653,14 +649,14 @@ Haskell types is fractal:</p>
</section>
<section class="slide">
<h2 id="category-of-endofunctors">Category of Endofunctors</h2>
<img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/>
<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>ex: for Haskell functors: <code>F a -&gt; G a</code> are the natural transformations.</li>
<li>for Haskell functors: <code>F a -&gt; G a</code> are the natural transformations.<br />List to Trees, Tree to List, Tree to Maybe...<br />Rearragement functions only.</li>
</ul></li>
</ul>
</section>
@ -669,6 +665,7 @@ Haskell types is fractal:</p>
<blockquote>
<p>A Monad is just a monoid in the category of endofunctors, what's the problem?</p>
</blockquote>
<p>The real sentence was:</p>
<blockquote>
<p>All told, a monad in X is just a monoid in the category of endofunctors of X, with product × replaced by composition of endofunctors and unit set by the identity endofunctor.</p>
</blockquote>
@ -691,13 +688,13 @@ Haskell types is fractal:</p>
<h2 id="monads-are-just-monoids-24">Monads are just Monoids (2/4)</h2>
<p>A Monad is a triplet \((M,⊙,η)\) s.t.</p>
<ul>
<li>\(M\) an <span class="yellow">Endofunctor</span></li>
<li>\(⊙:M×M→M\) a nat. trans. (× is functor composition)</li>
<li>\(η:I→M\) a nat. trans. (\(I\) identity functor)</li>
<li>\(M\) an <span class="yellow">Endofunctor</span> (to type <code>a</code> associate <code>M a</code>)</li>
<li>\(⊙:M×M→M\) a <span class="yellow">nat. trans.</span> (i.e. <code>⊙::M (M a) → M a</code>)</li>
<li>\(η:I→M\) a <span class="yellow">nat. trans.</span> (\(I\) identity functor ; <code>η::a → M a</code>)</li>
</ul>
<p>Satisfying</p>
<ul>
<li>\(M ⊙ (M ⊙ M)) = (M ⊙ M) ⊙ M\)</li>
<li>\(M ⊙ (M ⊙ M) = (M ⊙ M) ⊙ M\)</li>
<li>\(η ⊙ M = M = M ⊙ η\)</li>
</ul>
</section>
@ -728,9 +725,9 @@ join _ = Nothing
<li>\(η ⊙ M = M = M ⊙ η\)</li>
</ul>
<pre class="nohighlight small"><code>join (Just (join (Just (Just x)))) = join (join (Just (Just (Just x))))
join (Just (join (Just Nothing))) = join (join (Just (Just Nothing)))
join (Just (join Nothing)) = join (join (Just Nothing))
join Nothing = join (join Nothing)
join (Just (join (Just Nothing))) = join (join (Just (Just Nothing)))
join (Just (join Nothing)) = join (join (Just Nothing))
join Nothing = join (join Nothing)
join (η (Just x)) = Just x = Just (η x)
join (η Nothing) = Nothing = Nothing</code></pre>
@ -756,7 +753,7 @@ h=\x->[x+1,x*10] ⇒ h 1 = [2,10] ⇒ (h <=< h) 1 = [3,20,11,100]</code></pre>
<h2 id="monads-utility">Monads utility</h2>
<p>A monad can also hide computation details (ex: a common parameter).</p>
<p><code>DrawScene</code> to <code><span class="yellow">State Screen</span> DrawScene</code> ; still <b>pure</b>.</p>
<pre class="haskell left small" style="width:40%"><code>main = drawImage (width,height)
<pre class="haskell left smaller" style="width:40%"><code>main = drawImage (width,height)
drawImage :: Screen -&gt; DrawScene
drawImage <span class="orange">screen</span> =
@ -767,7 +764,7 @@ drawImage <span class="orange">screen</span> =
drawPoint point <span class="orange">screen</span> = ...
drawCircle circle <span class="orange">screen</span> = ...
drawRectangle rectangle <span class="orange">screen</span> = ...</code></pre>
<pre class="haskell right small" style="width:45%"><code>main = do
<pre class="haskell right smaller" style="width:45%"><code>main = do
<span class="orange">put (Screen 1024 768)</span>
drawImage
@ -779,7 +776,7 @@ drawImage = do
drawPoint :: Point -&gt; State Screen DrawScene
drawPoint p = do
<span class="orange">Screensize width height &lt;- get</span>
<span class="orange">Screen width height &lt;- get</span>
...</code></pre>
</section>
<!-- End slides. -->

View file

@ -2,7 +2,7 @@
<img class="right" src="categories/img/mindblown.gif" alt="mind blown"/>
<p>Math vocabulary used in this presentation:</p>
<blockquote>
<p>Category, Morphism, Associativity, Preorder, Functor, Endofunctor, Categorial property, Commutative diagram, Isomorph, Initial, Dual, Monoid Natural transformation, Monad, κατα-morphism, ...</p>
<p>Category, Morphism, Associativity, Preorder, Functor, Endofunctor, Categorial property, Commutative diagram, Isomorph, Initial, Dual, Monoid, Natural transformation, Monad, κατα-morphism, ...</p>
</blockquote>
<img class="right" src="categories/img/readingcat.jpg" alt="lolcat"/>
<table style="width:70%">

View file

@ -1,7 +1,12 @@
<h2>Degenerated Categories</h2>
<h2>Degenerated Categories: Monoids</h2>
<img class="right" style="max-width:17%" src="categories/img/mp/monoid.png" alt="Monoids are one object categories"/>
<h3>Monoids</h3>
<p>each Monoid \((M,e,⊙): \ob{M}=\{∙\},\hom{M}=M,\circ = ⊙\)</p>
<p>one object</p>
<p>Examples: <code>(Integer,0,+)</code>, <code>(Integer,1,*)</code>, <code>(Strings,"",++)</code>, <code>(Lists,[],++)</code>, ...
<p>Each Monoid \((M,e,⊙): \ob{M}=\{∙\},\hom{M}=M,\circ = ⊙\)</p>
<p class="yellow">Only one object.</p>
<p>Examples:</p>
<ul><li><code>(Integer,0,+)</code>,
</li><li><code>(Integer,1,*)</code>,
</li><li><code>(Strings,"",++)</code>,
</li><li>for each <code>a</code>, <code>([a],[],++)</code>
</li><li>Couple of monoids \((M×N, (0_M,0_N), (⊙_M,⊙_N))\)
</li></ul>

View file

@ -1,6 +1,6 @@
<h2>Degenerated Categories</h2>
<h2>Degenerated Categories: Discrete Categories</h2>
<img class="right" src="categories/img/mp/set.png" alt="Any set can be a category"/>
<h3>Any Set</h3>
<p>Any set \(E: \ob{E}=E, \hom{x,y}=\{x\} ⇔ x=y \)</p>
<p><em>Only identities ; not so interesting</em></p>
<p class="yellow">Only identities</p>

View file

@ -1,11 +1,11 @@
<h2>Categorical Property</h2>
<h2 class="base1">Categorical Property</h2>
<p>Any property which can be expressed in term of category, objects, morphism and composition</p>
<p class="base1">Any property which can be expressed in term of category, objects, morphism and composition.</p>
<ul><li> <em class="yellow">isomorphism</em>: \(f:A→B\) which can be "undone" <em class="yellow">i.e.</em>
<ul><li> <em class="yellow">isomorphism</em>: \(f:A→B\) which can be "undone" <em>i.e.</em>
<br/> \(∃g:B→A\), \(g∘f=id_A\) &amp; \(f∘g=id_B\)
<br/> in this case, \(A\) &amp; \(B\) are <em class="yellow">isomorphic</em>.
</li><li> <em class="yellow">Dual</em>: reverse direction of arrows of \(\C\)
</li><li> <em class="yellow">Dual</em>: \(\D\) is \(\C\) with reversed morphisms.
</li><li> <em class="yellow">Initial</em>: \(Z\in\ob{\C}\) s.t. \(∀Y∈\ob{\C}, \#\hom{Z,Y}=1\)
<br/> Unique ("up to isormophism")
</li><li> <em class="yellow">Terminal</em>: \(T\in\ob{\C}\) s.t. \(T\) is initial in the dual of \(\C\)

View file

@ -8,8 +8,8 @@ A <em>functor</em> <span class="yellow">\(\F\)</span> from <span class="blue">\(
<li> Associate morphisms: <span class="backblue">\(f:A\to B\)</span> to <span class="backgreen">\(\F(f) : \F(A) \to \F(B)\)</span>
such that
<ul>
<li>\( \F (\)<span class="backblue blue">\(\id_X\)</span>\() = \)<span class="backgreen"><span class="green">\(\id\)</span>\(\vphantom{\id}_{\F(}\)<span class="blue">\(\vphantom{\id}_X\)</span>\(\vphantom{\id}_{)} \)</span>,</li>
<li>\( \F (\)<span class="backblue blue">\(g∘f\)</span>\() = \)<span class="backgreen">\( \F(\)<span class="blue">\(g\)</span>\() \)<span class="green">\(\circ\)</span>\( \F(\)<span class="blue">\(f\)</span>\() \)</span></li>
<li>\( \F (\)<span class="backblue blue">\(\id_X\)</span>\()= \)<span class="backgreen"><span class="green">\(\id\)</span>\(\vphantom{\id}_{\F(}\)<span class="blue">\(\vphantom{\id}_X\)</span>\(\vphantom{\id}_{)} \)</span>,</li>
<li>\( \F (\)<span class="backblue blue">\(g∘f\)</span>\()= \)<span class="backgreen">\( \F(\)<span class="blue">\(g\)</span>\() \)<span class="green">\(\circ\)</span>\( \F(\)<span class="blue">\(f\)</span>\() \)</span></li>
</ul>
</li>
</ul>

View file

@ -0,0 +1,10 @@
<h2 id="haskell-functors-for-the-programmer">Haskell Functors for the programmer</h2>
<p><code>Functor</code> is a type class used for types that can be mapped over.</p>
<ul>
<li>Containers: <code>[]</code>, Trees, Map, HashMap...</li>
<li>Smart containers:
<ul>
<li><code>Maybe a</code>: help to handle absence of <code>a</code>.<br />Ex: <code>safeDiv x 0 ⇒ Nothing</code></li>
<li><code>Either String a</code>: help to handle errors<br />Ex: <code>reportDiv x 0 ⇒ Left &quot;Division by 0!&quot;</code></li>
</ul></li>
</ul>

View file

@ -0,0 +1,11 @@
Haskell Functors for the programmer
------------------------------
`Functor` is a type class used for types that can be mapped over.
- Containers: `[]`, Trees, Map, HashMap...
- Smart containers:
- `Maybe a`: help to handle absence of `a`.
Ex: `safeDiv x 0 ⇒ Nothing`
- `Either String a`: help to handle errors
Ex: `reportDiv x 0 ⇒ Left "Division by 0!"`

View file

@ -1,19 +0,0 @@
<h2>String like type</h2>
<pre class="haskell"><code>
data F a = Cons Char a | Nil
-- examples :
-- Cons 'c' 32 :: F Int
-- Cons 'c' (\x -> x*x) :: F (Int -> Int)
-- Cons 'c' (Cons 'a' (\x -> x*x)) :: F (F (Int -> Int))
-- Cons 'c' (Cons 'c' Nil) :: F (F (F))
-- note String is the fixed point of F: F(F(F(...)))
instance Functor F where
fmap :: (a -> b) -> [a] -> [b]
fmap f (Cons c x) = Cons c (f x)
fmap f Nil = Nil
fmap (+1) (Cons 'c' 3) == Cons 'c' 4
fmap (+1) Nil == Nil
fmap head (Cons 'c' [1,2,3])== Cons 'c' 1
</code></pre>

View file

@ -1,11 +1,11 @@
<h2 id="category-of-endofunctors">Category of Endofunctors</h2>
<img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/>
<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>ex: for Haskell functors: <code>F a -&gt; G a</code> are the natural transformations.</li>
<li>for Haskell functors: <code>F a -&gt; G a</code> are the natural transformations.<br />List to Trees, Tree to List, Tree to Maybe...<br />Rearragement functions only.</li>
</ul></li>
</ul>

View file

@ -1,13 +1,16 @@
Category of Endofunctors
------------------------
<img src="categories/img/mp/natural-transformation.png" alt="Natural transformation commutative diagram" class="right"/>
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.
- ex: for Haskell functors: `F a -> G a` are the natural transformations.
- for Haskell functors: `F a -> G a` are the natural transformations.
List to Trees, Tree to List, Tree to Maybe...
Rearragement functions only.

View file

@ -2,6 +2,7 @@
<blockquote>
<p>A Monad is just a monoid in the category of endofunctors, what's the problem?</p>
</blockquote>
<p>The real sentence was:</p>
<blockquote>
<p>All told, a monad in X is just a monoid in the category of endofunctors of X, with product × replaced by composition of endofunctors and unit set by the identity endofunctor.</p>
</blockquote>

View file

@ -3,6 +3,8 @@ Monads
> A Monad is just a monoid in the category of endofunctors, what's the problem?
The real sentence was:
> All told, a monad in X is just a monoid in the category of endofunctors of X,
> with product × replaced by composition of endofunctors
> and unit set by the identity endofunctor.

View file

@ -1,12 +1,12 @@
<h2 id="monads-are-just-monoids-24">Monads are just Monoids (2/4)</h2>
<p>A Monad is a triplet \((M,⊙,η)\) s.t.</p>
<ul>
<li>\(M\) an <span class="yellow">Endofunctor</span></li>
<li>\(⊙:M×M→M\) a nat. trans. (× is functor composition)</li>
<li>\(η:I→M\) a nat. trans. (\(I\) identity functor)</li>
<li>\(M\) an <span class="yellow">Endofunctor</span> (to type <code>a</code> associate <code>M a</code>)</li>
<li>\(⊙:M×M→M\) a <span class="yellow">nat. trans.</span> (i.e. <code>⊙::M (M a) → M a</code>)</li>
<li>\(η:I→M\) a <span class="yellow">nat. trans.</span> (\(I\) identity functor ; <code>η::a → M a</code>)</li>
</ul>
<p>Satisfying</p>
<ul>
<li>\(M ⊙ (M ⊙ M)) = (M ⊙ M) ⊙ M\)</li>
<li>\(M ⊙ (M ⊙ M) = (M ⊙ M) ⊙ M\)</li>
<li>\(η ⊙ M = M = M ⊙ η\)</li>
</ul>

View file

@ -3,11 +3,11 @@ Monads are just Monoids (2/4)
A Monad is a triplet \\((M,⊙,η)\\) s.t.
- \\(M\\) an <span class="yellow">Endofunctor</span>
- \\(⊙:M×M→M\\) a nat. trans. (× is functor composition)
- \\(η:I→M\\) a nat. trans. (\\(I\\) identity functor)
- \\(M\\) an <span class="yellow">Endofunctor</span> (to type `a` associate `M a`)
- \\(⊙:M×M→M\\) a <span class="yellow">nat. trans.</span> (i.e. `⊙::M (M a) → M a`)
- \\(η:I→M\\) a <span class="yellow">nat. trans.</span> (\\(I\\) identity functor ; `η::a → M a`)
Satisfying
- \\(M ⊙ (M ⊙ M)) = (M ⊙ M) ⊙ M\\)
- \\(M ⊙ (M ⊙ M) = (M ⊙ M) ⊙ M\\)
- \\(η ⊙ M = M = M ⊙ η\\)

View file

@ -5,9 +5,9 @@
<li>\(η ⊙ M = M = M ⊙ η\)</li>
</ul>
<pre class="nohighlight small"><code>join (Just (join (Just (Just x)))) = join (join (Just (Just (Just x))))
join (Just (join (Just Nothing))) = join (join (Just (Just Nothing)))
join (Just (join Nothing)) = join (join (Just Nothing))
join Nothing = join (join Nothing)
join (Just (join (Just Nothing))) = join (join (Just (Just Nothing)))
join (Just (join Nothing)) = join (join (Just Nothing))
join Nothing = join (join Nothing)
join (η (Just x)) = Just x = Just (η x)
join (η Nothing) = Nothing = Nothing</code></pre>

View file

@ -7,9 +7,9 @@ Example: `Maybe` is a functor (`join` is ⊙)
- \\(η ⊙ M = M = M ⊙ η\\)
<pre class="nohighlight small"><code>join (Just (join (Just (Just x)))) = join (join (Just (Just (Just x))))
join (Just (join (Just Nothing))) = join (join (Just (Just Nothing)))
join (Just (join Nothing)) = join (join (Just Nothing))
join Nothing = join (join Nothing)
join (Just (join (Just Nothing))) = join (join (Just (Just Nothing)))
join (Just (join Nothing)) = join (join (Just Nothing))
join Nothing = join (join Nothing)
join (η (Just x)) = Just x = Just (η x)
join (η Nothing) = Nothing = Nothing</code></pre>

View file

@ -1,7 +1,7 @@
<h2 id="monads-utility">Monads utility</h2>
<p>A monad can also hide computation details (ex: a common parameter).</p>
<p><code>DrawScene</code> to <code><span class="yellow">State Screen</span> DrawScene</code> ; still <b>pure</b>.</p>
<pre class="haskell left small" style="width:40%"><code>main = drawImage (width,height)
<pre class="haskell left smaller" style="width:40%"><code>main = drawImage (width,height)
drawImage :: Screen -&gt; DrawScene
drawImage <span class="orange">screen</span> =
@ -12,7 +12,7 @@ drawImage <span class="orange">screen</span> =
drawPoint point <span class="orange">screen</span> = ...
drawCircle circle <span class="orange">screen</span> = ...
drawRectangle rectangle <span class="orange">screen</span> = ...</code></pre>
<pre class="haskell right small" style="width:45%"><code>main = do
<pre class="haskell right smaller" style="width:45%"><code>main = do
<span class="orange">put (Screen 1024 768)</span>
drawImage
@ -24,5 +24,5 @@ drawImage = do
drawPoint :: Point -&gt; State Screen DrawScene
drawPoint p = do
<span class="orange">Screensize width height &lt;- get</span>
<span class="orange">Screen width height &lt;- get</span>
...</code></pre>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 780 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 501 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 296 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 334 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 914 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 819 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 968 KiB

View file

@ -66,7 +66,7 @@ for fpfic in $listfic; do
print -- "[$PWD]: mpost $tmp && convert -density 300 $tmp.1 $png"
mpost --tex=latex $tmp && \
convert -colorspace rgb -density 600 $eps $png && \
convert -colorspace rgb -density 600 $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"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 328 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 KiB

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 907 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 399 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 374 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 342 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 679 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 387 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 396 KiB

View file

@ -69,16 +69,20 @@ body.deck-container {
.deck-container .blue {
color: #268bd2; }
.deck-container .backblue {
border: solid 2px #268bd2;
padding: 0 0.1em;
border: solid 2px;
border-radius: 2px;
border-color: #268bd2;
background-color: rgba(38, 139, 210, 0.2); }
.deck-container .cyan {
color: #2aa198; }
.deck-container .green {
color: #859900; }
.deck-container .backgreen {
border: solid 2px #859900;
padding: 0 0.1em;
border: solid 2px;
border-radius: 2px;
border-color: #859900;
background-color: rgba(133, 153, 0, 0.2); }
.deck-container div {
font-family: "ComputerModernSansSerif", Helvetica, sans-serif; }
@ -146,7 +150,8 @@ body.deck-container {
margin: 0.5em 0; }
.deck-container ol li ul, .deck-container ol li ol, .deck-container ul li ol, .deck-container ul li ul {
margin: 0.5em 1.5em;
list-style: none; }
list-style: none;
line-height: 1.5em; }
.deck-container body, .deck-container h1, .deck-container h2, .deck-container h3, .deck-container h4, .deck-container #entete, .deck-container .tagname {
text-rendering: optimizelegibility;
line-height: 1.5em;

View file

@ -179,6 +179,10 @@ $secondTextColor: $base1
background:
color: $base02
color: $base0
=back
padding: 0 .1em
border: solid 2px
border-radius: 2px
body.deck-container
width: 100%
@ -214,16 +218,16 @@ body.deck-container
.blue
color: $blue
.backblue
border: solid 2px $blue
border-radius: 2px
+back
border-color: $blue
background-color: rgba(38,139,210,.2)
.cyan
color: $cyan
.green
color: $green
.backgreen
border: solid 2px $green
border-radius: 2px
+back
border-color: $green
background-color: rgba(133,153,0,.2)
font-family: "ComputerModernSansSerif",Helvetica,sans-serif
@ -303,6 +307,7 @@ body.deck-container
ol li ul, ol li ol, ul li ol, ul li ul
margin: .5em 1.5em
list-style: none
line-height: 1.5em
body, h1, h2, h3, h4, #entete, .tagname