mirror of
https://github.com/ikoHSE/sc-lectures.git
synced 2024-10-03 16:37:15 +03:00
Moved to using pandoc
This commit is contained in:
parent
8be33fa9cf
commit
3edbf64504
654
.html
Normal file
654
.html
Normal file
@ -0,0 +1,654 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="generator" content="pandoc">
|
||||
<meta name="author" content="Ilya Kostyuchenko">
|
||||
<title>1</title>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
|
||||
<link rel="stylesheet" href="reveal.js/css/reset.css">
|
||||
<link rel="stylesheet" href="reveal.js/css/reveal.css">
|
||||
<style>
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
span.underline{text-decoration: underline;}
|
||||
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
||||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
||||
ul.task-list{list-style: none;}
|
||||
pre > code.sourceCode { white-space: pre; position: relative; }
|
||||
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
||||
pre > code.sourceCode > span:empty { height: 1.2em; }
|
||||
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
||||
div.sourceCode { margin: 1em 0; }
|
||||
pre.sourceCode { margin: 0; }
|
||||
@media screen {
|
||||
div.sourceCode { overflow: auto; }
|
||||
}
|
||||
@media print {
|
||||
pre > code.sourceCode { white-space: pre-wrap; }
|
||||
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
||||
}
|
||||
pre.numberSource code
|
||||
{ counter-reset: source-line 0; }
|
||||
pre.numberSource code > span
|
||||
{ position: relative; left: -4em; counter-increment: source-line; }
|
||||
pre.numberSource code > span > a:first-child::before
|
||||
{ content: counter(source-line);
|
||||
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
||||
border: none; display: inline-block;
|
||||
-webkit-touch-callout: none; -webkit-user-select: none;
|
||||
-khtml-user-select: none; -moz-user-select: none;
|
||||
-ms-user-select: none; user-select: none;
|
||||
padding: 0 4px; width: 4em;
|
||||
background-color: #232629;
|
||||
color: #7a7c7d;
|
||||
}
|
||||
pre.numberSource { margin-left: 3em; border-left: 1px solid #7a7c7d; padding-left: 4px; }
|
||||
div.sourceCode
|
||||
{ color: #cfcfc2; background-color: #232629; }
|
||||
@media screen {
|
||||
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
||||
}
|
||||
code span. { color: #cfcfc2; } /* Normal */
|
||||
code span.al { color: #95da4c; background-color: #4d1f24; font-weight: bold; } /* Alert */
|
||||
code span.an { color: #3f8058; } /* Annotation */
|
||||
code span.at { color: #2980b9; } /* Attribute */
|
||||
code span.bn { color: #f67400; } /* BaseN */
|
||||
code span.bu { color: #7f8c8d; } /* BuiltIn */
|
||||
code span.cf { color: #fdbc4b; font-weight: bold; } /* ControlFlow */
|
||||
code span.ch { color: #3daee9; } /* Char */
|
||||
code span.cn { color: #27aeae; font-weight: bold; } /* Constant */
|
||||
code span.co { color: #7a7c7d; } /* Comment */
|
||||
code span.cv { color: #7f8c8d; } /* CommentVar */
|
||||
code span.do { color: #a43340; } /* Documentation */
|
||||
code span.dt { color: #2980b9; } /* DataType */
|
||||
code span.dv { color: #f67400; } /* DecVal */
|
||||
code span.er { color: #da4453; text-decoration: underline; } /* Error */
|
||||
code span.ex { color: #0099ff; font-weight: bold; } /* Extension */
|
||||
code span.fl { color: #f67400; } /* Float */
|
||||
code span.fu { color: #8e44ad; } /* Function */
|
||||
code span.im { color: #27ae60; } /* Import */
|
||||
code span.in { color: #c45b00; } /* Information */
|
||||
code span.kw { color: #cfcfc2; font-weight: bold; } /* Keyword */
|
||||
code span.op { color: #cfcfc2; } /* Operator */
|
||||
code span.ot { color: #27ae60; } /* Other */
|
||||
code span.pp { color: #27ae60; } /* Preprocessor */
|
||||
code span.re { color: #2980b9; background-color: #153042; } /* RegionMarker */
|
||||
code span.sc { color: #3daee9; } /* SpecialChar */
|
||||
code span.ss { color: #da4453; } /* SpecialString */
|
||||
code span.st { color: #f44f4f; } /* String */
|
||||
code span.va { color: #27aeae; } /* Variable */
|
||||
code span.vs { color: #da4453; } /* VerbatimString */
|
||||
code span.wa { color: #da4453; } /* Warning */
|
||||
</style>
|
||||
<link rel="stylesheet" href="reveal.js/css/theme/superblack.css" id="theme">
|
||||
<!-- Printing and PDF exports -->
|
||||
<script>
|
||||
var link = document.createElement( 'link' );
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = window.location.search.match( /print-pdf/gi ) ? 'reveal.js/css/print/pdf.css' : 'reveal.js/css/print/paper.css';
|
||||
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
||||
</script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="reveal.js/lib/js/html5shiv.js"></script>
|
||||
<![endif]-->
|
||||
<style>
|
||||
div.sourceCode {
|
||||
background-color: transparent;
|
||||
overflow: auto;
|
||||
margin: 0em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="reveal">
|
||||
<div class="slides">
|
||||
|
||||
|
||||
<section id="функциональное-программирование" class="slide level1">
|
||||
<h1>Функциональное программирование</h1>
|
||||
<aside class="notes">
|
||||
<p>Функциональное программирование это не про использование map filter reduce. Функциональное программирование это вообще ортогонально к ооп. ИМХО проблема с ООП – наследование (которое тоже ортогонально к ООП) – нет разграничения между абстракцией и реализацией. и вообще обзывание это функциональным программированием – не совсем правильно. то, что мы сейчас будем пытаться сделать – сделать код более переиспользуемым. сделать наши данные максимально тупыми => переиспользуемыми. пытаться комбинировать слишком умные куски – не получится – слишком сложно. мы хотим сделать простые куски, которые просто комбинировать и еще чтобы компилятор проверял эти наши комбинации на валидность.</p>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<p>Функциональное программирование:</p>
|
||||
<blockquote>
|
||||
<p>функции – это тоже данные.</p>
|
||||
</blockquote>
|
||||
<p><code>Int -> Bool</code> (функция) – ровно такие же данные как и <code>Int</code>. Их также можно складывать в структуры, передавать как аргументы и т. п.</p>
|
||||
</section>
|
||||
<section id="нотация" class="slide level1">
|
||||
<h1>нотация</h1>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode java"><code class="sourceCode java"><span id="cb1-1"><a href="#cb1-1"></a> <span class="dt">int</span> x;</span></code></pre></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb2-1"><a href="#cb2-1"></a><span class="ot"> x ::</span> <span class="dt">Int</span></span></code></pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode java"><code class="sourceCode java"><span id="cb3-1"><a href="#cb3-1"></a> <span class="dt">int</span> <span class="fu">f</span>(<span class="dt">int</span> x)</span></code></pre></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb4-1"><a href="#cb4-1"></a><span class="ot"> f ::</span> <span class="dt">Int</span> <span class="ot">-></span> <span class="dt">Int</span></span></code></pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode java"><code class="sourceCode java"><span id="cb5-1"><a href="#cb5-1"></a> <span class="dt">static</span> <T> T <span class="fu">f</span>(T x)</span></code></pre></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb6-1"><a href="#cb6-1"></a><span class="ot"> f ::</span> a <span class="ot">-></span> a</span></code></pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode java"><code class="sourceCode java"><span id="cb7-1"><a href="#cb7-1"></a> <span class="dt">static</span> <T> T <span class="fu">f</span>(T x)</span></code></pre></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb8-1"><a href="#cb8-1"></a><span class="ot"> f ::</span> a <span class="ot">-></span> a</span></code></pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fragment">
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode java"><code class="sourceCode java"><span id="cb9-1"><a href="#cb9-1"></a> <span class="fu">f</span>(x);</span></code></pre></div>
|
||||
</td>
|
||||
<td class="fragment">
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb10-1"><a href="#cb10-1"></a> f x</span></code></pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode java"><code class="sourceCode java"><span id="cb11-1"><a href="#cb11-1"></a> <span class="fu">f</span>(x, y);</span></code></pre></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode fragment haskell"><code class="sourceCode haskell"><span id="cb12-1"><a href="#cb12-1"></a> f x y</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb13"><pre class="sourceCode fragment haskell"><code class="sourceCode haskell"><span id="cb13-1"><a href="#cb13-1"></a> f x y <span class="ot">=</span> (f x) y</span></code></pre></div>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<aside class="notes">
|
||||
<p>Left-associative Currying</p>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb14"><pre class="sourceCode java"><code class="sourceCode java"><span id="cb14-1"><a href="#cb14-1"></a> <span class="dt">static</span> <T> T <span class="fu">f</span>(T x)</span>
|
||||
<span id="cb14-2"><a href="#cb14-2"></a> <span class="dt">static</span> <T> T <span class="fu">g</span>(T x)</span></code></pre></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb15"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb15-1"><a href="#cb15-1"></a><span class="ot"> f ::</span> a <span class="ot">-></span> a</span>
|
||||
<span id="cb15-2"><a href="#cb15-2"></a><span class="ot"> g ::</span> a <span class="ot">-></span> a</span></code></pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb16"><pre class="sourceCode java"><code class="sourceCode java"><span id="cb16-1"><a href="#cb16-1"></a> <span class="fu">f</span>(<span class="fu">g</span>(x));</span>
|
||||
<span id="cb16-2"><a href="#cb16-2"></a> <span class="fu">g</span>(<span class="fu">f</span>(x));</span></code></pre></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb17-1"><a href="#cb17-1"></a> f (g x)</span>
|
||||
<span id="cb17-2"><a href="#cb17-2"></a> g (f x)</span></code></pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
<section id="композиция" class="slide level1">
|
||||
<h1>Композиция</h1>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<div class="sourceCode" id="cb18"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb18-1"><a href="#cb18-1"></a><span class="ot">f ::</span> a <span class="ot">-></span> a</span>
|
||||
<span id="cb18-2"><a href="#cb18-2"></a><span class="ot">g ::</span> a <span class="ot">-></span> a</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode fragment haskell"><code class="sourceCode haskell"><span id="cb19-1"><a href="#cb19-1"></a>f (g x)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode fragment haskell"><code class="sourceCode haskell"><span id="cb20-1"><a href="#cb20-1"></a>(f <span class="op">.</span> g) x <span class="op">==</span> f (g x)</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb21"><pre class="sourceCode fragment haskell"><code class="sourceCode haskell"><span id="cb21-1"><a href="#cb21-1"></a>h <span class="ot">=</span> f <span class="op">.</span> g</span>
|
||||
<span id="cb21-2"><a href="#cb21-2"></a>h x <span class="op">==</span> f (g x)</span></code></pre></div>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<div class="sourceCode" id="cb22"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb22-1"><a href="#cb22-1"></a><span class="ot">f ::</span> a <span class="ot">-></span> a</span>
|
||||
<span id="cb22-2"><a href="#cb22-2"></a><span class="ot">g ::</span> a <span class="ot">-></span> a</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb23"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb23-1"><a href="#cb23-1"></a><span class="ot">h ::</span> a <span class="ot">-></span> a</span>
|
||||
<span id="cb23-2"><a href="#cb23-2"></a>h <span class="ot">=</span> f <span class="op">.</span> g</span></code></pre></div>
|
||||
<h3 class="fragment" id="моноид" class="fragment">моноид</h3>
|
||||
<aside class="notes">
|
||||
<p>моноид – у тебя есть две штуки одного типа и ты можешь получить еще одну штуку такого же типа. Это очень простой способ рождения сложности из простоты причем тип h выводится из определения. Нам его указывать не надо. если у нас изначальные маленькие кусочки хорошо описаны, то порожденные большие кусочки будут автоматически хорошо описанными.</p>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<h2 id="моноид-1">Моноид</h2>
|
||||
<p><span class="fragment">Бинарная асоциативная операция</span></p>
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode fragment haskell"><code class="sourceCode haskell"><span id="cb24-1"><a href="#cb24-1"></a><span class="ot">(.) ::</span> (a <span class="ot">-></span> a) <span class="ot">-></span> (a <span class="ot">-></span> a) <span class="ot">-></span> (a <span class="ot">-></span> a)</span></code></pre></div>
|
||||
<p><span class="fragment">Нейтральный элемент</span></p>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode fragment haskell"><code class="sourceCode haskell"><span id="cb25-1"><a href="#cb25-1"></a><span class="fu">id</span><span class="ot"> ::</span> a <span class="ot">-></span> a</span>
|
||||
<span id="cb25-2"><a href="#cb25-2"></a><span class="fu">id</span> x <span class="ot">=</span> x</span></code></pre></div>
|
||||
</section>
|
||||
<section id="haskell" class="slide level1">
|
||||
<h1>Haskell</h1>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<h3 id="чисто-функционаьлный">Чисто функционаьлный</h3>
|
||||
<p>Все что функция может сделать – посмотреть на свои аргументы это вернуть значение.</p>
|
||||
<aside class="notes">
|
||||
<p>Нельзя просто произвольно распечатать строку в консоль, нельзя просто произвольно отправить запрос на бд, нельзя просто произвольно изменить глобальную переменную.</p>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<h3 id="referential-transparency">Referential transparency</h3>
|
||||
<h5 id="любую-константу-можно-заменить-на-само-значение">(Любую константу можно заменить на само значение)</h5>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode java fragment"><code class="sourceCode java"><span id="cb26-1"><a href="#cb26-1"></a><span class="dt">int</span> x = <span class="dv">8</span>;</span>
|
||||
<span id="cb26-2"><a href="#cb26-2"></a><span class="dt">int</span> y = x++;</span>
|
||||
<span id="cb26-3"><a href="#cb26-3"></a><span class="bu">System</span>.<span class="fu">out</span>.<span class="fu">println</span>(y + <span class="st">" might be the same as "</span> + y);</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode java fragment"><code class="sourceCode java"><span id="cb27-1"><a href="#cb27-1"></a><span class="dt">int</span> x = <span class="dv">8</span>;</span>
|
||||
<span id="cb27-2"><a href="#cb27-2"></a><span class="bu">System</span>.<span class="fu">out</span>.<span class="fu">println</span>(x++ + <span class="st">" might be the same as "</span> + x++);</span></code></pre></div>
|
||||
<aside class="notes">
|
||||
<p>Сильно упрощает рефакторинг и понимание кода.</p>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<h3 id="нет-переменных-циклов-и-условных-переходов">Нет переменных, циклов и условных переходов</h3>
|
||||
<p><span class="fragment">Зато есть константы и нормальная рекурсия (А переходов вообще нет)</span></p>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<h3 id="очень-ленивый">Очень ленивый</h3>
|
||||
<div class="sourceCode" id="cb28"><pre class="sourceCode haskell fragment"><code class="sourceCode haskell"><span id="cb28-1"><a href="#cb28-1"></a>xs <span class="ot">=</span> [<span class="dv">4</span>, <span class="dv">1</span>, <span class="dv">3</span>, <span class="dv">2</span>]</span>
|
||||
<span id="cb28-2"><a href="#cb28-2"></a>xs' <span class="ot">=</span> <span class="fu">sort</span> xs</span>
|
||||
<span id="cb28-3"><a href="#cb28-3"></a><span class="fu">print</span> xs</span></code></pre></div>
|
||||
<div class="fragment">
|
||||
<p><code>xs'</code> не нужен чтобы распечатать <code>xs</code>, поэтому сортироваться ничто не будет. (Зачем делать то, что можно не делать)</p>
|
||||
</div>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<p>Если хотите быстро и просто потыкаться, тут есть интерктивная штука:</p>
|
||||
<p><a href="https://www.haskell.org">haskell.org</a></p>
|
||||
</section>
|
||||
<section id="синтаксис" class="slide level1">
|
||||
<h1>Синтаксис</h1>
|
||||
</section>
|
||||
<section id="функции" class="slide level1">
|
||||
<h1>Функции</h1>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<div class="sourceCode" id="cb29"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb29-1"><a href="#cb29-1"></a><span class="ot">add2 ::</span> <span class="dt">Int</span> <span class="ot">-></span> <span class="dt">Int</span></span>
|
||||
<span id="cb29-2"><a href="#cb29-2"></a>add2 x <span class="ot">=</span> x <span class="op">+</span> <span class="dv">2</span></span></code></pre></div>
|
||||
<p>Все функции и константы всегда обозначаются словами с маленькой буквы без пробелов.</p>
|
||||
<p>(Константы это просто функции с нулем аргументов.)</p>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<h2 id="pattern-mathcing">Pattern mathcing</h2>
|
||||
<div class="sourceCode" id="cb30"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb30-1"><a href="#cb30-1"></a><span class="ot">fixBuz ::</span> <span class="dt">Int</span> <span class="ot">-></span> <span class="dt">String</span></span>
|
||||
<span id="cb30-2"><a href="#cb30-2"></a>divide8 <span class="dv">3</span> <span class="ot">=</span> <span class="st">"Fiz"</span></span>
|
||||
<span id="cb30-3"><a href="#cb30-3"></a>divide8 <span class="dv">5</span> <span class="ot">=</span> <span class="st">"Buz"</span></span>
|
||||
<span id="cb30-4"><a href="#cb30-4"></a>divide8 <span class="dv">15</span> <span class="ot">=</span> <span class="st">"FizBuz"</span></span>
|
||||
<span id="cb30-5"><a href="#cb30-5"></a>divide8 _ <span class="ot">=</span> <span class="st">"Some other number"</span></span></code></pre></div>
|
||||
<p>Так матчить можно произвольные структуры произвольного уровня вложенности.</p>
|
||||
<p><code>_</code> – специальное название константы, которое говорит что вам все равно что в ней лежит.</p>
|
||||
<aside class="notes">
|
||||
<p>функции объявляются в несколькро строк. Первая – обьявленик типа функции, а последубщие – реализация. В общем случае тип можно не указывать, но указывать тип у высказыванй на самом верхнем уровне (не вложенные) считается хорошим тоном и улучшает выведение типов и ошибки компиляции. У функции может быть несколько реализаций: какая из них вызовется зависит от значений передаваемых аргументов. матчинг произхводится сверху вниз. если в аргемантах написано слово с маленькой буквы, то значение аргумента биндится на эту константу.</p>
|
||||
</aside>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<h2 id="структуры">Структуры</h2>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<div class="sourceCode" id="cb31"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb31-1"><a href="#cb31-1"></a><span class="kw">data</span> <span class="dt">Foo</span> <span class="ot">=</span> <span class="dt">Bar</span></span>
|
||||
<span id="cb31-2"><a href="#cb31-2"></a><span class="ot">foo ::</span> <span class="dt">Bar</span></span>
|
||||
<span id="cb31-3"><a href="#cb31-3"></a>foo <span class="ot">=</span> <span class="dt">Bar</span></span></code></pre></div>
|
||||
<p><code>Foo</code> – тип структуры. <code>Bar</code> – конструктор структуры.</p>
|
||||
<p>Тут у <code>Foo</code> всего одно значение <code>Bar</code>.</p>
|
||||
</section>
|
||||
<section class="slide level1">
|
||||
|
||||
<h2 id="произведение-типов">Произведение типов</h2>
|
||||
<h5 id="обычные-поля-структур">(обычные поля структур)</h5>
|
||||
<aside class="notes">
|
||||
<p>После констрктора можно укзать существующие типы, которые в нем храняться.</p>
|
||||
</aside>
|
||||
<div class="sourceCode" id="cb32"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb32-1"><a href="#cb32-1"></a><span class="kw">data</span> <span class="dt">PersonType</span> <span class="ot">=</span> <span class="dt">Person</span> <span class="dt">String</span> <span class="dt">Int</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb33"><pre class="sourceCode haskell fragment"><code class="sourceCode haskell"><span id="cb33-1"><a href="#cb33-1"></a><span class="ot">vasya ::</span> <span class="dt">PersonType</span></span>
|
||||
<span id="cb33-2"><a href="#cb33-2"></a>vasya <span class="ot">=</span> <span class="dt">Person</span> <span class="st">"Vasya"</span> <span class="dv">8</span></span>
|
||||
<span id="cb33-3"><a href="#cb33-3"></a><span class="co">-- тип можно не укзывать</span></span>
|
||||
<span id="cb33-4"><a href="#cb33-4"></a>petya <span class="ot">=</span> <span class="dt">Person</span> <span class="st">"Petya"</span> <span class="dv">5</span></span></code></pre></div>
|
||||
<div class="sourceCode" id="cb34"><pre class="sourceCode haskell fragment"><code class="sourceCode haskell"><span id="cb34-1"><a href="#cb34-1"></a><span class="ot">getName ::</span> <span class="dt">PersonType</span> <span class="ot">-></span> <span class="dt">String</span></span>
|
||||
<span id="cb34-2"><a href="#cb34-2"></a>getName (<span class="dt">Person</span> name _) <span class="ot">=</span> name</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb35"><pre class="sourceCode haskell fragment"><code class="sourceCode haskell"><span id="cb35-1"><a href="#cb35-1"></a><span class="ot">greetPerson ::</span> <span class="dt">PersonType</span> <span class="ot">-></span> <span class="dt">String</span></span>
|
||||
<span id="cb35-2"><a href="#cb35-2"></a>greetPerson p <span class="ot">=</span> <span class="st">"Hello, "</span> <span class="op">++</span> getName p</span></code></pre></div>
|
||||
<div class="sourceCode" id="cb36"><pre class="sourceCode haskell fragment"><code class="sourceCode haskell"><span id="cb36-1"><a href="#cb36-1"></a>greetPerson petya</span>
|
||||
<span id="cb36-2"><a href="#cb36-2"></a><span class="co">-- "Hello, Petya"</span></span></code></pre></div>
|
||||
<h3 id="еще-немного-функций">Еще немного функций</h3>
|
||||
<pre><code>greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ getName p
|
||||
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ name
|
||||
where
|
||||
name = getName p
|
||||
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ name
|
||||
where
|
||||
getName' (Person name _) = name
|
||||
name = getName' p
|
||||
|
||||
data PersonType = Person String Int
|
||||
|
||||
getName :: PersonType -> String
|
||||
getName (Person name _) = name
|
||||
|
||||
greetName :: String -> String
|
||||
greetName name = "Hello, " ++ name
|
||||
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson p = greetName (getName p)
|
||||
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson = greetName . getName
|
||||
|
||||
greetPerson petya
|
||||
-- "Hello, Petya"
|
||||
|
||||
(greetName . getName) petya
|
||||
-- "Hello, Petya"</code></pre>
|
||||
<h3 id="суммы-типов">Суммы типов</h3>
|
||||
<p>Функции нескольких аргументов – странный синтаксис – потом расскажу.</p>
|
||||
<pre><code>data Bool = False | True
|
||||
|
||||
x :: Bool
|
||||
x = True
|
||||
y = False
|
||||
|
||||
ifThenElse :: (Bool, a, a) -> a
|
||||
|
||||
ifThenElse (True, a, _) = a
|
||||
ifThenElse (False, _, b) = b
|
||||
|
||||
ifThenElse (True, "Hello", "World")
|
||||
-- "Hello"
|
||||
|
||||
ifThenElse (False, "Hello", "World")
|
||||
-- "World"
|
||||
|
||||
data CircleType = Circle Double Double Double
|
||||
data RectangleType = Rectangle Double Double Double Double
|
||||
|
||||
data Shape =
|
||||
CircleShape CircleType | RectangleShape RectangleType
|
||||
|
||||
surface :: Shape -> Double
|
||||
|
||||
surface (CircleShape (Circle _ _ r)) =
|
||||
pi * r ^ 2
|
||||
|
||||
surface (RectangleShape (Rectangle x1 y1 x2 y2)) =
|
||||
(abs (x2 - x1)) * (abs (y2 - y1))
|
||||
|
||||
shape = CircleShape (Circle 0 0 2)
|
||||
surface shape
|
||||
-- 12.566370614359172
|
||||
|
||||
otherShape = RectangleShape (Rectangle 1 2 3 4)
|
||||
surface otherShape
|
||||
-- 4.0</code></pre>
|
||||
<h2 id="и-еще-немного-функций">И еще немного функций</h2>
|
||||
<h3 id="лямбда-выражения">Лямбда-выражения</h3>
|
||||
<pre><code>add8 :: Int -> Int
|
||||
|
||||
add8 x = x + 8
|
||||
|
||||
add8 = \x -> x + 8</code></pre>
|
||||
<p>λ – <code>\\</code> (λ печатать тяжело)</p>
|
||||
<pre><code>foo :: (Int -> Int) -> Int
|
||||
|
||||
foo add8
|
||||
|
||||
foo (\x -> x + 8)</code></pre>
|
||||
<h3 id="давайте-придумаем-синтаксис-для-функции-нескольких-аргументов">Давайте придумаем синтаксис для функции нескольких аргументов!</h3>
|
||||
<pre><code>x, y :: Int
|
||||
x = 42
|
||||
y = 69
|
||||
|
||||
xPlusY :: Int
|
||||
xPlusY = add x y</code></pre>
|
||||
<p>Применение функции – лево-ассоциативно</p>
|
||||
<pre><code>xPlusY = (add x) y
|
||||
|
||||
xPlusY = f y
|
||||
f = add x
|
||||
|
||||
f :: Int -> Int
|
||||
|
||||
add :: Int -> (Int -> Int)
|
||||
|
||||
add :: Int -> (Int -> Int)</code></pre>
|
||||
<p>Тип <code>-\></code> – право-ассоциативный</p>
|
||||
<pre><code>add :: Int -> Int -> Int
|
||||
|
||||
add a b = a + b
|
||||
|
||||
add = \a b -> a + b</code></pre>
|
||||
<p>Любая функция берет строго один аргумент.</p>
|
||||
<p>Функция нескольких аргументов все равно берет строго одтн аргумент и возвращает функцию, которая берет следйющий.</p>
|
||||
<p><em>(И из-за того, что применение функции лево-ассоциативно, вызов таких не трубует особого синтаксиса.)</em></p>
|
||||
<h3 id="currying">Currying</h3>
|
||||
<pre><code>add :: Int -> Int -> Int
|
||||
add a b = a + b
|
||||
|
||||
add8 :: Int -> Int
|
||||
|
||||
add :: Int -> (Int -> Int)
|
||||
|
||||
add8 = add 8
|
||||
|
||||
add8 3
|
||||
-- 11</code></pre>
|
||||
<h3 id="funny-fact">Funny fact</h3>
|
||||
<p>Оператор (например <code>+</code>) – функция, название которой не содержит буквы и цифры.</p>
|
||||
<pre><code>x +&+ y = x + y
|
||||
|
||||
8 +&+ 9
|
||||
-- 17</code></pre>
|
||||
<h3 id="funny-fact-2">Funny fact 2</h3>
|
||||
<p>Оператор можно превратить в функцию, окружив его скобками.</p>
|
||||
<pre><code>add :: Int -> Int -> Int
|
||||
add x y = x + y
|
||||
|
||||
add = (+&+)
|
||||
|
||||
add = (+)</code></pre>
|
||||
<h3 id="funny-fact-3">Funny fact 3</h3>
|
||||
<p>Функцию можно превратить в оператор, окружив ее обратными кавычками.</p>
|
||||
<pre><code>add :: Int -> Int -> Int
|
||||
add x y = x + y
|
||||
|
||||
add 8 9
|
||||
-- 17
|
||||
|
||||
8 `add` 9
|
||||
-- 17</code></pre>
|
||||
<h2 id="список">Список</h2>
|
||||
<h3 id="односвязный-список">Односвязный список</h3>
|
||||
<pre><code>data IntList = Cons Int IntList | Nil
|
||||
|
||||
nums :: IntList
|
||||
nums = 1 `Cons` (2 `Cons` (3 `Cons` Nil))
|
||||
|
||||
sum :: IntList -> Int
|
||||
|
||||
sum (Cons x xs) = x + sum xs
|
||||
|
||||
sum Nil = 0
|
||||
sum (Cons x xs) = x + sum xs
|
||||
|
||||
sum nums
|
||||
-- 6
|
||||
|
||||
take :: Int -> IntList -> IntList
|
||||
|
||||
take _ Nil = Nil
|
||||
take 0 _ = Nil
|
||||
take n (Cons x xs) = Cons x (take (n - 1) xs)
|
||||
|
||||
nums :: IntList
|
||||
nums = 1 `Cons` (2 `Cons` (3 `Cons` Nil))
|
||||
|
||||
take 2 nums
|
||||
-- Cons 1 (Cons 2 Nil)
|
||||
take 1029 nums
|
||||
-- Cons 1 (Cons 2 (Cons 3 Nil))
|
||||
take 0 nums
|
||||
-- Nil
|
||||
|
||||
repeat :: Int -> IntList
|
||||
|
||||
repeat n = n : (repeat n)
|
||||
|
||||
repeat 8
|
||||
-- Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (...
|
||||
|
||||
(take 3 . repeat) 8
|
||||
-- Cons 8 (Cons 8 (Cons 8 Nil))
|
||||
|
||||
(sum . take 3 . repeat) 8
|
||||
-- 24</code></pre>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col style="width: 50%" />
|
||||
<col style="width: 50%" />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td>Наша самодеятельность</td>
|
||||
<td>В стандартной библиотеке</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td><pre><code>IntList</code></pre></td>
|
||||
<td><pre><code>[Int]</code></pre></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td><pre><code>Nil</code></pre></td>
|
||||
<td><pre><code>[]</code></pre></td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td><pre><code>Cons</code></pre></td>
|
||||
<td><pre><code>:</code></pre></td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td><pre><code>Cons 3 (Cons 4 Nil)</code></pre></td>
|
||||
<td><pre class="fragment"><code>3 : 4 : []</code></pre>
|
||||
<pre class="fragment"><code>[3, 4]</code></pre></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><code>repeat</code>, <code>sum</code> и <code>take</code> тоже есть в стандартной библиотеке.</p>
|
||||
<h2 id="quicksort">QuickSort</h2>
|
||||
<pre><code>quicksort :: [Int] -> [Int]
|
||||
|
||||
quicksort (x:xs) =
|
||||
quicksort smaller ++ [x] ++ quicksort larger
|
||||
where
|
||||
smaller = filter (< x) xs
|
||||
larger = filter (>= x) xs
|
||||
|
||||
filter :: (Bool -> Int) -> [Int] -> [Int]
|
||||
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)
|
||||
|
||||
filter _ [] = []
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)
|
||||
|
||||
quicksort :: [Int] -> [Int]
|
||||
quicksort (x:xs) =
|
||||
quicksort smaller ++ [x] ++ quicksort larger
|
||||
where
|
||||
smaller = filter (< x) xs
|
||||
larger = filter (>= x) xs
|
||||
filter _ [] = []
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)
|
||||
|
||||
quicksort :: [Int] -> [Int]
|
||||
quicksort [] = []
|
||||
quicksort (x:xs) =
|
||||
quicksort smaller ++ [x] ++ quicksort larger
|
||||
where
|
||||
smaller = filter (< x) xs
|
||||
larger = filter (>= x) xs
|
||||
filter _ [] = []
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)
|
||||
|
||||
quicksort [2, 1, 3, 4]
|
||||
-- [1, 2, 3, 4]</code></pre>
|
||||
<p><code>filter</code> тоже есть в стандартной библиотеке.</p>
|
||||
<h2 id="где-и-как-смотреть-стандартную-библиотеку">Где и как смотреть "стандартную библиотеку"</h2>
|
||||
<ol type="1">
|
||||
<li class="fragment"><p><a href="https://hackage.haskell.org/package/base">Hackage</a></p>
|
||||
<p>(Там вам нужен только пакет <code>base</code>. Ссылка ведет прямо на него.) Еще если там нажать <code>s</code>, то будет поиск.</p></li>
|
||||
<li class="fragment"><p><a href="https://hoogle.haskell.org">Hoogle</a></p>
|
||||
<p>Это поиск по типам. Например: <code>Int -\> \[Int\] -\> \[Int\]</code> (Тут вам опять же нужен только пакет <code>base</code>. Нужно чтобы справа было "package:base".) –></p></li>
|
||||
</ol>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="reveal.js/js/reveal.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// Full list of configuration options available at:
|
||||
// https://github.com/hakimel/reveal.js#configuration
|
||||
Reveal.initialize({
|
||||
// Push each slide change to the browser history
|
||||
history: true,
|
||||
|
||||
// Optional reveal.js plugins
|
||||
dependencies: [
|
||||
{ src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
|
||||
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
|
||||
{ src: 'reveal.js/plugin/notes/notes.js', async: true }
|
||||
]
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
974
1.md
Normal file
974
1.md
Normal file
@ -0,0 +1,974 @@
|
||||
---
|
||||
theme: superblack
|
||||
author: Ilya Kostyuchenko
|
||||
---
|
||||
|
||||
# Функциональное программирование
|
||||
|
||||
|
||||
:::{.notes}
|
||||
Функциональное программирование это не про использование map filter
|
||||
reduce. Функциональное программирование это вообще ортогонально к ооп.
|
||||
ИМХО проблема с ООП -- наследование (которое тоже ортогонально к ООП)
|
||||
-- нет разграничения между абстракцией и реализацией. и вообще
|
||||
обзывание это функциональным программированием -- не совсем правильно.
|
||||
то, что мы сейчас будем пытаться сделать -- сделать код более
|
||||
переиспользуемым. сделать наши данные максимально тупыми =>
|
||||
переиспользуемыми. пытаться комбинировать слишком умные куски -- не
|
||||
получится -- слишком сложно. мы хотим сделать простые куски, которые
|
||||
просто комбинировать и еще чтобы компилятор проверял эти наши комбинации
|
||||
на валидность.
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
Функциональное программирование:
|
||||
|
||||
> функции -- это тоже данные.
|
||||
|
||||
`Int -> Bool` (функция) -- ровно такие же данные как и `Int`. Их также
|
||||
можно складывать в структуры, передавать как аргументы и т. п.
|
||||
|
||||
---
|
||||
|
||||
# нотация
|
||||
|
||||
---
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
```java
|
||||
int x;
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```haskell
|
||||
x :: Int
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
```java
|
||||
int f(int x)
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```haskell
|
||||
f :: Int -> Int
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
```java
|
||||
static <T> T f(T x)
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```haskell
|
||||
f :: a -> a
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
---
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
```java
|
||||
static <T> T f(T x)
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```haskell
|
||||
f :: a -> a
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fragment">
|
||||
```java
|
||||
f(x);
|
||||
```
|
||||
</td>
|
||||
<td class="fragment">
|
||||
```haskell
|
||||
f x
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
```java
|
||||
f(x, y);
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```{.fragment .haskell}
|
||||
f x y
|
||||
```
|
||||
|
||||
```{.fragment .haskell}
|
||||
f x y = (f x) y
|
||||
```
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
:::{.notes}
|
||||
Left-associative
|
||||
Currying
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
```java
|
||||
static <T> T f(T x)
|
||||
static <T> T g(T x)
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```haskell
|
||||
f :: a -> a
|
||||
g :: a -> a
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fragment">
|
||||
```java
|
||||
f(g(x));
|
||||
g(f(x));
|
||||
```
|
||||
</td>
|
||||
<td class="fragment">
|
||||
```haskell
|
||||
f (g x)
|
||||
g (f x)
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
---
|
||||
|
||||
# Композиция
|
||||
|
||||
---
|
||||
|
||||
```haskell
|
||||
f :: a -> a
|
||||
g :: a -> a
|
||||
```
|
||||
|
||||
``` {.fragment .haskell}
|
||||
f (g x)
|
||||
```
|
||||
|
||||
``` {.fragment .haskell}
|
||||
(f . g) x == f (g x)
|
||||
```
|
||||
|
||||
``` {.fragment .haskell}
|
||||
h = f . g
|
||||
h x == f (g x)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```haskell
|
||||
f :: a -> a
|
||||
g :: a -> a
|
||||
```
|
||||
|
||||
```haskell
|
||||
h :: a -> a
|
||||
h = f . g
|
||||
```
|
||||
|
||||
### моноид {#моноид .fragment}
|
||||
|
||||
:::{.notes}
|
||||
моноид -- у тебя есть две штуки одного типа и ты можешь получить еще
|
||||
одну штуку такого же типа. Это очень простой способ рождения сложности
|
||||
из простоты причем тип h выводится из определения. Нам его указывать не
|
||||
надо. если у нас изначальные маленькие кусочки хорошо описаны, то
|
||||
порожденные большие кусочки будут автоматически хорошо описанными.
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
## Моноид
|
||||
|
||||
[Бинарная асоциативная операция]{.fragment}
|
||||
|
||||
```{.fragment .haskell}
|
||||
(.) :: (a -> a) -> (a -> a) -> (a -> a)
|
||||
```
|
||||
|
||||
[Нейтральный элемент]{.fragment}
|
||||
|
||||
```{.fragment .haskell}
|
||||
id :: a -> a
|
||||
id x = x
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Haskell
|
||||
|
||||
---
|
||||
|
||||
### Чисто функционаьлный
|
||||
|
||||
Все что функция может сделать -- посмотреть на свои аргументы это
|
||||
вернуть значение.
|
||||
|
||||
:::{.notes}
|
||||
Нельзя просто произвольно распечатать строку в консоль, нельзя просто
|
||||
произвольно отправить запрос на бд, нельзя просто произвольно изменить
|
||||
глобальную переменную.
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
### Referential transparency
|
||||
|
||||
##### (Любую константу можно заменить на само значение)
|
||||
|
||||
```{.java .fragment}
|
||||
int x = 8;
|
||||
int y = x++;
|
||||
System.out.println(y + " might be the same as " + y);
|
||||
```
|
||||
|
||||
```{.java .fragment}
|
||||
int x = 8;
|
||||
System.out.println(x++ + " might be the same as " + x++);
|
||||
```
|
||||
|
||||
:::notes
|
||||
Сильно упрощает рефакторинг и понимание кода.
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
### Нет переменных, циклов и условных переходов
|
||||
|
||||
[Зато есть константы и нормальная рекурсия (А переходов вообще нет)]{.fragment}
|
||||
|
||||
---
|
||||
|
||||
### Очень ленивый
|
||||
|
||||
```{.haskell .fragment}
|
||||
xs = [4, 1, 3, 2]
|
||||
xs' = sort xs
|
||||
print xs
|
||||
```
|
||||
|
||||
:::fragment
|
||||
`xs'` не нужен чтобы распечатать `xs`, поэтому сортироваться ничто
|
||||
не будет. (Зачем делать то, что можно не делать)
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
Если хотите быстро и просто потыкаться, тут есть интерктивная штука:
|
||||
|
||||
[haskell.org](https://www.haskell.org)
|
||||
|
||||
---
|
||||
|
||||
# Синтаксис
|
||||
|
||||
---
|
||||
|
||||
# Функции
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
add2 :: Int -> Int
|
||||
add2 x = x + 2
|
||||
````
|
||||
|
||||
Все функции и константы всегда обозначаются словами с маленькой буквы
|
||||
без пробелов.
|
||||
|
||||
(Константы это просто функции с нулем аргументов.)
|
||||
|
||||
---
|
||||
|
||||
## Pattern mathcing
|
||||
|
||||
```haskell
|
||||
fixBuz :: Int -> String
|
||||
divide8 3 = "Fiz"
|
||||
divide8 5 = "Buz"
|
||||
divide8 15 = "FizBuz"
|
||||
divide8 _ = "Some other number"
|
||||
```
|
||||
|
||||
Так матчить можно произвольные структуры произвольного уровня
|
||||
вложенности.
|
||||
|
||||
`_` -- специальное название константы, которое говорит
|
||||
что вам все равно что в ней лежит.
|
||||
|
||||
:::notes
|
||||
функции объявляются в несколькро строк. Первая -- обьявленик типа
|
||||
функции, а последубщие -- реализация. В общем случае тип можно не
|
||||
указывать, но указывать тип у высказыванй на самом верхнем уровне (не
|
||||
вложенные) считается хорошим тоном и улучшает выведение типов и ошибки
|
||||
компиляции. У функции может быть несколько реализаций: какая из них
|
||||
вызовется зависит от значений передаваемых аргументов. матчинг
|
||||
произхводится сверху вниз. если в аргемантах написано слово с маленькой
|
||||
буквы, то значение аргумента биндится на эту константу.
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
## Структуры
|
||||
|
||||
---
|
||||
|
||||
```haskell
|
||||
data Foo = Bar
|
||||
foo :: Bar
|
||||
foo = Bar
|
||||
```
|
||||
|
||||
`Foo` -- тип структуры. `Bar` -- конструктор структуры.
|
||||
|
||||
Тут у `Foo` всего одно значение `Bar`.
|
||||
|
||||
---
|
||||
|
||||
## Произведение типов
|
||||
|
||||
##### (обычные поля структур)
|
||||
|
||||
:::notes
|
||||
После констрктора можно укзать существующие типы, которые в нем
|
||||
храняться.
|
||||
:::
|
||||
|
||||
```haskell
|
||||
data PersonType = Person String Int
|
||||
```
|
||||
|
||||
```{.haskell .fragment}
|
||||
vasya :: PersonType
|
||||
vasya = Person "Vasya" 8
|
||||
-- тип можно не укзывать
|
||||
petya = Person "Petya" 5
|
||||
```
|
||||
|
||||
```{.haskell .fragment}
|
||||
getName :: PersonType -> String
|
||||
getName (Person name _) = name
|
||||
```
|
||||
|
||||
```{.haskell .fragment}
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ getName p
|
||||
```
|
||||
|
||||
```{.haskell .fragment}
|
||||
greetPerson petya
|
||||
-- "Hello, Petya"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Еще немного функций
|
||||
|
||||
```{ .haskell .fragment }
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ getName p
|
||||
```
|
||||
|
||||
```{.fragment .haskell }
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ name
|
||||
where
|
||||
name = getName p
|
||||
```
|
||||
|
||||
```{.fragment .haskell }
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ name
|
||||
where
|
||||
getName' (Person name _) = name
|
||||
name = getName' p
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
data PersonType = Person String Int
|
||||
|
||||
getName :: PersonType -> String
|
||||
getName (Person name _) = name
|
||||
```
|
||||
|
||||
```{.fragment .haskell }
|
||||
greetName :: String -> String
|
||||
greetName name = "Hello, " ++ name
|
||||
```
|
||||
|
||||
```{.fragment .haskell }
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson p = greetName (getName p)
|
||||
```
|
||||
|
||||
```{.fragment .haskell }
|
||||
greetPerson :: PersonType -> String
|
||||
greetPerson = greetName . getName
|
||||
```
|
||||
|
||||
```{.fragment .haskell }
|
||||
greetPerson petya
|
||||
-- "Hello, Petya"
|
||||
```
|
||||
|
||||
```{.fragment .haskell }
|
||||
(greetName . getName) petya
|
||||
-- "Hello, Petya"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Суммы типов
|
||||
|
||||
:::notes
|
||||
Функции нескольких аргументов -- странный синтаксис -- потом расскажу. А пока используем тюпли!
|
||||
:::
|
||||
|
||||
```{ .fragment .haskell }
|
||||
data Bool = False | True
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
x :: Bool
|
||||
x = True
|
||||
y = False
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
ifThenElse :: (Bool, a, a) -> a
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
ifThenElse (True, a, _) = a
|
||||
ifThenElse (False, _, b) = b
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
ifThenElse (True, "Hello", "World")
|
||||
-- "Hello"
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
ifThenElse (False, "Hello", "World")
|
||||
-- "World"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```{ .fragment .haskell }
|
||||
data CircleType = Circle Double Double Double
|
||||
data RectangleType = Rectangle Double Double Double Double
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
data Shape =
|
||||
CircleShape CircleType | RectangleShape RectangleType
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
surface :: Shape -> Double
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
surface (CircleShape (Circle _ _ r)) =
|
||||
pi * r ^ 2
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
surface (RectangleShape (Rectangle x1 y1 x2 y2)) =
|
||||
(abs (x2 - x1)) * (abs (y2 - y1))
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
shape = CircleShape (Circle 0 0 2)
|
||||
surface shape
|
||||
-- 12.566370614359172
|
||||
```
|
||||
|
||||
```{ .fragment .haskell }
|
||||
otherShape = RectangleShape (Rectangle 1 2 3 4)
|
||||
surface otherShape
|
||||
-- 4.0
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# И еще немного функций
|
||||
|
||||
---
|
||||
|
||||
## Лямбда-выражения
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add8 :: Int -> Int
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add8 x = x + 8
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add8 = \x -> x + 8
|
||||
```
|
||||
|
||||
[λ -- `\` (λ печатать тяжело)]{.fragment}
|
||||
|
||||
```{ .haskell .fragment }
|
||||
foo :: (Int -> Int) -> Int
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
foo add8
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
foo (\x -> x + 8)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Давайте придумаем синтаксис для функции нескольких аргументов!
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
x, y :: Int
|
||||
x = 42
|
||||
y = 69
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
xPlusY :: Int
|
||||
xPlusY = add x y
|
||||
```
|
||||
|
||||
[Применение функции -- лево-ассоциативно]{.fragment}
|
||||
|
||||
```{ .haskell .fragment }
|
||||
xPlusY = (add x) y
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
xPlusY = f y
|
||||
f = add x
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
f :: Int -> Int
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add :: Int -> (Int -> Int)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
add :: Int -> (Int -> Int)
|
||||
```
|
||||
|
||||
[Тип `->` -- право-ассоциативный]{.fragment}
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add :: Int -> Int -> Int
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add a b = a + b
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add = \a b -> a + b
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Любая функция берет строго один аргумент.
|
||||
|
||||
Функция нескольких аргументов все равно берет строго одтн аргумент и
|
||||
возвращает функцию, которая берет следйющий.
|
||||
|
||||
*(И из-за того, что применение функции лево-ассоциативно, вызов таких не
|
||||
трубует особого синтаксиса.)*
|
||||
|
||||
---
|
||||
|
||||
### Currying
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add :: Int -> Int -> Int
|
||||
add a b = a + b
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add8 :: Int -> Int
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add :: Int -> (Int -> Int)
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add8 = add 8
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add8 3
|
||||
-- 11
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Funny fact
|
||||
|
||||
[Оператор (например `+`) -- функция, название которой не содержит буквы и цифры.]{.fragment}
|
||||
|
||||
```{ .haskell .fragment }
|
||||
x +&+ y = x + y
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
8 +&+ 9
|
||||
-- 17
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Funny fact 2
|
||||
|
||||
[Оператор можно превратить в функцию, окружив его скобками.]{.fragment}
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add :: Int -> Int -> Int
|
||||
add x y = x + y
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add = (+&+)
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add = (+)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Funny fact 3
|
||||
|
||||
[Функцию можно превратить в оператор, окружив ее обратными кавычками.]{.fragment}
|
||||
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add :: Int -> Int -> Int
|
||||
add x y = x + y
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
add 8 9
|
||||
-- 17
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
8 `add` 9
|
||||
-- 17
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Список
|
||||
|
||||
---
|
||||
|
||||
### Односвязный список
|
||||
|
||||
```{ .haskell .fragment }
|
||||
data IntList = Cons Int IntList | Nil
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
Cons :: Int -> IntList -> IntList
|
||||
Nil :: IntList
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
nums :: IntList
|
||||
nums = 1 `Cons` (2 `Cons` (3 `Cons` Nil))
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
sum :: IntList -> Int
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
sum (Cons x xs) = x + sum xs
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
sum Nil = 0
|
||||
sum (Cons x xs) = x + sum xs
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
sum nums
|
||||
-- 6
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
take :: Int -> IntList -> IntList
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
take _ Nil = Nil
|
||||
take 0 _ = Nil
|
||||
take n (Cons x xs) = Cons x (take (n - 1) xs)
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
nums :: IntList
|
||||
nums = 1 `Cons` (2 `Cons` (3 `Cons` Nil))
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
take 2 nums
|
||||
-- Cons 1 (Cons 2 Nil)
|
||||
take 1029 nums
|
||||
-- Cons 1 (Cons 2 (Cons 3 Nil))
|
||||
take 0 nums
|
||||
-- Nil
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
repeat :: Int -> IntList
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
repeat n = Cons n (repeat n)
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
repeat 8
|
||||
-- Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (...
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
(take 3 . repeat) 8
|
||||
-- Cons 8 (Cons 8 (Cons 8 Nil))
|
||||
```
|
||||
|
||||
```{ .haskell .fragment }
|
||||
(sum . take 3 . repeat) 8
|
||||
-- 24
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
Наша самодеятельность
|
||||
</td>
|
||||
<td>
|
||||
В стандартной библиотеке
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
```haskell
|
||||
IntList
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```haskell
|
||||
[Int]
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
```haskell
|
||||
IntList
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```haskell
|
||||
[Int]
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
```haskell
|
||||
Nil
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```haskell
|
||||
[]
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
```haskell
|
||||
Cons
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
```haskell
|
||||
:
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
```haskell
|
||||
Cons 3 (Cons 4 Nil)
|
||||
```
|
||||
</td>
|
||||
<td>
|
||||
``` {.fragment .haskell }
|
||||
3 : 4 : []
|
||||
```
|
||||
|
||||
``` {.fragment .haskell }
|
||||
[3, 4]
|
||||
```
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
---
|
||||
|
||||
`repeat`, `sum` и `take` тоже есть в стандартной библиотеке.
|
||||
|
||||
---
|
||||
|
||||
# QuickSort
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
quicksort :: [Int] -> [Int]
|
||||
```
|
||||
|
||||
```{ .haskell .fragment}
|
||||
quicksort (x:xs) =
|
||||
quicksort smaller ++ [x] ++ quicksort larger
|
||||
where
|
||||
smaller = filter (< x) xs
|
||||
larger = filter (>= x) xs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
filter :: (Bool -> Int) -> [Int] -> [Int]
|
||||
```
|
||||
|
||||
```{ .haskell .fragment}
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)
|
||||
```
|
||||
|
||||
```{ .haskell .fragment}
|
||||
filter _ [] = []
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
quicksort :: [Int] -> [Int]
|
||||
quicksort (x:xs) =
|
||||
quicksort smaller ++ [x] ++ quicksort larger
|
||||
where
|
||||
smaller = filter (< x) xs
|
||||
larger = filter (>= x) xs
|
||||
filter _ [] = []
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```{ .haskell }
|
||||
quicksort :: [Int] -> [Int]
|
||||
quicksort [] = []
|
||||
quicksort (x:xs) =
|
||||
quicksort smaller ++ [x] ++ quicksort larger
|
||||
where
|
||||
smaller = filter (< x) xs
|
||||
larger = filter (>= x) xs
|
||||
filter _ [] = []
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)
|
||||
```
|
||||
|
||||
```{ .haskell .fragment}
|
||||
quicksort [2, 1, 3, 4]
|
||||
-- [1, 2, 3, 4]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
`filter` тоже есть в стандартной библиотеке.
|
||||
|
||||
---
|
||||
|
||||
# Где и как смотреть "стандартную библиотеку"
|
||||
|
||||
---
|
||||
|
||||
1. [Hackage](https://hackage.haskell.org/package/base)
|
||||
|
||||
(Там вам нужен только пакет `base`. Ссылка ведет прямо на него.)
|
||||
Еще если там нажать `s`, то будет поиск.
|
||||
|
||||
2. [Hoogle](https://hoogle.haskell.org)
|
||||
|
||||
Это поиск по типам. Например: `Int -> [Int] -> [Int]` (Тут
|
||||
вам опять же нужен только пакет `base`. Нужно чтобы справа было
|
||||
\"package:base\".) -->
|
887
1_old.html
Normal file
887
1_old.html
Normal file
@ -0,0 +1,887 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
|
||||
<link rel="stylesheet" href="css/reset.css">
|
||||
<link rel="stylesheet" href="css/reveal.css">
|
||||
<link rel="stylesheet" href="css/theme/superblack.css">
|
||||
|
||||
<!-- Theme used for syntax highlighting of code -->
|
||||
<link rel="stylesheet" href="lib/css/monokai.css">
|
||||
|
||||
<!-- Printing and PDF exports -->
|
||||
<script>
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
|
||||
document.getElementsByTagName('head')[0].appendChild(link);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="reveal">
|
||||
<div class="slides">
|
||||
<section>
|
||||
<h2>Функциональное программирование</h2>
|
||||
<aside class="notes" data-markdown>
|
||||
Функциональное программирование это не про использование map filter reduce.
|
||||
|
||||
Функциональное программирование это вообще ортогонально к ооп.
|
||||
|
||||
ИМХО проблема с ООП -- наследование (которое тоже ортогонально к ООП) -- нет разграничения между абстракцией и
|
||||
реализацией.
|
||||
|
||||
и вообще обзывание это функциональным программированием -- не совсем правильно.
|
||||
|
||||
то, что мы сейчас будем пытаться сделать -- сделать код более переиспользуемым.
|
||||
|
||||
сделать наши данные максимально тупыми => переиспользуемыми.
|
||||
|
||||
пытаться комбинировать слишком умные куски -- не получится -- слишком сложно.
|
||||
|
||||
мы хотим сделать простые куски, которые просто комбинировать и еще чтобы компилятор проверял эти наши
|
||||
комбинации на валидность.
|
||||
</aside>
|
||||
</section>
|
||||
<section data-markdown>
|
||||
Функциональное программирование:
|
||||
> функции -- это тоже данные.
|
||||
|
||||
`Int -> Bool` (функция) -- ровно такие же данные как и `Int`. Их также можно складывать в структуры,
|
||||
передавать как аргументы и т. п.
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<section>
|
||||
<h1>нотация</h1>
|
||||
</section>
|
||||
<section>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<pre>
|
||||
<code class="java">int x;</code>
|
||||
</pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre>
|
||||
<code class="haskell">x :: Int</code>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<pre>
|
||||
<code class="java">int f(int x)</code>
|
||||
</pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre>
|
||||
<code class="haskell">f :: Int -> Int</code>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<pre>
|
||||
<code class="java">static <T> T f(T x)</code>
|
||||
</pre>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<pre>
|
||||
<code class="haskell">f :: a -> a</code>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
<section>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<pre>
|
||||
<code class="java">static <T> T f(T x)</code>
|
||||
</pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre>
|
||||
<code class="haskell">f :: a -> a</code>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fragment">
|
||||
<pre>
|
||||
<code class="java">f(x);</code>
|
||||
</pre>
|
||||
</td>
|
||||
<td class="fragment">
|
||||
<pre>
|
||||
<code class="haskell">f x</code>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<pre>
|
||||
<code class="java">f(x, y);</code>
|
||||
</pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre>
|
||||
<code class="haskell">f x y</code>
|
||||
</pre>
|
||||
<pre class="fragment">
|
||||
<code class="haskell">f x y = (f x) y</code>
|
||||
</pre>
|
||||
<aside class="notes">
|
||||
Left-associative
|
||||
Currying
|
||||
</aside>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
<section>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<pre>
|
||||
<code class="java">static <T> T f(T x)
|
||||
static <T> T g(T x)</code>
|
||||
</pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre>
|
||||
<code class="haskell">f :: a -> a
|
||||
g :: a -> a</code>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<pre>
|
||||
<code class="java">f(g(x));
|
||||
g(f(x));</code>
|
||||
</pre>
|
||||
</td>
|
||||
<td class="fragment">
|
||||
<pre>
|
||||
<code class="haskell">f (g x)
|
||||
g (f x)</code>
|
||||
</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<section>
|
||||
<h1>
|
||||
Композиция
|
||||
</h1>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">f :: a -> a
|
||||
g :: a -> a</code></pre>
|
||||
<pre class="fragment"><code class="haskell">f (g x)</code></pre>
|
||||
<pre class="fragment"><code class="haskell">(f . g) x == f (g x)</code></pre>
|
||||
<pre class="fragment"><code class="haskell">h = f . g
|
||||
h x == f (g x)</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">f :: a -> a
|
||||
g :: a -> a
|
||||
|
||||
h :: a -> a
|
||||
h = f . g</code></pre>
|
||||
|
||||
<h3 class="fragment">моноид</h3>
|
||||
|
||||
<aside class="notes" data-markdown>
|
||||
моноид -- у тебя есть две штуки одного типа и ты можешь получить еще одну
|
||||
штуку такого же
|
||||
типа.
|
||||
|
||||
Это очень простой способ рождения сложности из простоты
|
||||
|
||||
причем тип h выводится из определения. Нам его указывать не надо.
|
||||
|
||||
если у нас изначальные маленькие кусочки хорошо описаны, то порожденные большие кусочки будут автоматически
|
||||
хорошо описанными.
|
||||
</aside>
|
||||
</section>
|
||||
<section>
|
||||
<h3>
|
||||
Моноид
|
||||
</h3>
|
||||
|
||||
<p class="fragment">
|
||||
Бинарная асоциативная операция
|
||||
</p>
|
||||
|
||||
<pre><code class="haskell fragment">(.) :: (a -> a) -> (a -> a) -> (a -> a)</code></pre>
|
||||
|
||||
<p class="fragment">
|
||||
Нейтральный элемент
|
||||
</p>
|
||||
|
||||
<pre><code class="haskell fragment">id :: a -> a
|
||||
id x = x</code></pre>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<section>
|
||||
<h2>Haskell</h2>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Чисто функционаьлный</h3>
|
||||
<p class="fragment" data-markdown>Все что функция может сделать -- посмотреть на свои аргументы это вернуть
|
||||
значение.</p>
|
||||
<aside class="notes" data-markdown>Нельзя просто произвольно распечатать строку в консоль, нельзя просто
|
||||
произвольно
|
||||
отправить запрос на бд, нельзя просто произвольно изменить глобальную переменную.</aside>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Referential transparency</h3>
|
||||
<h5>(Любую константу можно заменить на само значение)</h5>
|
||||
<pre><code class="java fragment">int x = 8;
|
||||
int y = x++;
|
||||
System.out.println(y + " might be the same as " + y);</code></pre>
|
||||
<pre><code class="java fragment">int x = 8;
|
||||
System.out.println(x++ + " might be the same as " + x++);</code></pre>
|
||||
|
||||
<aside class="notes" data-markdown>Сильно упрощает рефакторинг и понимание кода.</aside>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Нет переменных, циклов и условных переходов</h3>
|
||||
|
||||
<p class="fragment" data-markdown>
|
||||
Зато есть константы и нормальная рекурсия
|
||||
|
||||
(А переходов вообще нет)
|
||||
</p>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Очень ленивый</h3>
|
||||
|
||||
<pre><code class="haskell fragment">xs = [4, 1, 3, 2]
|
||||
xs' = sort xs
|
||||
print xs</code></pre>
|
||||
|
||||
<p class="fragment" data-markdown>
|
||||
`xs'` не нужен чтобы распечатать `xs`, поэтому сортироваться ничто не будет.
|
||||
|
||||
(Зачем делать то, что можно не делать)
|
||||
</p>
|
||||
</section>
|
||||
<section>
|
||||
<p>Если хотите быстро и просто потыкаться, тут есть интерктивная штука:</p>
|
||||
<a href="https://www.haskell.org">haskell.org</a>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Синтаксис</h2>
|
||||
</section>
|
||||
<section>
|
||||
<section>
|
||||
<h2>Функции</h2>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">add2 :: Int -> Int
|
||||
add2 x = x + 2</code></pre>
|
||||
<p>Все функции и константы всегда обозначаются словами с маленькой буквы без пробелов.</p>
|
||||
<p>(Константы это просто функции с нулем аргументов.)</p>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Pattern mathcing</h3>
|
||||
<pre><code class="haskell">fixBuz :: Int -> String
|
||||
divide8 3 = "Fiz"
|
||||
divide8 5 = "Buz"
|
||||
divide8 15 = "FizBuz"
|
||||
divide8 _ = "Some other number"</code></pre>
|
||||
|
||||
<p data-markdown>
|
||||
Так матчить можно произвольные структуры произвольного уровня вложенности.
|
||||
|
||||
`_` -- специальное название константы, которое говорит что вам все равно что в ней лежит.
|
||||
</p>
|
||||
<aside class="notes" data-markdown>
|
||||
функции объявляются в несколькро строк. Первая -- обьявленик типа функции,
|
||||
а последубщие -- реализация. В общем случае тип можно не указывать, но указывать тип у высказыванй на самом
|
||||
верхнем уровне (не вложенные) считается хорошим тоном и улучшает выведение типов и ошибки компиляции.
|
||||
|
||||
У функции может быть несколько реализаций: какая из них вызовется зависит от значений передаваемых
|
||||
аргументов. матчинг произхводится сверху вниз.
|
||||
|
||||
если в аргемантах написано слово с маленькой буквы, то значение аргумента биндится на эту константу.
|
||||
</aside>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<section>
|
||||
<h2>Структуры</h2>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">data Foo = Bar
|
||||
foo :: Bar
|
||||
foo = Bar</code></pre>
|
||||
|
||||
<p data-markdown>
|
||||
`Foo` -- тип структуры. `Bar` -- конструктор структуры.
|
||||
|
||||
Тут у `Foo` всего одно значение `Bar`.
|
||||
</p>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Произведение типов</h3>
|
||||
<h5>(обычные поля структур)</h5>
|
||||
<aside class="notes" data-markdown>
|
||||
После констрктора можно укзать существующие типы, которые в нем храняться.
|
||||
</aside>
|
||||
|
||||
<pre><code class="haskell">data PersonType = Person String Int</code></pre>
|
||||
<pre><code class="haskell fragment">vasya :: PersonType
|
||||
vasya = Person "Vasya" 8
|
||||
-- тип можно не укзывать
|
||||
petya = Person "Petya" 5</code></pre>
|
||||
<pre><code class="haskell fragment">getName :: PersonType -> String
|
||||
getName (Person name _) = name</code></pre>
|
||||
<pre><code class="haskell fragment">greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ getName p</code></pre>
|
||||
<pre><code class="haskell fragment">greetPerson petya
|
||||
-- "Hello, Petya"</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Еще немного функций</h3>
|
||||
<pre><code class="haskell fragment">greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ getName p</code></pre>
|
||||
|
||||
<pre><code class="haskell fragment">greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ name
|
||||
where
|
||||
name = getName p</code></pre>
|
||||
<pre><code class="haskell fragment">greetPerson :: PersonType -> String
|
||||
greetPerson p = "Hello, " ++ name
|
||||
where
|
||||
getName' (Person name _) = name
|
||||
name = getName' p</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">data PersonType = Person String Int
|
||||
|
||||
getName :: PersonType -> String
|
||||
getName (Person name _) = name</code></pre>
|
||||
<pre><code class="haskell fragment">greetName :: String -> String
|
||||
greetName name = "Hello, " ++ name</code></pre>
|
||||
<pre><code class="haskell fragment">greetPerson :: PersonType -> String
|
||||
greetPerson p = greetName (getName p)</code></pre>
|
||||
<pre><code class="haskell fragment">greetPerson :: PersonType -> String
|
||||
greetPerson = greetName . getName</code></pre>
|
||||
<pre><code class="haskell fragment">greetPerson petya
|
||||
-- "Hello, Petya"</code></pre>
|
||||
<pre><code class="haskell fragment">(greetName . getName) petya
|
||||
-- "Hello, Petya"</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Суммы типов</h3>
|
||||
<aside class="notes" data-markdown>
|
||||
Функции нескольких аргументов -- странный синтаксис -- потом расскажу.
|
||||
</aside>
|
||||
|
||||
<pre><code class="haskell fragment">data Bool = False | True</code></pre>
|
||||
<pre><code class="haskell fragment">x :: Bool
|
||||
x = True
|
||||
y = False</code></pre>
|
||||
|
||||
<pre><code class="haskell fragment">ifThenElse :: (Bool, a, a) -> a</code></pre>
|
||||
<pre><code class="haskell fragment">ifThenElse (True, a, _) = a
|
||||
ifThenElse (False, _, b) = b</code></pre>
|
||||
<pre><code class="haskell fragment">ifThenElse (True, "Hello", "World")
|
||||
-- "Hello"</code></pre>
|
||||
|
||||
<pre><code class="haskell fragment">ifThenElse (False, "Hello", "World")
|
||||
-- "World"</code></pre>
|
||||
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">data CircleType = Circle Double Double Double
|
||||
data RectangleType = Rectangle Double Double Double Double
|
||||
</code></pre>
|
||||
<pre><code class="haskell fragment">data Shape =
|
||||
CircleShape CircleType | RectangleShape RectangleType</code></pre>
|
||||
<pre><code class="haskell fragment">surface :: Shape -> Double</code></pre>
|
||||
<pre><code class="haskell fragment">surface (CircleShape (Circle _ _ r)) =
|
||||
pi * r ^ 2</code></pre>
|
||||
<pre><code class="haskell fragment">surface (RectangleShape (Rectangle x1 y1 x2 y2)) =
|
||||
(abs (x2 - x1)) * (abs (y2 - y1))</code></pre>
|
||||
<pre><code class="haskell fragment">shape = CircleShape (Circle 0 0 2)
|
||||
surface shape
|
||||
-- 12.566370614359172
|
||||
</code></pre>
|
||||
<pre><code class="haskell fragment">otherShape = RectangleShape (Rectangle 1 2 3 4)
|
||||
surface otherShape
|
||||
-- 4.0
|
||||
</code></pre>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<section>
|
||||
<h2>И еще немного функций</h2>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Лямбда-выражения</h3>
|
||||
|
||||
<pre><code class="haskell fragment">add8 :: Int -> Int</code></pre>
|
||||
<pre><code class="haskell fragment">add8 x = x + 8</code></pre>
|
||||
<pre><code class="haskell fragment">add8 = \x -> x + 8</code></pre>
|
||||
<p data-markdown class="fragment">
|
||||
λ -- `\`
|
||||
|
||||
(λ печатать тяжело)</p>
|
||||
|
||||
<pre><code class="haskell fragment">foo :: (Int -> Int) -> Int</code></pre>
|
||||
<pre><code class="haskell fragment">foo add8</code></pre>
|
||||
<pre><code class="haskell fragment">foo (\x -> x + 8)</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Давайте придумаем синтаксис для функции нескольких аргументов!</h3>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">x, y :: Int
|
||||
x = 42
|
||||
y = 69
|
||||
</code></pre>
|
||||
|
||||
<pre><code class="haskell fragment">xPlusY :: Int
|
||||
xPlusY = add x y</code></pre>
|
||||
<p class="fragment" data-markdown>Применение функции -- лево-ассоциативно</p>
|
||||
<pre><code class="haskell fragment">xPlusY = (add x) y</code></pre>
|
||||
<pre><code class="haskell fragment">xPlusY = f y
|
||||
f = add x</code></pre>
|
||||
<pre><code class="haskell fragment">f :: Int -> Int</code></pre>
|
||||
<pre><code class="haskell fragment">add :: Int -> (Int -> Int)</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">add :: Int -> (Int -> Int)</code></pre>
|
||||
<p class="fragment" data-markdown>Тип `->` -- право-ассоциативный</p>
|
||||
|
||||
<pre><code class="haskell fragment">add :: Int -> Int -> Int</code></pre>
|
||||
<pre><code class="haskell fragment">add a b = a + b</code></pre>
|
||||
<pre><code class="haskell fragment">add = \a b -> a + b</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<p>Любая функция берет строго один аргумент.</p>
|
||||
|
||||
<p>Функция нескольких аргументов все равно берет строго одтн аргумент и возвращает функцию, которая берет
|
||||
следйющий.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<em>
|
||||
(И из-за того, что применение функции лево-ассоциативно, вызов таких не трубует особого
|
||||
синтаксиса.)
|
||||
</em>
|
||||
</p>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Currying</h3>
|
||||
<pre><code class="haskell fragment">add :: Int -> Int -> Int
|
||||
add a b = a + b</code></pre>
|
||||
|
||||
<pre><code class="haskell fragment">add8 :: Int -> Int</code></pre>
|
||||
<pre><code class="haskell fragment">add :: Int -> (Int -> Int)</code></pre>
|
||||
<pre><code class="haskell fragment">add8 = add 8</code></pre>
|
||||
<pre><code class="haskell fragment">add8 3
|
||||
-- 11</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Funny fact</h3>
|
||||
|
||||
<p class="fragment" data-markdown>Оператор (например `+`) -- функция, название которой не содержит буквы и
|
||||
цифры.</p>
|
||||
<pre><code class="haskell fragment">x +&+ y = x + y</code></pre>
|
||||
<pre><code class="haskell fragment">8 +&+ 9
|
||||
-- 17</code></pre>
|
||||
|
||||
</section>
|
||||
<section>
|
||||
<h3>Funny fact 2</h3>
|
||||
|
||||
<p class="fragment" data-markdown>Оператор можно превратить в функцию, окружив его скобками.</p>
|
||||
<pre><code class="haskell fragment">add :: Int -> Int -> Int
|
||||
add x y = x + y</code></pre>
|
||||
<pre><code class="haskell fragment">add = (+&+)</code></pre>
|
||||
<pre><code class="haskell fragment">add = (+)</code></pre>
|
||||
|
||||
</section>
|
||||
<section>
|
||||
<h3>Funny fact 3</h3>
|
||||
|
||||
<p class="fragment" data-markdown>Функцию можно превратить в оператор, окружив ее обратными кавычками.</p>
|
||||
<pre><code class="haskell fragment">add :: Int -> Int -> Int
|
||||
add x y = x + y</code></pre>
|
||||
<pre><code class="haskell fragment">add 8 9
|
||||
-- 17</code></pre>
|
||||
<pre><code class="haskell fragment">8 `add` 9
|
||||
-- 17</code></pre>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<section>
|
||||
<h2>Список</h2>
|
||||
</section>
|
||||
<section>
|
||||
<h3>Односвязный список</h3>
|
||||
<pre><code class="haskell fragment">data IntList = Cons Int IntList | Nil</code></pre>
|
||||
<pre><code class="haskell fragment">nums :: IntList
|
||||
nums = 1 `Cons` (2 `Cons` (3 `Cons` Nil))</code></pre>
|
||||
<pre><code class="haskell fragment">sum :: IntList -> Int</code></pre>
|
||||
<pre><code class="haskell fragment">sum (Cons x xs) = x + sum xs</code></pre>
|
||||
<pre><code class="haskell fragment">sum Nil = 0
|
||||
sum (Cons x xs) = x + sum xs</code></pre>
|
||||
<pre><code class="haskell fragment">sum nums
|
||||
-- 6</code></pre>
|
||||
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">take :: Int -> IntList -> IntList</code></pre>
|
||||
<pre><code class="haskell fragment">take _ Nil = Nil
|
||||
take 0 _ = Nil
|
||||
take n (Cons x xs) = Cons x (take (n - 1) xs)</code></pre>
|
||||
<pre><code class="haskell fragment">nums :: IntList
|
||||
nums = 1 `Cons` (2 `Cons` (3 `Cons` Nil))</code></pre>
|
||||
<pre><code class="haskell fragment">take 2 nums
|
||||
-- Cons 1 (Cons 2 Nil)
|
||||
take 1029 nums
|
||||
-- Cons 1 (Cons 2 (Cons 3 Nil))
|
||||
take 0 nums
|
||||
-- Nil</code></pre>
|
||||
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">repeat :: Int -> IntList</code></pre>
|
||||
<pre><code class="haskell fragment">repeat n = n : (repeat n)</code></pre>
|
||||
<pre><code class="haskell fragment">repeat 8
|
||||
-- Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (Cons 8 (...</code></pre>
|
||||
<pre><code class="haskell fragment">(take 3 . repeat) 8
|
||||
-- Cons 8 (Cons 8 (Cons 8 Nil))</code></pre>
|
||||
<pre><code class="haskell fragment">(sum . take 3 . repeat) 8
|
||||
-- 24</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Наша самодеятельность</td>
|
||||
<td>В стандартной библиотеке</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<pre><code class="haskell">IntList</code></pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre><code class="haskell">[Int]</code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<pre><code class="haskell">Nil</code></pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre><code class="haskell">[]</code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<pre><code class="haskell">Cons</code></pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre><code class="haskell">:</code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fragment">
|
||||
<td>
|
||||
<pre><code class="haskell">Cons 3 (Cons 4 Nil)</code></pre>
|
||||
</td>
|
||||
<td>
|
||||
<pre class="fragment"><code class="haskell">3 : 4 : []</code></pre>
|
||||
<pre class="fragment"><code class="haskell">[3, 4]</code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
<section>
|
||||
<p data-markdown>`repeat`, `sum` и `take` тоже есть в стандартной библиотеке.</p>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<section>
|
||||
<h2>QuickSort</h2>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">quicksort :: [Int] -> [Int]</code></pre>
|
||||
|
||||
<pre><code class="haskell fragment">quicksort (x:xs) =
|
||||
quicksort smaller ++ [x] ++ quicksort larger
|
||||
where
|
||||
smaller = filter (< x) xs
|
||||
larger = filter (>= x) xs</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">filter :: (Bool -> Int) -> [Int] -> [Int]</code></pre>
|
||||
<pre><code class="haskell fragment">filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)</code></pre>
|
||||
<pre><code class="haskell fragment">filter _ [] = []
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">quicksort :: [Int] -> [Int]
|
||||
quicksort (x:xs) =
|
||||
quicksort smaller ++ [x] ++ quicksort larger
|
||||
where
|
||||
smaller = filter (< x) xs
|
||||
larger = filter (>= x) xs
|
||||
filter _ [] = []
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<pre><code class="haskell">quicksort :: [Int] -> [Int]
|
||||
quicksort [] = []
|
||||
quicksort (x:xs) =
|
||||
quicksort smaller ++ [x] ++ quicksort larger
|
||||
where
|
||||
smaller = filter (< x) xs
|
||||
larger = filter (>= x) xs
|
||||
filter _ [] = []
|
||||
filter f (x:xs) =
|
||||
if f x
|
||||
then filter f xs
|
||||
else x:(filter f xs)</code></pre>
|
||||
<pre><code class="haskell fragment">quicksort [2, 1, 3, 4]
|
||||
-- [1, 2, 3, 4]</code></pre>
|
||||
</section>
|
||||
<section>
|
||||
<p data-markdown>`filter` тоже есть в стандартной библиотеке.</p>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<section>
|
||||
<h2>Где и как смотреть "стандартную библиотеку"</h2>
|
||||
</section>
|
||||
<section>
|
||||
<ol>
|
||||
<li>
|
||||
<a href="https://hackage.haskell.org/package/base">Hackage</a>
|
||||
|
||||
<p data-markdown>
|
||||
(Там вам нужен только пакет `base`. Ссылка ведет прямо на него.)
|
||||
|
||||
Еще если там нажать `s`, то будет поиск.
|
||||
</p>
|
||||
</li>
|
||||
<li class="fragment">
|
||||
<a href="https://hoogle.haskell.org">Hoogle</a>
|
||||
|
||||
<p data-markdown>
|
||||
Это поиск по типам.
|
||||
|
||||
Например: `Int -> [Int] -> [Int]`
|
||||
|
||||
(Тут вам опять же нужен только пакет `base`. Нужно чтобы справа было "package:base".)
|
||||
|
||||
</p>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="./js/reveal.js"></script>
|
||||
|
||||
<script>
|
||||
// More info about config & dependencies:
|
||||
// - https://github.com/hakimel/reveal.js#configuration
|
||||
// - https://github.com/hakimel/reveal.js#dependencies
|
||||
Reveal.initialize({
|
||||
|
||||
// Displaнес presentation control arrows
|
||||
controls: true,
|
||||
|
||||
// Help the user learn the controls by providing hints, for example by
|
||||
// bouncing the down arrow when they first encounter a vertical slide
|
||||
controlsTutorial: true,
|
||||
|
||||
// Determines where controls appear, "edges" or "bottom-right"
|
||||
controlsLayout: 'bottom-right',
|
||||
|
||||
// Visibility rule for backwards navigation arrows; "faded", "hidden"
|
||||
// or "visible"
|
||||
controlsBackArrows: 'faded',
|
||||
|
||||
// Display a presentation progress bar
|
||||
progress: true,
|
||||
|
||||
// Display the page number of the current slide
|
||||
slideNumber: false,
|
||||
|
||||
// Add the current slide number to the URL hash so that reloading the
|
||||
// page/copying the URL will return you to the same slide
|
||||
hash: true,
|
||||
|
||||
// Push each slide change to the browser history. Implies `hash: true`
|
||||
history: false,
|
||||
|
||||
// Enable keyboard shortcuts for navigation
|
||||
keyboard: true,
|
||||
|
||||
// Enable the slide overview mode
|
||||
overview: true,
|
||||
|
||||
// Vertical centering of slides
|
||||
center: true,
|
||||
|
||||
// Enables touch navigation on devices with touch input
|
||||
touch: true,
|
||||
|
||||
// Loop the presentation
|
||||
loop: false,
|
||||
|
||||
// Change the presentation direction to be RTL
|
||||
rtl: false,
|
||||
|
||||
// See https://github.com/hakimel/reveal.js/#navigation-mode
|
||||
navigationMode: 'linear',
|
||||
|
||||
// Randomizes the order of slides each time the presentation loads
|
||||
shuffle: false,
|
||||
|
||||
// Turns fragments on and off globally
|
||||
fragments: true,
|
||||
|
||||
// Flags whether to include the current fragment in the URL,
|
||||
// so that reloading brings you to the same fragment position
|
||||
fragmentInURL: true,
|
||||
|
||||
// Flags if the presentation is running in an embedded mode,
|
||||
// i.e. contained within a limited portion of the screen
|
||||
embedded: false,
|
||||
|
||||
// Flags if we should show a help overlay when the questionmark
|
||||
// key is pressed
|
||||
help: true,
|
||||
|
||||
// Flags if speaker notes should be visible to all viewers
|
||||
showNotes: false,
|
||||
|
||||
// Global override for autoplaying embedded media (video/audio/iframe)
|
||||
// - null: Media will only autoplay if data-autoplay is present
|
||||
// - true: All media will autoplay, regardless of individual setting
|
||||
// - false: No media will autoplay, regardless of individual setting
|
||||
autoPlayMedia: null,
|
||||
|
||||
// Global override for preloading lazy-loaded iframes
|
||||
// - null: Iframes with data-src AND data-preload will be loaded when within
|
||||
// the viewDistance, iframes with only data-src will be loaded when visible
|
||||
// - true: All iframes with data-src will be loaded when within the viewDistance
|
||||
// - false: All iframes with data-src will be loaded only when visible
|
||||
preloadIframes: null,
|
||||
|
||||
// Number of milliseconds between automatically proceeding to the
|
||||
// next slide, disabled when set to 0, this value can be overwritten
|
||||
// by using a data-autoslide attribute on your slides
|
||||
autoSlide: 0,
|
||||
|
||||
// Stop auto-sliding after user input
|
||||
autoSlideStoppable: true,
|
||||
|
||||
// Use this method for navigation when auto-sliding
|
||||
autoSlideMethod: Reveal.navigateNext,
|
||||
|
||||
// Specify the average time in seconds that you think you will spend
|
||||
// presenting each slide. This is used to show a pacing timer in the
|
||||
// speaker view
|
||||
defaultTiming: 120,
|
||||
|
||||
// Enable slide navigation via mouse wheel
|
||||
mouseWheel: false,
|
||||
|
||||
// Hide cursor if inactive
|
||||
hideInactiveCursor: true,
|
||||
|
||||
// Time before the cursor is hidden (in ms)
|
||||
hideCursorTime: 5000,
|
||||
|
||||
// Hides the address bar on mobile devices
|
||||
hideAddressBar: true,
|
||||
|
||||
// Opens links in an iframe preview overlay
|
||||
// Add `data-preview-link` and `data-preview-link="false"` to customise each link
|
||||
// individually
|
||||
previewLinks: false,
|
||||
|
||||
// Transition style
|
||||
transition: 'slide', // none/fade/slide/convex/concave/zoom
|
||||
|
||||
// Transition speed
|
||||
transitionSpeed: 'default', // default/fast/slow
|
||||
|
||||
// Transition style for full page slide backgrounds
|
||||
backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom
|
||||
|
||||
// Number of slides away from the current that are visible
|
||||
viewDistance: 3,
|
||||
|
||||
// Parallax background image
|
||||
parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'"
|
||||
|
||||
// Parallax background size
|
||||
parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px"
|
||||
|
||||
// Number of pixels to move the parallax background per slide
|
||||
// - Calculated automatically unless specified
|
||||
// - Set to 0 to disable movement along an axis
|
||||
parallaxBackgroundHorizontal: null,
|
||||
parallaxBackgroundVertical: null,
|
||||
|
||||
// The display mode that will be used to show slides
|
||||
display: 'block',
|
||||
|
||||
pdfSeparateFragments: false,
|
||||
|
||||
defaultTiming: null,
|
||||
|
||||
markdown: {
|
||||
smartypants: true
|
||||
},
|
||||
|
||||
|
||||
dependencies: [
|
||||
{ src: './plugin/markdown/marked.js' },
|
||||
{ src: './plugin/markdown/markdown.js' },
|
||||
{ src: './plugin/zoom-js/zoom.js', async: true },
|
||||
{ src: './plugin/notes/notes.js', async: true },
|
||||
{ src: './plugin/highlight/highlight.js', async: true }
|
||||
]
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
7
build.sh
Executable file
7
build.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
for file in *.md
|
||||
do
|
||||
base=$(basename $file .md)
|
||||
pandoc -i $file -t revealjs -s --highlight-style=breezeDark --include-in-header=style.html >"$base.html"
|
||||
done
|
@ -39,22 +39,18 @@ body {
|
||||
opacity: 1;
|
||||
visibility: inherit; }
|
||||
.reveal .slides section .fragment.grow.visible {
|
||||
-webkit-transform: scale(1.3);
|
||||
transform: scale(1.3); }
|
||||
transform: scale(1.3); }
|
||||
|
||||
.reveal .slides section .fragment.shrink {
|
||||
opacity: 1;
|
||||
visibility: inherit; }
|
||||
.reveal .slides section .fragment.shrink.visible {
|
||||
-webkit-transform: scale(0.7);
|
||||
transform: scale(0.7); }
|
||||
transform: scale(0.7); }
|
||||
|
||||
.reveal .slides section .fragment.zoom-in {
|
||||
-webkit-transform: scale(0.1);
|
||||
transform: scale(0.1); }
|
||||
transform: scale(0.1); }
|
||||
.reveal .slides section .fragment.zoom-in.visible {
|
||||
-webkit-transform: none;
|
||||
transform: none; }
|
||||
transform: none; }
|
||||
|
||||
.reveal .slides section .fragment.fade-out {
|
||||
opacity: 1;
|
||||
@ -77,32 +73,24 @@ body {
|
||||
text-decoration: line-through; }
|
||||
|
||||
.reveal .slides section .fragment.fade-up {
|
||||
-webkit-transform: translate(0, 20%);
|
||||
transform: translate(0, 20%); }
|
||||
transform: translate(0, 40px); }
|
||||
.reveal .slides section .fragment.fade-up.visible {
|
||||
-webkit-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
transform: translate(0, 0); }
|
||||
|
||||
.reveal .slides section .fragment.fade-down {
|
||||
-webkit-transform: translate(0, -20%);
|
||||
transform: translate(0, -20%); }
|
||||
transform: translate(0, -40px); }
|
||||
.reveal .slides section .fragment.fade-down.visible {
|
||||
-webkit-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
transform: translate(0, 0); }
|
||||
|
||||
.reveal .slides section .fragment.fade-right {
|
||||
-webkit-transform: translate(-20%, 0);
|
||||
transform: translate(-20%, 0); }
|
||||
transform: translate(-40px, 0); }
|
||||
.reveal .slides section .fragment.fade-right.visible {
|
||||
-webkit-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
transform: translate(0, 0); }
|
||||
|
||||
.reveal .slides section .fragment.fade-left {
|
||||
-webkit-transform: translate(20%, 0);
|
||||
transform: translate(20%, 0); }
|
||||
transform: translate(40px, 0); }
|
||||
.reveal .slides section .fragment.fade-left.visible {
|
||||
-webkit-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
transform: translate(0, 0); }
|
||||
|
||||
.reveal .slides section .fragment.fade-in-then-out,
|
||||
.reveal .slides section .fragment.current-visible {
|
||||
@ -177,48 +165,21 @@ body {
|
||||
/*********************************************
|
||||
* CONTROLS
|
||||
*********************************************/
|
||||
@-webkit-keyframes bounce-right {
|
||||
0%, 10%, 25%, 40%, 50% {
|
||||
-webkit-transform: translateX(0);
|
||||
transform: translateX(0); }
|
||||
20% {
|
||||
-webkit-transform: translateX(10px);
|
||||
transform: translateX(10px); }
|
||||
30% {
|
||||
-webkit-transform: translateX(-5px);
|
||||
transform: translateX(-5px); } }
|
||||
@keyframes bounce-right {
|
||||
0%, 10%, 25%, 40%, 50% {
|
||||
-webkit-transform: translateX(0);
|
||||
transform: translateX(0); }
|
||||
transform: translateX(0); }
|
||||
20% {
|
||||
-webkit-transform: translateX(10px);
|
||||
transform: translateX(10px); }
|
||||
transform: translateX(10px); }
|
||||
30% {
|
||||
-webkit-transform: translateX(-5px);
|
||||
transform: translateX(-5px); } }
|
||||
|
||||
@-webkit-keyframes bounce-down {
|
||||
0%, 10%, 25%, 40%, 50% {
|
||||
-webkit-transform: translateY(0);
|
||||
transform: translateY(0); }
|
||||
20% {
|
||||
-webkit-transform: translateY(10px);
|
||||
transform: translateY(10px); }
|
||||
30% {
|
||||
-webkit-transform: translateY(-5px);
|
||||
transform: translateY(-5px); } }
|
||||
transform: translateX(-5px); } }
|
||||
|
||||
@keyframes bounce-down {
|
||||
0%, 10%, 25%, 40%, 50% {
|
||||
-webkit-transform: translateY(0);
|
||||
transform: translateY(0); }
|
||||
transform: translateY(0); }
|
||||
20% {
|
||||
-webkit-transform: translateY(10px);
|
||||
transform: translateY(10px); }
|
||||
transform: translateY(10px); }
|
||||
30% {
|
||||
-webkit-transform: translateY(-5px);
|
||||
transform: translateY(-5px); } }
|
||||
transform: translateY(-5px); } }
|
||||
|
||||
.reveal .controls {
|
||||
display: none;
|
||||
@ -239,9 +200,7 @@ body {
|
||||
outline: 0;
|
||||
cursor: pointer;
|
||||
color: currentColor;
|
||||
-webkit-transform: scale(0.9999);
|
||||
transform: scale(0.9999);
|
||||
transition: color 0.2s ease, opacity 0.2s ease, -webkit-transform 0.2s ease;
|
||||
transform: scale(0.9999);
|
||||
transition: color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
|
||||
z-index: 2;
|
||||
pointer-events: auto;
|
||||
@ -261,67 +220,51 @@ body {
|
||||
border-radius: 0.25em;
|
||||
background-color: currentColor;
|
||||
transition: all 0.15s ease, background-color 0.8s ease;
|
||||
-webkit-transform-origin: 0.2em 50%;
|
||||
transform-origin: 0.2em 50%;
|
||||
transform-origin: 0.2em 50%;
|
||||
will-change: transform; }
|
||||
.reveal .controls .controls-arrow {
|
||||
position: relative;
|
||||
width: 3.6em;
|
||||
height: 3.6em; }
|
||||
.reveal .controls .controls-arrow:before {
|
||||
-webkit-transform: translateX(0.5em) translateY(1.55em) rotate(45deg);
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(45deg); }
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(45deg); }
|
||||
.reveal .controls .controls-arrow:after {
|
||||
-webkit-transform: translateX(0.5em) translateY(1.55em) rotate(-45deg);
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(-45deg); }
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(-45deg); }
|
||||
.reveal .controls .controls-arrow:hover:before {
|
||||
-webkit-transform: translateX(0.5em) translateY(1.55em) rotate(40deg);
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(40deg); }
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(40deg); }
|
||||
.reveal .controls .controls-arrow:hover:after {
|
||||
-webkit-transform: translateX(0.5em) translateY(1.55em) rotate(-40deg);
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(-40deg); }
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(-40deg); }
|
||||
.reveal .controls .controls-arrow:active:before {
|
||||
-webkit-transform: translateX(0.5em) translateY(1.55em) rotate(36deg);
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(36deg); }
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(36deg); }
|
||||
.reveal .controls .controls-arrow:active:after {
|
||||
-webkit-transform: translateX(0.5em) translateY(1.55em) rotate(-36deg);
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(-36deg); }
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(-36deg); }
|
||||
.reveal .controls .navigate-left {
|
||||
right: 6.4em;
|
||||
bottom: 3.2em;
|
||||
-webkit-transform: translateX(-10px);
|
||||
transform: translateX(-10px); }
|
||||
transform: translateX(-10px); }
|
||||
.reveal .controls .navigate-right {
|
||||
right: 0;
|
||||
bottom: 3.2em;
|
||||
-webkit-transform: translateX(10px);
|
||||
transform: translateX(10px); }
|
||||
transform: translateX(10px); }
|
||||
.reveal .controls .navigate-right .controls-arrow {
|
||||
-webkit-transform: rotate(180deg);
|
||||
transform: rotate(180deg); }
|
||||
transform: rotate(180deg); }
|
||||
.reveal .controls .navigate-right.highlight {
|
||||
-webkit-animation: bounce-right 2s 50 both ease-out;
|
||||
animation: bounce-right 2s 50 both ease-out; }
|
||||
animation: bounce-right 2s 50 both ease-out; }
|
||||
.reveal .controls .navigate-up {
|
||||
right: 3.2em;
|
||||
bottom: 6.4em;
|
||||
-webkit-transform: translateY(-10px);
|
||||
transform: translateY(-10px); }
|
||||
transform: translateY(-10px); }
|
||||
.reveal .controls .navigate-up .controls-arrow {
|
||||
-webkit-transform: rotate(90deg);
|
||||
transform: rotate(90deg); }
|
||||
transform: rotate(90deg); }
|
||||
.reveal .controls .navigate-down {
|
||||
right: 3.2em;
|
||||
bottom: -1.4em;
|
||||
padding-bottom: 1.4em;
|
||||
-webkit-transform: translateY(10px);
|
||||
transform: translateY(10px); }
|
||||
transform: translateY(10px); }
|
||||
.reveal .controls .navigate-down .controls-arrow {
|
||||
-webkit-transform: rotate(-90deg);
|
||||
transform: rotate(-90deg); }
|
||||
transform: rotate(-90deg); }
|
||||
.reveal .controls .navigate-down.highlight {
|
||||
-webkit-animation: bounce-down 2s 50 both ease-out;
|
||||
animation: bounce-down 2s 50 both ease-out; }
|
||||
animation: bounce-down 2s 50 both ease-out; }
|
||||
.reveal .controls[data-controls-back-arrows="faded"] .navigate-left.enabled,
|
||||
.reveal .controls[data-controls-back-arrows="faded"] .navigate-up.enabled {
|
||||
opacity: 0.3; }
|
||||
@ -336,8 +279,7 @@ body {
|
||||
visibility: visible;
|
||||
opacity: 0.9;
|
||||
cursor: pointer;
|
||||
-webkit-transform: none;
|
||||
transform: none; }
|
||||
transform: none; }
|
||||
.reveal .controls .enabled.fragmented {
|
||||
opacity: 0.5; }
|
||||
.reveal .controls .enabled:hover,
|
||||
@ -374,13 +316,11 @@ body {
|
||||
|
||||
.reveal.no-hover .controls .controls-arrow:hover:before,
|
||||
.reveal.no-hover .controls .controls-arrow:active:before {
|
||||
-webkit-transform: translateX(0.5em) translateY(1.55em) rotate(45deg);
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(45deg); }
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(45deg); }
|
||||
|
||||
.reveal.no-hover .controls .controls-arrow:hover:after,
|
||||
.reveal.no-hover .controls .controls-arrow:active:after {
|
||||
-webkit-transform: translateX(0.5em) translateY(1.55em) rotate(-45deg);
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(-45deg); }
|
||||
transform: translateX(0.5em) translateY(1.55em) rotate(-45deg); }
|
||||
|
||||
@media screen and (min-width: 500px) {
|
||||
.reveal .controls[data-controls-layout="edges"] {
|
||||
@ -486,14 +426,11 @@ body {
|
||||
overflow: visible;
|
||||
z-index: 1;
|
||||
text-align: center;
|
||||
-webkit-perspective: 600px;
|
||||
perspective: 600px;
|
||||
-webkit-perspective-origin: 50% 40%;
|
||||
perspective-origin: 50% 40%; }
|
||||
perspective: 600px;
|
||||
perspective-origin: 50% 40%; }
|
||||
|
||||
.reveal .slides > section {
|
||||
-webkit-perspective: 600px;
|
||||
perspective: 600px; }
|
||||
perspective: 600px; }
|
||||
|
||||
.reveal .slides > section,
|
||||
.reveal .slides > section > section {
|
||||
@ -503,9 +440,7 @@ body {
|
||||
padding: 20px 0px;
|
||||
pointer-events: auto;
|
||||
z-index: 10;
|
||||
-webkit-transform-style: flat;
|
||||
transform-style: flat;
|
||||
transition: -webkit-transform-origin 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), -webkit-transform 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), visibility 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), opacity 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
|
||||
transform-style: flat;
|
||||
transition: transform-origin 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), transform 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), visibility 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), opacity 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
|
||||
|
||||
/* Global transition speed settings */
|
||||
@ -570,60 +505,50 @@ body {
|
||||
* Aliased 'linear' for backwards compatibility
|
||||
*********************************************/
|
||||
.reveal.slide section {
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden; }
|
||||
backface-visibility: hidden; }
|
||||
|
||||
.reveal .slides > section[data-transition=slide].past,
|
||||
.reveal .slides > section[data-transition~=slide-out].past,
|
||||
.reveal.slide .slides > section:not([data-transition]).past {
|
||||
-webkit-transform: translate(-150%, 0);
|
||||
transform: translate(-150%, 0); }
|
||||
transform: translate(-150%, 0); }
|
||||
|
||||
.reveal .slides > section[data-transition=slide].future,
|
||||
.reveal .slides > section[data-transition~=slide-in].future,
|
||||
.reveal.slide .slides > section:not([data-transition]).future {
|
||||
-webkit-transform: translate(150%, 0);
|
||||
transform: translate(150%, 0); }
|
||||
transform: translate(150%, 0); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=slide].past,
|
||||
.reveal .slides > section > section[data-transition~=slide-out].past,
|
||||
.reveal.slide .slides > section > section:not([data-transition]).past {
|
||||
-webkit-transform: translate(0, -150%);
|
||||
transform: translate(0, -150%); }
|
||||
transform: translate(0, -150%); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=slide].future,
|
||||
.reveal .slides > section > section[data-transition~=slide-in].future,
|
||||
.reveal.slide .slides > section > section:not([data-transition]).future {
|
||||
-webkit-transform: translate(0, 150%);
|
||||
transform: translate(0, 150%); }
|
||||
transform: translate(0, 150%); }
|
||||
|
||||
.reveal.linear section {
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden; }
|
||||
backface-visibility: hidden; }
|
||||
|
||||
.reveal .slides > section[data-transition=linear].past,
|
||||
.reveal .slides > section[data-transition~=linear-out].past,
|
||||
.reveal.linear .slides > section:not([data-transition]).past {
|
||||
-webkit-transform: translate(-150%, 0);
|
||||
transform: translate(-150%, 0); }
|
||||
transform: translate(-150%, 0); }
|
||||
|
||||
.reveal .slides > section[data-transition=linear].future,
|
||||
.reveal .slides > section[data-transition~=linear-in].future,
|
||||
.reveal.linear .slides > section:not([data-transition]).future {
|
||||
-webkit-transform: translate(150%, 0);
|
||||
transform: translate(150%, 0); }
|
||||
transform: translate(150%, 0); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=linear].past,
|
||||
.reveal .slides > section > section[data-transition~=linear-out].past,
|
||||
.reveal.linear .slides > section > section:not([data-transition]).past {
|
||||
-webkit-transform: translate(0, -150%);
|
||||
transform: translate(0, -150%); }
|
||||
transform: translate(0, -150%); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=linear].future,
|
||||
.reveal .slides > section > section[data-transition~=linear-in].future,
|
||||
.reveal.linear .slides > section > section:not([data-transition]).future {
|
||||
-webkit-transform: translate(0, 150%);
|
||||
transform: translate(0, 150%); }
|
||||
transform: translate(0, 150%); }
|
||||
|
||||
/*********************************************
|
||||
* CONVEX TRANSITION
|
||||
@ -631,93 +556,78 @@ body {
|
||||
*********************************************/
|
||||
.reveal .slides section[data-transition=default].stack,
|
||||
.reveal.default .slides section.stack {
|
||||
-webkit-transform-style: preserve-3d;
|
||||
transform-style: preserve-3d; }
|
||||
transform-style: preserve-3d; }
|
||||
|
||||
.reveal .slides > section[data-transition=default].past,
|
||||
.reveal .slides > section[data-transition~=default-out].past,
|
||||
.reveal.default .slides > section:not([data-transition]).past {
|
||||
-webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0);
|
||||
transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); }
|
||||
transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); }
|
||||
|
||||
.reveal .slides > section[data-transition=default].future,
|
||||
.reveal .slides > section[data-transition~=default-in].future,
|
||||
.reveal.default .slides > section:not([data-transition]).future {
|
||||
-webkit-transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0);
|
||||
transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); }
|
||||
transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=default].past,
|
||||
.reveal .slides > section > section[data-transition~=default-out].past,
|
||||
.reveal.default .slides > section > section:not([data-transition]).past {
|
||||
-webkit-transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0);
|
||||
transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); }
|
||||
transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=default].future,
|
||||
.reveal .slides > section > section[data-transition~=default-in].future,
|
||||
.reveal.default .slides > section > section:not([data-transition]).future {
|
||||
-webkit-transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0);
|
||||
transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); }
|
||||
transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); }
|
||||
|
||||
.reveal .slides section[data-transition=convex].stack,
|
||||
.reveal.convex .slides section.stack {
|
||||
-webkit-transform-style: preserve-3d;
|
||||
transform-style: preserve-3d; }
|
||||
transform-style: preserve-3d; }
|
||||
|
||||
.reveal .slides > section[data-transition=convex].past,
|
||||
.reveal .slides > section[data-transition~=convex-out].past,
|
||||
.reveal.convex .slides > section:not([data-transition]).past {
|
||||
-webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0);
|
||||
transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); }
|
||||
transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); }
|
||||
|
||||
.reveal .slides > section[data-transition=convex].future,
|
||||
.reveal .slides > section[data-transition~=convex-in].future,
|
||||
.reveal.convex .slides > section:not([data-transition]).future {
|
||||
-webkit-transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0);
|
||||
transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); }
|
||||
transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=convex].past,
|
||||
.reveal .slides > section > section[data-transition~=convex-out].past,
|
||||
.reveal.convex .slides > section > section:not([data-transition]).past {
|
||||
-webkit-transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0);
|
||||
transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); }
|
||||
transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=convex].future,
|
||||
.reveal .slides > section > section[data-transition~=convex-in].future,
|
||||
.reveal.convex .slides > section > section:not([data-transition]).future {
|
||||
-webkit-transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0);
|
||||
transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); }
|
||||
transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); }
|
||||
|
||||
/*********************************************
|
||||
* CONCAVE TRANSITION
|
||||
*********************************************/
|
||||
.reveal .slides section[data-transition=concave].stack,
|
||||
.reveal.concave .slides section.stack {
|
||||
-webkit-transform-style: preserve-3d;
|
||||
transform-style: preserve-3d; }
|
||||
transform-style: preserve-3d; }
|
||||
|
||||
.reveal .slides > section[data-transition=concave].past,
|
||||
.reveal .slides > section[data-transition~=concave-out].past,
|
||||
.reveal.concave .slides > section:not([data-transition]).past {
|
||||
-webkit-transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0);
|
||||
transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); }
|
||||
transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); }
|
||||
|
||||
.reveal .slides > section[data-transition=concave].future,
|
||||
.reveal .slides > section[data-transition~=concave-in].future,
|
||||
.reveal.concave .slides > section:not([data-transition]).future {
|
||||
-webkit-transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0);
|
||||
transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); }
|
||||
transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=concave].past,
|
||||
.reveal .slides > section > section[data-transition~=concave-out].past,
|
||||
.reveal.concave .slides > section > section:not([data-transition]).past {
|
||||
-webkit-transform: translate3d(0, -80%, 0) rotateX(-70deg) translate3d(0, -80%, 0);
|
||||
transform: translate3d(0, -80%, 0) rotateX(-70deg) translate3d(0, -80%, 0); }
|
||||
transform: translate3d(0, -80%, 0) rotateX(-70deg) translate3d(0, -80%, 0); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=concave].future,
|
||||
.reveal .slides > section > section[data-transition~=concave-in].future,
|
||||
.reveal.concave .slides > section > section:not([data-transition]).future {
|
||||
-webkit-transform: translate3d(0, 80%, 0) rotateX(70deg) translate3d(0, 80%, 0);
|
||||
transform: translate3d(0, 80%, 0) rotateX(70deg) translate3d(0, 80%, 0); }
|
||||
transform: translate3d(0, 80%, 0) rotateX(70deg) translate3d(0, 80%, 0); }
|
||||
|
||||
/*********************************************
|
||||
* ZOOM TRANSITION
|
||||
@ -730,27 +640,23 @@ body {
|
||||
.reveal .slides > section[data-transition~=zoom-out].past,
|
||||
.reveal.zoom .slides > section:not([data-transition]).past {
|
||||
visibility: hidden;
|
||||
-webkit-transform: scale(16);
|
||||
transform: scale(16); }
|
||||
transform: scale(16); }
|
||||
|
||||
.reveal .slides > section[data-transition=zoom].future,
|
||||
.reveal .slides > section[data-transition~=zoom-in].future,
|
||||
.reveal.zoom .slides > section:not([data-transition]).future {
|
||||
visibility: hidden;
|
||||
-webkit-transform: scale(0.2);
|
||||
transform: scale(0.2); }
|
||||
transform: scale(0.2); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=zoom].past,
|
||||
.reveal .slides > section > section[data-transition~=zoom-out].past,
|
||||
.reveal.zoom .slides > section > section:not([data-transition]).past {
|
||||
-webkit-transform: scale(16);
|
||||
transform: scale(16); }
|
||||
transform: scale(16); }
|
||||
|
||||
.reveal .slides > section > section[data-transition=zoom].future,
|
||||
.reveal .slides > section > section[data-transition~=zoom-in].future,
|
||||
.reveal.zoom .slides > section > section:not([data-transition]).future {
|
||||
-webkit-transform: scale(0.2);
|
||||
transform: scale(0.2); }
|
||||
transform: scale(0.2); }
|
||||
|
||||
/*********************************************
|
||||
* CUBE TRANSITION
|
||||
@ -760,17 +666,14 @@ body {
|
||||
* future version.
|
||||
*********************************************/
|
||||
.reveal.cube .slides {
|
||||
-webkit-perspective: 1300px;
|
||||
perspective: 1300px; }
|
||||
perspective: 1300px; }
|
||||
|
||||
.reveal.cube .slides section {
|
||||
padding: 30px;
|
||||
min-height: 700px;
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
box-sizing: border-box;
|
||||
-webkit-transform-style: preserve-3d;
|
||||
transform-style: preserve-3d; }
|
||||
transform-style: preserve-3d; }
|
||||
|
||||
.reveal.center.cube .slides section {
|
||||
min-height: 0; }
|
||||
@ -785,8 +688,7 @@ body {
|
||||
top: 0;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
border-radius: 4px;
|
||||
-webkit-transform: translateZ(-20px);
|
||||
transform: translateZ(-20px); }
|
||||
transform: translateZ(-20px); }
|
||||
|
||||
.reveal.cube .slides section:not(.stack):after {
|
||||
content: '';
|
||||
@ -800,36 +702,27 @@ body {
|
||||
z-index: 1;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0px 95px 25px rgba(0, 0, 0, 0.2);
|
||||
-webkit-transform: translateZ(-90px) rotateX(65deg);
|
||||
transform: translateZ(-90px) rotateX(65deg); }
|
||||
transform: translateZ(-90px) rotateX(65deg); }
|
||||
|
||||
.reveal.cube .slides > section.stack {
|
||||
padding: 0;
|
||||
background: none; }
|
||||
|
||||
.reveal.cube .slides > section.past {
|
||||
-webkit-transform-origin: 100% 0%;
|
||||
transform-origin: 100% 0%;
|
||||
-webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg);
|
||||
transform: translate3d(-100%, 0, 0) rotateY(-90deg); }
|
||||
transform-origin: 100% 0%;
|
||||
transform: translate3d(-100%, 0, 0) rotateY(-90deg); }
|
||||
|
||||
.reveal.cube .slides > section.future {
|
||||
-webkit-transform-origin: 0% 0%;
|
||||
transform-origin: 0% 0%;
|
||||
-webkit-transform: translate3d(100%, 0, 0) rotateY(90deg);
|
||||
transform: translate3d(100%, 0, 0) rotateY(90deg); }
|
||||
transform-origin: 0% 0%;
|
||||
transform: translate3d(100%, 0, 0) rotateY(90deg); }
|
||||
|
||||
.reveal.cube .slides > section > section.past {
|
||||
-webkit-transform-origin: 0% 100%;
|
||||
transform-origin: 0% 100%;
|
||||
-webkit-transform: translate3d(0, -100%, 0) rotateX(90deg);
|
||||
transform: translate3d(0, -100%, 0) rotateX(90deg); }
|
||||
transform-origin: 0% 100%;
|
||||
transform: translate3d(0, -100%, 0) rotateX(90deg); }
|
||||
|
||||
.reveal.cube .slides > section > section.future {
|
||||
-webkit-transform-origin: 0% 0%;
|
||||
transform-origin: 0% 0%;
|
||||
-webkit-transform: translate3d(0, 100%, 0) rotateX(-90deg);
|
||||
transform: translate3d(0, 100%, 0) rotateX(-90deg); }
|
||||
transform-origin: 0% 0%;
|
||||
transform: translate3d(0, 100%, 0) rotateX(-90deg); }
|
||||
|
||||
/*********************************************
|
||||
* PAGE TRANSITION
|
||||
@ -839,17 +732,14 @@ body {
|
||||
* future version.
|
||||
*********************************************/
|
||||
.reveal.page .slides {
|
||||
-webkit-perspective-origin: 0% 50%;
|
||||
perspective-origin: 0% 50%;
|
||||
-webkit-perspective: 3000px;
|
||||
perspective: 3000px; }
|
||||
perspective-origin: 0% 50%;
|
||||
perspective: 3000px; }
|
||||
|
||||
.reveal.page .slides section {
|
||||
padding: 30px;
|
||||
min-height: 700px;
|
||||
box-sizing: border-box;
|
||||
-webkit-transform-style: preserve-3d;
|
||||
transform-style: preserve-3d; }
|
||||
transform-style: preserve-3d; }
|
||||
|
||||
.reveal.page .slides section.past {
|
||||
z-index: 12; }
|
||||
@ -863,8 +753,7 @@ body {
|
||||
left: 0;
|
||||
top: 0;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
-webkit-transform: translateZ(-20px);
|
||||
transform: translateZ(-20px); }
|
||||
transform: translateZ(-20px); }
|
||||
|
||||
.reveal.page .slides section:not(.stack):after {
|
||||
content: '';
|
||||
@ -885,28 +774,20 @@ body {
|
||||
background: none; }
|
||||
|
||||
.reveal.page .slides > section.past {
|
||||
-webkit-transform-origin: 0% 0%;
|
||||
transform-origin: 0% 0%;
|
||||
-webkit-transform: translate3d(-40%, 0, 0) rotateY(-80deg);
|
||||
transform: translate3d(-40%, 0, 0) rotateY(-80deg); }
|
||||
transform-origin: 0% 0%;
|
||||
transform: translate3d(-40%, 0, 0) rotateY(-80deg); }
|
||||
|
||||
.reveal.page .slides > section.future {
|
||||
-webkit-transform-origin: 100% 0%;
|
||||
transform-origin: 100% 0%;
|
||||
-webkit-transform: translate3d(0, 0, 0);
|
||||
transform: translate3d(0, 0, 0); }
|
||||
transform-origin: 100% 0%;
|
||||
transform: translate3d(0, 0, 0); }
|
||||
|
||||
.reveal.page .slides > section > section.past {
|
||||
-webkit-transform-origin: 0% 0%;
|
||||
transform-origin: 0% 0%;
|
||||
-webkit-transform: translate3d(0, -40%, 0) rotateX(80deg);
|
||||
transform: translate3d(0, -40%, 0) rotateX(80deg); }
|
||||
transform-origin: 0% 0%;
|
||||
transform: translate3d(0, -40%, 0) rotateX(80deg); }
|
||||
|
||||
.reveal.page .slides > section > section.future {
|
||||
-webkit-transform-origin: 0% 100%;
|
||||
transform-origin: 0% 100%;
|
||||
-webkit-transform: translate3d(0, 0, 0);
|
||||
transform: translate3d(0, 0, 0); }
|
||||
transform-origin: 0% 100%;
|
||||
transform: translate3d(0, 0, 0); }
|
||||
|
||||
/*********************************************
|
||||
* FADE TRANSITION
|
||||
@ -914,8 +795,7 @@ body {
|
||||
.reveal .slides section[data-transition=fade],
|
||||
.reveal.fade .slides section:not([data-transition]),
|
||||
.reveal.fade .slides > section > section:not([data-transition]) {
|
||||
-webkit-transform: none;
|
||||
transform: none;
|
||||
transform: none;
|
||||
transition: opacity 0.5s; }
|
||||
|
||||
.reveal.fade.overview .slides section,
|
||||
@ -927,8 +807,7 @@ body {
|
||||
*********************************************/
|
||||
.reveal .slides section[data-transition=none],
|
||||
.reveal.none .slides section:not([data-transition]) {
|
||||
-webkit-transform: none;
|
||||
transform: none;
|
||||
transform: none;
|
||||
transition: none; }
|
||||
|
||||
/*********************************************
|
||||
@ -997,8 +876,7 @@ body {
|
||||
left: 0;
|
||||
margin: 10vh 0;
|
||||
margin: 70px 0;
|
||||
-webkit-transform: none;
|
||||
transform: none; }
|
||||
transform: none; }
|
||||
|
||||
.reveal .no-transition,
|
||||
.reveal .no-transition * {
|
||||
@ -1013,8 +891,7 @@ body {
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
-webkit-perspective: 600px;
|
||||
perspective: 600px; }
|
||||
perspective: 600px; }
|
||||
|
||||
.reveal .slide-background {
|
||||
display: none;
|
||||
@ -1072,78 +949,65 @@ body {
|
||||
.reveal[data-background-transition=slide] > .backgrounds .slide-background,
|
||||
.reveal > .backgrounds .slide-background[data-background-transition=slide] {
|
||||
opacity: 1;
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden; }
|
||||
backface-visibility: hidden; }
|
||||
|
||||
.reveal[data-background-transition=slide] > .backgrounds .slide-background.past,
|
||||
.reveal > .backgrounds .slide-background.past[data-background-transition=slide] {
|
||||
-webkit-transform: translate(-100%, 0);
|
||||
transform: translate(-100%, 0); }
|
||||
transform: translate(-100%, 0); }
|
||||
|
||||
.reveal[data-background-transition=slide] > .backgrounds .slide-background.future,
|
||||
.reveal > .backgrounds .slide-background.future[data-background-transition=slide] {
|
||||
-webkit-transform: translate(100%, 0);
|
||||
transform: translate(100%, 0); }
|
||||
transform: translate(100%, 0); }
|
||||
|
||||
.reveal[data-background-transition=slide] > .backgrounds .slide-background > .slide-background.past,
|
||||
.reveal > .backgrounds .slide-background > .slide-background.past[data-background-transition=slide] {
|
||||
-webkit-transform: translate(0, -100%);
|
||||
transform: translate(0, -100%); }
|
||||
transform: translate(0, -100%); }
|
||||
|
||||
.reveal[data-background-transition=slide] > .backgrounds .slide-background > .slide-background.future,
|
||||
.reveal > .backgrounds .slide-background > .slide-background.future[data-background-transition=slide] {
|
||||
-webkit-transform: translate(0, 100%);
|
||||
transform: translate(0, 100%); }
|
||||
transform: translate(0, 100%); }
|
||||
|
||||
/* Convex */
|
||||
.reveal[data-background-transition=convex] > .backgrounds .slide-background.past,
|
||||
.reveal > .backgrounds .slide-background.past[data-background-transition=convex] {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0);
|
||||
transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); }
|
||||
transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); }
|
||||
|
||||
.reveal[data-background-transition=convex] > .backgrounds .slide-background.future,
|
||||
.reveal > .backgrounds .slide-background.future[data-background-transition=convex] {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0);
|
||||
transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); }
|
||||
transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); }
|
||||
|
||||
.reveal[data-background-transition=convex] > .backgrounds .slide-background > .slide-background.past,
|
||||
.reveal > .backgrounds .slide-background > .slide-background.past[data-background-transition=convex] {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(0, -100%, 0) rotateX(90deg) translate3d(0, -100%, 0);
|
||||
transform: translate3d(0, -100%, 0) rotateX(90deg) translate3d(0, -100%, 0); }
|
||||
transform: translate3d(0, -100%, 0) rotateX(90deg) translate3d(0, -100%, 0); }
|
||||
|
||||
.reveal[data-background-transition=convex] > .backgrounds .slide-background > .slide-background.future,
|
||||
.reveal > .backgrounds .slide-background > .slide-background.future[data-background-transition=convex] {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(0, 100%, 0) rotateX(-90deg) translate3d(0, 100%, 0);
|
||||
transform: translate3d(0, 100%, 0) rotateX(-90deg) translate3d(0, 100%, 0); }
|
||||
transform: translate3d(0, 100%, 0) rotateX(-90deg) translate3d(0, 100%, 0); }
|
||||
|
||||
/* Concave */
|
||||
.reveal[data-background-transition=concave] > .backgrounds .slide-background.past,
|
||||
.reveal > .backgrounds .slide-background.past[data-background-transition=concave] {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0);
|
||||
transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); }
|
||||
transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); }
|
||||
|
||||
.reveal[data-background-transition=concave] > .backgrounds .slide-background.future,
|
||||
.reveal > .backgrounds .slide-background.future[data-background-transition=concave] {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0);
|
||||
transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); }
|
||||
transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); }
|
||||
|
||||
.reveal[data-background-transition=concave] > .backgrounds .slide-background > .slide-background.past,
|
||||
.reveal > .backgrounds .slide-background > .slide-background.past[data-background-transition=concave] {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(0, -100%, 0) rotateX(-90deg) translate3d(0, -100%, 0);
|
||||
transform: translate3d(0, -100%, 0) rotateX(-90deg) translate3d(0, -100%, 0); }
|
||||
transform: translate3d(0, -100%, 0) rotateX(-90deg) translate3d(0, -100%, 0); }
|
||||
|
||||
.reveal[data-background-transition=concave] > .backgrounds .slide-background > .slide-background.future,
|
||||
.reveal > .backgrounds .slide-background > .slide-background.future[data-background-transition=concave] {
|
||||
opacity: 0;
|
||||
-webkit-transform: translate3d(0, 100%, 0) rotateX(90deg) translate3d(0, 100%, 0);
|
||||
transform: translate3d(0, 100%, 0) rotateX(90deg) translate3d(0, 100%, 0); }
|
||||
transform: translate3d(0, 100%, 0) rotateX(90deg) translate3d(0, 100%, 0); }
|
||||
|
||||
/* Zoom */
|
||||
.reveal[data-background-transition=zoom] > .backgrounds .slide-background,
|
||||
@ -1154,29 +1018,25 @@ body {
|
||||
.reveal > .backgrounds .slide-background.past[data-background-transition=zoom] {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
-webkit-transform: scale(16);
|
||||
transform: scale(16); }
|
||||
transform: scale(16); }
|
||||
|
||||
.reveal[data-background-transition=zoom] > .backgrounds .slide-background.future,
|
||||
.reveal > .backgrounds .slide-background.future[data-background-transition=zoom] {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
-webkit-transform: scale(0.2);
|
||||
transform: scale(0.2); }
|
||||
transform: scale(0.2); }
|
||||
|
||||
.reveal[data-background-transition=zoom] > .backgrounds .slide-background > .slide-background.past,
|
||||
.reveal > .backgrounds .slide-background > .slide-background.past[data-background-transition=zoom] {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
-webkit-transform: scale(16);
|
||||
transform: scale(16); }
|
||||
transform: scale(16); }
|
||||
|
||||
.reveal[data-background-transition=zoom] > .backgrounds .slide-background > .slide-background.future,
|
||||
.reveal > .backgrounds .slide-background > .slide-background.future[data-background-transition=zoom] {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
-webkit-transform: scale(0.2);
|
||||
transform: scale(0.2); }
|
||||
transform: scale(0.2); }
|
||||
|
||||
/* Global transition speed settings */
|
||||
.reveal[data-transition-speed="fast"] > .backgrounds .slide-background {
|
||||
@ -1189,10 +1049,8 @@ body {
|
||||
* OVERVIEW
|
||||
*********************************************/
|
||||
.reveal.overview {
|
||||
-webkit-perspective-origin: 50% 50%;
|
||||
perspective-origin: 50% 50%;
|
||||
-webkit-perspective: 700px;
|
||||
perspective: 700px; }
|
||||
perspective-origin: 50% 50%;
|
||||
perspective: 700px; }
|
||||
.reveal.overview .slides {
|
||||
-moz-transform-style: preserve-3d; }
|
||||
.reveal.overview .slides section {
|
||||
@ -1220,8 +1078,7 @@ body {
|
||||
outline: none;
|
||||
overflow: visible; }
|
||||
.reveal.overview .backgrounds {
|
||||
-webkit-perspective: inherit;
|
||||
perspective: inherit;
|
||||
perspective: inherit;
|
||||
-moz-transform-style: preserve-3d; }
|
||||
.reveal.overview .backgrounds .slide-background {
|
||||
opacity: 1;
|
||||
@ -1347,7 +1204,6 @@ body {
|
||||
|
||||
.reveal > .overlay .viewport {
|
||||
position: absolute;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
top: 40px;
|
||||
@ -1388,8 +1244,7 @@ body {
|
||||
.reveal > .overlay.overlay-preview.loaded .spinner {
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
-webkit-transform: scale(0.2);
|
||||
transform: scale(0.2); }
|
||||
transform: scale(0.2); }
|
||||
|
||||
.reveal > .overlay.overlay-help .viewport {
|
||||
overflow: auto;
|
||||
@ -1472,10 +1327,8 @@ body {
|
||||
line-height: 1.2;
|
||||
overflow: hidden;
|
||||
vertical-align: top;
|
||||
-webkit-perspective: 400px;
|
||||
perspective: 400px;
|
||||
-webkit-perspective-origin: 50% 50%;
|
||||
perspective-origin: 50% 50%; }
|
||||
perspective: 400px;
|
||||
perspective-origin: 50% 50%; }
|
||||
|
||||
.reveal .roll:hover {
|
||||
background: none;
|
||||
@ -1487,17 +1340,13 @@ body {
|
||||
padding: 0 2px;
|
||||
pointer-events: none;
|
||||
transition: all 400ms ease;
|
||||
-webkit-transform-origin: 50% 0%;
|
||||
transform-origin: 50% 0%;
|
||||
-webkit-transform-style: preserve-3d;
|
||||
transform-style: preserve-3d;
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden; }
|
||||
transform-origin: 50% 0%;
|
||||
transform-style: preserve-3d;
|
||||
backface-visibility: hidden; }
|
||||
|
||||
.reveal .roll:hover span {
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
-webkit-transform: translate3d(0px, 0px, -45px) rotateX(90deg);
|
||||
transform: translate3d(0px, 0px, -45px) rotateX(90deg); }
|
||||
transform: translate3d(0px, 0px, -45px) rotateX(90deg); }
|
||||
|
||||
.reveal .roll span:after {
|
||||
content: attr(data-title);
|
||||
@ -1506,12 +1355,9 @@ body {
|
||||
left: 0;
|
||||
top: 0;
|
||||
padding: 0 2px;
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
-webkit-transform-origin: 50% 0%;
|
||||
transform-origin: 50% 0%;
|
||||
-webkit-transform: translate3d(0px, 110%, 0px) rotateX(-90deg);
|
||||
transform: translate3d(0px, 110%, 0px) rotateX(-90deg); }
|
||||
backface-visibility: hidden;
|
||||
transform-origin: 50% 0%;
|
||||
transform: translate3d(0px, 110%, 0px) rotateX(-90deg); }
|
||||
|
||||
/*********************************************
|
||||
* SPEAKER NOTES
|
||||
@ -1592,8 +1438,7 @@ body {
|
||||
.zoomed .reveal *,
|
||||
.zoomed .reveal *:before,
|
||||
.zoomed .reveal *:after {
|
||||
-webkit-backface-visibility: visible !important;
|
||||
backface-visibility: visible !important; }
|
||||
backface-visibility: visible !important; }
|
||||
|
||||
.zoomed .reveal .progress,
|
||||
.zoomed .reveal .controls {
|
7
reveal.js/css/reveal.min.css
vendored
Normal file
7
reveal.js/css/reveal.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -35,10 +35,10 @@ $linkColor: #42affa;
|
||||
$linkColorHover: lighten( $linkColor, 15% );
|
||||
$selectionBackgroundColor: lighten( $linkColor, 25% );
|
||||
|
||||
$heading1Size: 2.5em;
|
||||
$heading2Size: 1.6em;
|
||||
$heading3Size: 1.3em;
|
||||
$heading4Size: 1.0em;
|
||||
$heading1Size: 1.6em;
|
||||
$heading2Size: 1.3em;
|
||||
$heading3Size: 1.0em;
|
||||
$heading4Size: 0.8em;
|
||||
|
||||
section.has-light-background {
|
||||
&, h1, h2, h3, h4, h5, h6 {
|
@ -56,17 +56,17 @@ body {
|
||||
word-wrap: break-word; }
|
||||
|
||||
.reveal h1 {
|
||||
font-size: 2.5em; }
|
||||
|
||||
.reveal h2 {
|
||||
font-size: 1.6em; }
|
||||
|
||||
.reveal h3 {
|
||||
.reveal h2 {
|
||||
font-size: 1.3em; }
|
||||
|
||||
.reveal h4 {
|
||||
.reveal h3 {
|
||||
font-size: 1em; }
|
||||
|
||||
.reveal h4 {
|
||||
font-size: 0.8em; }
|
||||
|
||||
.reveal h1 {
|
||||
text-shadow: none; }
|
||||
|
||||
@ -283,3 +283,8 @@ body {
|
||||
border-width: 2px;
|
||||
border-style: solid;
|
||||
border-color: #777; }
|
||||
|
||||
.sourceCode {
|
||||
background-color: transparent;
|
||||
overflow: auto;
|
||||
margin: 0em; }
|
@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* reveal.js 3.8.0 (2020-01-19, 21:24)
|
||||
* reveal.js 3.8.0 (2020-01-31, 21:50)
|
||||
* http://revealjs.com
|
||||
* MIT licensed
|
||||
*
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user