commit 2559ecf3e233701ae07a8f6cb08a44db8b63774f Author: nek0 Date: Thu Jan 9 02:19:41 2020 +0100 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3d0ef34 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.aux +*.log +*.nav +*.out +*.pdf +*.synctex.gz +*.toc +*.vrb diff --git a/12days.hs b/12days.hs new file mode 100644 index 0000000..99d9e18 --- /dev/null +++ b/12days.hs @@ -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]) diff --git a/Functional programming.tex b/Functional programming.tex new file mode 100644 index 0000000..f11cccc --- /dev/null +++ b/Functional programming.tex @@ -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} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..99ca79d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# presentation-fp-haskell + +A short presentation on functional programming with Haskell diff --git a/beamercolorthemeBlackboard.sty b/beamercolorthemeBlackboard.sty new file mode 100644 index 0000000..a73ecd1 --- /dev/null +++ b/beamercolorthemeBlackboard.sty @@ -0,0 +1,22 @@ +%% Copyright (c) 2011-2016 Kazuki Maeda +%% +%% Distributable under the MIT License: +%% http://www.opensource.org/licenses/mit-license.php +%% +\ProvidesPackage{beamercolorthemeBlackboard}[2012/06/07 ] + +\mode + +\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 + + +\endinput diff --git a/beamercolorthemeDarkConsole.sty b/beamercolorthemeDarkConsole.sty new file mode 100644 index 0000000..769d0da --- /dev/null +++ b/beamercolorthemeDarkConsole.sty @@ -0,0 +1,28 @@ +%% Copyright (c) 2013-2016 Kazuki Maeda +%% +%% Distributable under the MIT License: +%% http://www.opensource.org/licenses/mit-license.php +%% +\ProvidesPackage{beamercolorthemeDarkConsole}[2013/05/08 ] + +\mode + +\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 + + +\endinput diff --git a/beamerfontthemeluatexja.sty b/beamerfontthemeluatexja.sty new file mode 100644 index 0000000..26849c9 --- /dev/null +++ b/beamerfontthemeluatexja.sty @@ -0,0 +1,18 @@ +%% Copyright (c) 2011-2016 Kazuki Maeda +%% +%% Distributable under the MIT License: +%% http://www.opensource.org/licenses/mit-license.php +%% +\ProvidesPackage{beamerfontthemeluatexja}[2011/11/03 ] + +\mode + +\RequirePackage{luatexja-fontspec} + +\setmainjfont[NoEmbed]{GothicBBB-Medium} +\setsansjfont[NoEmbed]{GothicBBB-Medium} + +\mode + + +\endinput diff --git a/beamerthemeDarkConsole.sty b/beamerthemeDarkConsole.sty new file mode 100644 index 0000000..1eef2c7 --- /dev/null +++ b/beamerthemeDarkConsole.sty @@ -0,0 +1,53 @@ +%% Copyright (c) 2013-2016 Kazuki Maeda +%% +%% Distributable under the MIT License: +%% http://www.opensource.org/licenses/mit-license.php +%% +\ProvidesPackage{beamerthemeDarkConsole}[2013/05/16 ] + +\mode + +\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 + + +\endinput diff --git a/kmbeamer_color.sty b/kmbeamer_color.sty new file mode 100644 index 0000000..ef2c283 --- /dev/null +++ b/kmbeamer_color.sty @@ -0,0 +1,48 @@ +%% Copyright (c) 2011-2016 Kazuki Maeda +%% +%% 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 diff --git a/kmbeamer_common.sty b/kmbeamer_common.sty new file mode 100644 index 0000000..198cf72 --- /dev/null +++ b/kmbeamer_common.sty @@ -0,0 +1,17 @@ +%% Copyright (c) 2011–2016 Kazuki Maeda +%% +%% 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 diff --git a/pictures/Elixir-Logo.png b/pictures/Elixir-Logo.png new file mode 100644 index 0000000..28fdb4f Binary files /dev/null and b/pictures/Elixir-Logo.png differ diff --git a/pictures/Haskell-Logo.png b/pictures/Haskell-Logo.png new file mode 100644 index 0000000..109cff9 Binary files /dev/null and b/pictures/Haskell-Logo.png differ diff --git a/pictures/Lisplogo_alien_256.png b/pictures/Lisplogo_alien_256.png new file mode 100644 index 0000000..5006f2e Binary files /dev/null and b/pictures/Lisplogo_alien_256.png differ diff --git a/pictures/OCaml_Logo.png b/pictures/OCaml_Logo.png new file mode 100644 index 0000000..32d8656 Binary files /dev/null and b/pictures/OCaml_Logo.png differ diff --git a/pictures/Swift-Logo.png b/pictures/Swift-Logo.png new file mode 100644 index 0000000..20e4d5c Binary files /dev/null and b/pictures/Swift-Logo.png differ