This commit is contained in:
nek0 2020-01-09 02:19:41 +01:00
commit 2559ecf3e2
15 changed files with 432 additions and 0 deletions

8
.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
*.aux
*.log
*.nav
*.out
*.pdf
*.synctex.gz
*.toc
*.vrb

23
12days.hs Normal file
View file

@ -0,0 +1,23 @@
gifts :: [String]
gifts =
[ "And a partridge in a pear tree!", "Two turtle doves,", "Three french hens,"
, "Four calling birds,", "Five golden rings,", "Six geese a-laying,"
, "Seven swans a-swimming,", "Eight maids a-milking,", "Nine ladies dancing,"
, "Ten lords a-leaping,", "Eleven pipers piping,", "Twelve drummers drumming,"
]
days :: [String]
days = [
"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth",
"ninth", "tenth", "eleventh", "twelfth" ]
verseOfTheDay :: Int -> String
verseOfTheDay day =
"On the " ++ days !! day ++ " day of Christmas my true love gave to me... \n"
++ concat (map (++ "\n") [dayGift day d | d <- [day, day-1..0]]) ++ "\n"
where
dayGift 0 _ = "A partridge in a pear tree!"
dayGift _ gift = gifts !! gift
main :: IO ()
main = putStrLn (concatMap verseOfTheDay [0..11])

212
Functional programming.tex Normal file
View file

@ -0,0 +1,212 @@
\documentclass[aspectratio=1610,10pt]{beamer}
\usepackage{fontspec}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{listings}
\usepackage{tcolorbox}
\usepackage{hyperref}
\newtcbox{\mybox}{
on line,
%colframe=mycolor,
colback=lightgray,
%boxrule=0.5pt,
arc=4pt,
boxsep=0pt,
left=6pt,
right=6pt,
top=6pt,
bottom=6pt
}
\lstdefinelanguage{Haskelln}{
language = Haskell,
otherkeywords = {=>,->,::,++,!!,|,<-},
}
\lstset{
frame=none,
xleftmargin=2pt,
stepnumber=1,
numbers=none,
numbersep=5pt,
numberstyle=\ttfamily\tiny\color{lightgray},
belowcaptionskip=\bigskipamount,
captionpos=b,
escapeinside={*'}{'*},
language=Haskelln,
tabsize=2,
emphstyle={\bf},
commentstyle=\it,
stringstyle=\mdseries\ttfamily\color{green},
showspaces=false,
keywordstyle=[1]\color{cyan}\bfseries\ttfamily,
keywordstyle=[2]\color{orange}\bfseries\ttfamily,
keywordstyle=[3]\color{yellow}\bfseries\ttfamily,
keywordstyle=[4]\color{red}\bfseries\ttfamily,
keywordstyle=[5]\color{purple}\bfseries\ttfamily,
keywordstyle=[6]\color{blue}\bfseries\ttfamily,
%keywordstyle=\color{cyan}\ttfamily
columns=flexible,
basicstyle=\color{white}\small\ttfamily,
showstringspaces=false,
morecomment=[l]\%,
emptylines=1,
}
% You can set fonts for Latin script here
\setmainfont{FreeSerif}
\setsansfont{FreeSans}
\setmonofont{Fira Mono}
\usetheme{DarkConsole}
\begin{document}
% The metadata of the presentation
\title{Functional Programming}
\subtitle{Using the example of Haskell}
\author[]{Amedeo Molnár - \href{mailto:nek0@nek0.eu}{nek0@nek0.eu}}
%\institute{SRH Berufsbildungswerk Dresden gGmbH}
\date{13. Januar 2020} % Replace with date of the presentation
\begin{frame}[plain]
\maketitle
\end{frame}
\begin{frame}{Overview}
\tableofcontents
\end{frame}
\section{Introduction}
\begin{frame}
\frametitle{Languages}
\begin{center}
\begin{tabular}{ccc}
\onslide<2->{\mybox{\includegraphics[width=.2\linewidth]{pictures/Lisplogo_alien_256.png}}} &
&
\onslide<3->{\mybox{\includegraphics[width=.2\linewidth]{pictures/OCaml_Logo.png}}}
\\
&
\onslide<6->{\mybox{\includegraphics[width=.25\linewidth]{pictures/Haskell-Logo.png}}}
&
\\
\onslide<4->{\mybox{\includegraphics[width=.16\linewidth]{pictures/Swift-Logo.png}}}
&
&
\onslide<5->{\mybox{\includegraphics[height=.16\linewidth]{pictures/Elixir-Logo.png}}}
\end{tabular}
\end{center}
\end{frame}
\begin{frame}
\frametitle{Core Concepts}
\begin{itemize}
\item \underline{Pure functions}\\
{\onslide<2->{\color{lightgray}A (pure) function must produce the same
result given the same input and does not rely on or alter external state.}}
\item \underline{Non-imperative functions}\\
{\onslide<3->{\color{lightgray}A function is not a sequence of commands, but
a nesting of other functions.}}
\item \underline{First class citizens}\\
{\onslide<4->{\color{lightgray}Functions are equal to other data objects and
can thus be passed as function arguments or be computation results
themselves.}}
\item \underline{Closures}\\
{\onslide<5->{\color{lightgray}Functions can only access variables inside
context they have been created. This can happen even when the function
itself has left this context. In this case the variable values are frozen at
the moment of departure inside the function.}}
\item \underline{Lambdas}\\
{\onslide<6->{\color{lightgray}A function definition can take place without
an explicit name in the position of a function symbol.}}
\end{itemize}
\end{frame}
\section{Main differences to imperative programming}
\begin{frame}
\frametitle{\secname}
\begin{itemize}
\item<2-> Avoidance of side effects
\item<3-> No state
\item<4-> No Loops
\item<5-> Immutable variables
\end{itemize}
\end{frame}
\section{Examples}
\begin{frame}[fragile]
\frametitle{\secname}
\begin{lstlisting}
sq :: (Floating a) => a -> a
sq x = x * x
\end{lstlisting}
\vspace{1cm}
\begin{lstlisting}
ringArea :: (Floating a) => a -> a -> a
ringArea r1 r2 = pi * (sq r1 - sq r2)
\end{lstlisting}
\vspace{1cm}
\begin{lstlisting}
fib :: Integer -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n - 2) + fib (n - 1)
\end{lstlisting}
\end{frame}
\begin{frame}
\frametitle{Advanced Example}
\lstinputlisting[
basicstyle=\color{white}\fontsize{9pt}{9pt}\ttfamily
]{12days.hs}
\end{frame}
\section{Fields of Application}
\begin{frame}
\frametitle{Fields of Application}
\begin{itemize}
\item<2-> Big Data
\item<3-> Finance Sector
\item<4-> Science
\item<5-> Virtually everywhere
\end{itemize}
\end{frame}
\section{Conclusion}
\begin{frame}
\frametitle{Literature recommendations}
\begin{itemize}
\item \href{http://learnyouahaskell.com/}{Learn you a Haskell for Great Good!}
\item \href{http://book.realworldhaskell.org/}{Real World Haskell}
\item
\href{https://www.oreilly.com/library/view/parallel-and-concurrent/9781449335939}{Parallel and Concurrent Programming in Haskell}
\item \href{http://www.cs.yale.edu/homes/hudak/Papers/HSoM.pdf}{The Haskell
School of Music}
\end{itemize}
\end{frame}
\begin{frame}[plain]
\begin{center}
{\Huge Thank you for your attention!}\\
This presentation is avalable for download at:\\
\url{https://github.com/nek0/presentation-fp-haskell}
\end{center}
\end{frame}
\end{document}

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# presentation-fp-haskell
A short presentation on functional programming with Haskell

View file

@ -0,0 +1,22 @@
%% Copyright (c) 2011-2016 Kazuki Maeda <kmaeda@kmaeda.net>
%%
%% Distributable under the MIT License:
%% http://www.opensource.org/licenses/mit-license.php
%%
\ProvidesPackage{beamercolorthemeBlackboard}[2012/06/07 ]
\mode<presentation>
\usepackage{kmbeamer_color}
\setbeamercolor*{background canvas}{bg=bottlegreen}
\setbeamercolor*{normal text}{fg=snow}
\setbeamercolor*{alerted text}{fg=midyellow}
\setbeamercolor*{structure}{fg=water}
\setbeamercolor*{title}{fg=water}
\mode
<all>
\endinput

View file

@ -0,0 +1,28 @@
%% Copyright (c) 2013-2016 Kazuki Maeda <kmaeda@kmaeda.net>
%%
%% Distributable under the MIT License:
%% http://www.opensource.org/licenses/mit-license.php
%%
\ProvidesPackage{beamercolorthemeDarkConsole}[2013/05/08 ]
\mode<presentation>
\usepackage{kmbeamer_color}
\setbeamercolor*{background canvas}{bg=backgroundGray}
\setbeamercolor*{normal text}{fg=whiteee}
\setbeamercolor*{alerted text}{fg=tomato}
\setbeamercolor*{structure}{fg=gold}
\setbeamercolor*{title}{fg=chartreuse}
\setbeamercolor*{frametitle}{fg=chartreuse}
\setbeamercolor*{itemize item}{fg=chartreuse}
\setbeamercolor*{enumerate item}{fg=chartreuse}
\mode
<all>
\endinput

View file

@ -0,0 +1,18 @@
%% Copyright (c) 2011-2016 Kazuki Maeda <kmaeda@kmaeda.net>
%%
%% Distributable under the MIT License:
%% http://www.opensource.org/licenses/mit-license.php
%%
\ProvidesPackage{beamerfontthemeluatexja}[2011/11/03 ]
\mode<presentation>
\RequirePackage{luatexja-fontspec}
\setmainjfont[NoEmbed]{GothicBBB-Medium}
\setsansjfont[NoEmbed]{GothicBBB-Medium}
\mode
<all>
\endinput

View file

@ -0,0 +1,53 @@
%% Copyright (c) 2013-2016 Kazuki Maeda <kmaeda@kmaeda.net>
%%
%% Distributable under the MIT License:
%% http://www.opensource.org/licenses/mit-license.php
%%
\ProvidesPackage{beamerthemeDarkConsole}[2013/05/16 ]
\mode<presentation>
\RequirePackage{kmbeamer_common}
\usecolortheme{DarkConsole}
\def\familydefault{\ttdefault}
\setbeamersize{text margin left=2mm,text margin right=2mm}
\setbeamerfont{alerted text}{series=\bfseries}
\setbeamerfont{structure}{series=\bfseries}
\setbeamerfont{title}{size=\normalsize,series=\bfseries}
\setbeamerfont{frametitle}{size=\normalsize,series=\bfseries}
\setbeamerfont{block title}{size=\normalsize,series=\bfseries}
\setbeamerfont{footline}{size*={5}{\z@},series=\bfseries}
\setbeamertemplate{itemize item}{*}
\setbeamertemplate{itemize subitem}{*}
\setbeamertemplate{itemize subsubitem}{*}
\setbeamertemplate{frametitle}{{\usebeamercolor[fg]{normal text}\texttt{\mdseries >\hbox{}>\hbox{}> }}\boldmath\insertframetitle}
\setbeamertemplate{headline}{}
\setbeamertemplate{footline}{
\setbox\kmbmr@tmpboxa\hbox{[\ifnum\insertsectionnumber>0\boldmath\insertsectionnumber.~\insertsection\else\char"7E\fi]\$~\_}
\setbox\kmbmr@tmpboxb\hbox{[\insertframenumber/\inserttotalframenumber]}
\ht\kmbmr@tmpboxa=1mm\dp\kmbmr@tmpboxa=0mm
\ht\kmbmr@tmpboxb=1mm\dp\kmbmr@tmpboxb=0mm
\vspace{5.2mm}
\hspace{2mm}\noindent\box\kmbmr@tmpboxa\hfill\box\kmbmr@tmpboxb\hspace{2mm}
\vspace{1.3mm}
}
\setbeamertemplate{title page}{
\renewcommand\thefootnote{\fnsymbol{footnote}}
\setcounter{footnote}{1} % \dagger
\noindent >\hbox{}>\hbox{}> {\usebeamerfont{title}\usebeamercolor[fg]{title}\bfseries\boldmath\inserttitle}
\ifx\insertsubtitle\@empty\else\\>\hbox{}>\hbox{}> {\usebeamerfont{title}\usebeamercolor[fg]{title}\insertsubtitle}\fi~\\[1em]
Name: \insertauthor\ \ifx\insertinstitute\@empty\else(\insertinstitute)\fi\\
Date: \insertdate
\renewcommand\thefootnote{\arabic{footnote}}
\setcounter{footnote}{0}
}
\mode
<all>
\endinput

48
kmbeamer_color.sty Normal file
View file

@ -0,0 +1,48 @@
%% Copyright (c) 2011-2016 Kazuki Maeda <kmaeda@kmaeda.net>
%%
%% Distributable under the MIT License:
%% http://www.opensource.org/licenses/mit-license.php
%%
\ProvidesPackage{kmbeamer_color}[2013/05/08 ]
%% black
\definecolor{backgroundGray}{HTML}{1e1e1e}
%% blue
\definecolor{midnightblue}{HTML}{00152D}
\definecolor{navyblue}{HTML}{1F2F54}
\definecolor{ultramarine}{HTML}{4B64A1}
\definecolor{water}{HTML}{A9CEEC}
%% brown
\definecolor{sepia}{HTML}{4A3B2A}
\definecolor{brown}{HTML}{763900}
\definecolor{goldbrown}{HTML}{C47600}
\definecolor{satsuma}{HTML}{FA8000}
%% green
\definecolor{deepgreen}{HTML}{005731}
\definecolor{bottlegreen}{HTML}{264435}
\definecolor{tokiwa}{HTML}{357C4C}
\definecolor{indigo}{HTML}{234794}
\definecolor{chartreuse}{HTML}{7FFF00}
%% red
\definecolor{kerria}{HTML}{FFA500}
\definecolor{vermilion}{HTML}{ED514E}
\definecolor{madder}{HTML}{B22D35}
\definecolor{maroon}{HTML}{682A2B}
\definecolor{tomato}{HTML}{FF6347}
%% white
\definecolor{snow}{HTML}{F1F1F1}
\definecolor{whiteee}{HTML}{EEEEEC}
%% yellow
\definecolor{midyellow}{HTML}{FAD43A}
\definecolor{lemonchiffon}{HTML}{FFFACD}
\definecolor{gold}{HTML}{FFD700}
\endinput

17
kmbeamer_common.sty Normal file
View file

@ -0,0 +1,17 @@
%% Copyright (c) 20112016 Kazuki Maeda <kmaeda@kmaeda.net>
%%
%% Distributable under the MIT License:
%% http://www.opensource.org/licenses/mit-license.php
%%
\ProvidesPackage{kmbeamer_common}[2012/04/20 ]
\newbox\kmbmr@tmpboxa
\newbox\kmbmr@tmpboxb
\usefonttheme{professionalfonts}
\setbeamertemplate{sections/subsections in toc}[sections numbered]{}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{qed symbol}{}
\endinput

BIN
pictures/Elixir-Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

BIN
pictures/Haskell-Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
pictures/OCaml_Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
pictures/Swift-Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB