Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: b16a598f28
Fetching contributors…

Cannot retrieve contributors at this time

244 lines (233 sloc) 7.131 kB
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">
<head>
<title>Themenabend Haskell &amp; Yesod</title>
<!-- Slidy: http://www.w3.org/Talks/Tools/Slidy2/ -->
<link rel="stylesheet" type="text/css" media="screen, projection, print" href="slidy.css" />
<script src="slidy.js" charset="utf-8"
type="text/javascript"></script>
<!-- Highlighting: http://zenzike.com/posts/2010-10-14-highlighting-haskell-with-shjs -->
<link rel="stylesheet" type="text/css" href="sh_style.css" />
<script type="text/javascript" src="sh_main.js" > </script>
<script type="text/javascript" src="sh_haskell.js" > </script>
<script type="text/javascript" src="sh_init.js" > </script>
<!-- Custom style -->
<style type="text/css">
.cover {
text-align: center;
}
.speakers {
margin: 1em 0;
}
.speakers li {
list-style-type: none;
margin: 0;
padding: 0;
}
@media screen {
.note { display: none; visibility: visible }
.toolbar { display:none }
}
@media print {
.note { display: block; visibility: visible; color: red; font-size: 110%; line-height: 1.5em; }
}
</style>
</head>
<body onload="sh_highlightDocument();">
<div class="slide cover">
<h1>Themenabend Haskell &amp; Yesod</h1>
<ul class="speakers">
<li>maloi &lt;mm@noexample.de&gt;</li>
<li>Astro &lt;astro@spaceboyz.net&gt;</li>
</ul>
<p>Chaos Computer Club Dresden</p>
<p>2012-08-29</p>
</div>
<!--
Geplante Agenda, entferne was du in Folien umgesetzt hast.
* Intro: (astro) (10 min)
  * Bücher/Doku
  * Hackage/Cabal
  * Hayoo/Hoogle
-->
<!--
* Syntax, Currying, Typen, Lazyness  (astro)  (min. 30min)
-->
<div class="slide">
<h1>Syntax</h2>
</div>
<div class="slide">
<h2>Funktionen</h2>
<pre>fac :: Integer -> Integer
fac 1 = 1
fac n = n * fac (n - 1)
</pre>
<p class="note">Fakultät</p>
<p class="note">-&gt; Impliziert</p>
<p class="note">Pattern matching des Parameters</p>
<p class="note">Integer is bignum</p>
</div>
<div class="slide">
<h2>Guards</h2>
<pre>fac :: Integer -> Integer
fac n
| n &lt;= 1 = 1
| otherwise = n * fac (n - 1)
</pre>
<p class="note">Boolean expression</p>
</div>
<!--
case
if
let/where
module
-->
<div class="slide">
<h2>Currying</h2>
</div>
<!-- sections -->
<!--
* Monads, Functors, Applicatives (maloi) (30 min)
-->
<div class="slide">
<h2>Functors - Motivation</h2>
<ul class="incremental">
<li>
<p>Eine Funktion, die jeder liebt:</p>
<pre class="sh_haskell">map :: (a -> b) -> [] a -> [] b -- map :: (a -> b) -> [a] -> [b]</pre>
</li>
<li>
<p>Wie sieht so eine Funktion z.B. fuer Baeume aus?</p>
<pre class="sh_haskell">data Tree a = Leaf a | Node a (Tree a) (Tree a)</pre>
<pre class="sh_haskell">mapTree :: (a -> b) -> Tree a -> Tree b</pre>
</li>
<li>
<p>Maybe just nothing</p>
<pre class="sh_haskell">data Maybe a = Just a | Nothing</pre>
<pre class="sh_haskell">mapMaybe :: (a -> b) -> Maybe a -> Maybe b</pre>
</li>
</ul>
</div>
<div class="slide">
<h2>Functors - Motivation (2)</h2>
<ul class="incremental">
<li>
<pre class="sh_haskell">map :: (a -> b) -> [] a -> [] b</pre>
<pre class="sh_haskell">mapTree :: (a -> b) -> Tree a -> Tree b</pre>
<pre class="sh_haskell">mapMaybe :: (a -> b) -> Maybe a -> Maybe b</pre>
</li>
<li>
<p>Die Funktionen haben - bis auf Umbenennung des Typ-Konstruktors - die gleiche Signatur</p>
</li>
<li>
<p><strong>Type classes to the rescue!</strong></p>
</li>
<li>
<p>Zuvor aber ein kleiner Ausflug</p>
</li>
</ul>
</div>
<div class="slide">
<h2>Kinds: Typen von Typen - WTF?</h2>
<ul class="incremental">
<li>
<p>In Haskell hat jeder Ausdruck einen Typ</p>
</li>
<li>
<p>Diese Typen haben wiederum "Typen" - <strong>Kinds</strong></p>
</li>
<li>
<!--<p>Jeder (monomorphe) Typ (nullstelliger Typ-Konstuktor) hat Kind <strong>*</strong></p>-->
<p><strong>*</strong> ist der Kind jedes Datentyps (nullstelliger Typ-Konstruktor)</p>
<p>Diese Typen beschreiben Werte</p>
</li>
<li>
<p><strong>k1->k2</strong> ist der Kind von einstelligen Typ-Konstruktoren, die Typen von Kind <strong>k1</strong> nehmen und Typen von Kind <strong>k2</strong> erzeugen</p>
</li>
</ul>
</div>
<div class="slide">
<h2>Kinds: Beispiele</h2>
<ul class="incremental">
<li>
<p>Monomorph</p>
<pre class="sh_haskell">Int :: * -- z.B. 42</pre>
<pre class="sh_haskell">Maybe Int :: * -- z.B. Just 23</pre>
<pre class="sh_haskell">Int -> Int :: * -- z.B. (+23)</pre>
</li>
<li>
<p>Polymorph</p>
<pre class="sh_haskell">Maybe :: * -> *</pre>
<pre class="sh_haskell">(->) :: * -> *</pre>
<pre class="sh_haskell">(,,) :: * -> * -> *</pre>
</li>
<li>
<p>Lustig</p>
<pre class="sh_haskell">data Funny f a = Funny a (f a)
Funny :: (* -> *) -> * -> *</pre>
</li>
</ul>
</div>
<div class="slide">
<h2>Functors redux</h2>
<ul class="incremental">
<li>
<pre class="sh_haskell">map :: (a -> b) -> [] a -> [] b</pre>
<pre class="sh_haskell">mapTree :: (a -> b) -> Tree a -> Tree b</pre>
<pre class="sh_haskell">mapMaybe :: (a -> b) -> Maybe a -> Maybe b</pre>
</li>
<li>
<p>Zusammengefasst ergibt sich also folgendes:</p>
<pre class="sh_haskell">map :: (a -> b) -> f a -> f b</pre>
</li>
<li>
<p><strong>f</strong> ist demnach vom Kind <strong>* -> *</strong></p>
</li>
<li>
<p>Ist es moeglich die Funktion einmalig fuer alle Typen dieses Kinds schreiben?</p>
</li>
<li>
<p><strong>Nein</strong>, natuerlich nicht!</p>
</li>
</ul>
</div>
<div class="slide">
<h2>Functor - the easy type class</h2>
<ul class="incremental">
<li>
<pre class="sh_haskell">class Functor f where
fmap :: (a -> b) -> f a -> f b</pre>
</li>
<li>
<h3>Intuition<h3>
</li>
<li>
<p>Ein Functor stellt eine Art </strong>Container</strong> dar, der es ermoeglicht (mit fmap) eine Funktion (uniform) auf alle Elemente in diesem Container anzuwenden</p>
</li>
<li>
<p>Alternativ dazu kann man Functor auch als einen <strong>computational context</strong> sehen und fmap wendet eine Funktion auf einen Wert in einem Kontext an ohne diesen Kontext zu aendern</p>
</li>
</ul>
</div>
<!--
* Combinatoric Parsing: Attoparsec (astro) (15 min)
* Template Haskell (maloi) (20min)
* Profiling (astro) (15min)
* Parallel Haskell (maloi) (10min)
* Yesod:
 * Conduits (astro) (15 min)
*
 * Wai (astro) (10 min)
* Frontend, middlewares, backend (graphic)
 * Handlers & Hamlet (astro) (25 min)
* App construction
* Routing
* RESTful content
* Hamlet, Whamlet
* I18N
 * Persistent (maloi) (10min)
-->
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.