\documentclass[12pt]{article}
%
% Doug Nychka's LaTeX template (8/13/2004). To create a pdf file from this 
%use pdflatex 
%
% if you read one more comment read the one that starts with ***********
%
%

\nofiles % Suppress all those pesky files!

% include some color support (see examples below)
\usepackage[usenames,dvipsnames]{color}
%
% set background color 
\definecolor{Fcolor}{rgb}{.1,.1,.1} % A cool manila
\definecolor{Pcolor}{rgb}{1,1,1} % A cool manila
\pagecolor{Pcolor} 

% see the Tex files associated with dvipsnames
% for some  predefined colors.


%
% this little style file allows you to 
% step through a page adding items 
% 
\usepackage{isolatin1}
\usepackage{pause}



%
% include a graphics package for importing figures
%
\usepackage{graphicx}
%
% this nice package supports pdf, png, and  jpeg in pdflatex 
%( but just eps for latex)
% png and jpg formats for images are particularly efficient.
% In R use the pdf/png function to create a pdf/png graphics file. 
% If you have a ps file in  UNIX use   convert foo.ps foo.pdf
% to make it into a pdf version 
% 
% If the postscript file has too much white space around it 
% use ps2epsi foo.ps ; epstopdf foo.eps foo.pdf to shrink wrap the figure
%
% or use the utility xv to crop images manually. 
%
%
%******* The magic of pdflatex, 
% These options give information to the acrobat viewer for displaying. 
% Use 
% pdflatex example.tex  
% to create example.pdf for viewing  ( e.g. acroread example.pdf)
% if you comment out the next two lines you can just use latex to make the 
% usual kind of dvi or postscript output. But you will have to use 
% postscript figures instead of pdf ones.
%

\RequirePackage[pdftex,pdfpagemode=none, pdftoolbar=true,
                pdffitwindow=true,pdfcenterwindow=true]{hyperref}
%
% change these to suit! Margins assume an inch as default 
%
\setlength{\paperheight}{7in}
\setlength{\paperwidth}{9in}
\setlength{\textheight}{6.75in}
\setlength{\textwidth}{7.5in}
\setlength{\evensidemargin}{-.75in}
\setlength{\oddsidemargin}{-.75in}
\setlength{\topmargin}{-.75in}
\setlength{\parskip}{.125in}
\setlength{\parindent}{0in}

%
%


% set background color
\definecolor{Pcolor}{rgb}{1,1,1} % A rosy manila
\pagecolor{Pcolor}

% Define heading color. 
\definecolor{Hcolor}{rgb}{.3,.3,.3} % my heading color

%
% these are  my basic page headings 
% note how the color is set 
%
\def\mytitle#1{{\color{Hcolor}{\it \LARGE #1}\\ }}

\def\MYTITLE#1{{\color{Hcolor}{\huge #1}\\
                      \rule[.15in]{\textwidth}{.03in} }}
\def\myTITLE#1{{\color{Hcolor}{\huge #1}\\}}

% just to make the math work, everyone does this differently ...
\newcommand{\BLD}[1]{\mbox{\boldmath $#1$}}

% low tech way to start a new ``slide'' and add a background image
% This has been tuned to the aspect paper sizes declared above. 
\newcommand{\emptyBS}{
   \newpage
   \vspace*{-1in} 
   \hspace*{-.5in}
   %\includegraphics[height=\paperheight, 
   %    width=\paperwidth]{dia0231_med.jpg} % old fire
   %\vspace*{-\paperheight} 
   \vspace*{.5in} 
   %\hspace*{-\paperwidth}
}

\newcommand{\BS}{
   \newpage
   \vspace*{-1in} 
  % \hspace*{-.5in}
	{\begin{center}
Haskell
\end{center}
}
   %\includegraphics[height=\paperheight, 
   %    width=\paperwidth]{dia0230_back.jpg} % old fire
   %\vspace*{-\paperheight} 
   \vspace*{.5in} 
   %\hspace*{-\paperwidth}
}


% uncomment this version for just a new page and no background image. 
% note that you still get a background color from setting \pagecolor above
%\newcommand{\BS}{ \newpage}

\begin{document} 
\hypertarget{start}{}
 %%%%%%%%%%%
 {\color{Black} %begin default text color
 %{\color{White} %begin default text color
 {\LARGE  % fault is LARGE size font
  { \sf   % default face is sans serif
 %%%%%%%%%%%%

   %\vspace*{-1in} 
   %\hspace*{-.5in}
   %\includegraphics[height=\paperheight, 
   %    width=\paperwidth]{dia0230_back.jpg} % old fire
   %\vspace*{-\paperheight} 
   %\vspace*{.5in} 
   %\hspace*{-\paperwidth}
\BS

\MYTITLE{Funktionale Programmierung mit Haskell}


050071 Praktikum zur Fachdidaktik\\
Alexander \"Olzant, 9301547\\
%%%%%%%%%%%%
%%%%%%%%%%%%%%%
\vspace*{.5in} % adjust this to makes things fit nicely 
%\includegraphics[height=1.5in]{dia0231_med.jpg} 
%\hfill
%\includegraphics[height=1in]{dia0231_med.jpg} 
%\\{\it \normalsize
%Supported by the National Science Foundation DMS
%}

\BS
\MYTITLE{Einleitung}

\begin{itemize} 
\item benannt nach Haskell Curry (1900 - 1982)
\item Kommitee: Standardisierung 1987, heute: {\it Haskell 98}
\item Interpreter (hugs, Haskell User's Gofer System)
\item Compiler (Bytecode) + Engine (GHC, {\it Glasgow Haskell Compiler})
\end{itemize} 


\BS
\MYTITLE{Einleitung Sprachbeschreibung Haskell}

\begin{itemize} 
\item sauber konzipierte deklarative funktionale Sprache
\item f\"ur alle Systeme verf\"ugbar, Open-Source-Interpreter
\item durch Tail Recursion ist Rekursion elegant und effizient
\item lazy evaluation: nur Funktionen werden evaluiert, deren Resultate 
 tats\"achlich verwendet werden
 (aber: Eager Haskell mit speculative evaluation)
\end{itemize} 

\BS

\begin{itemize} 
\item Kompakter Code 
\item bringt mathematische Konzepte n\"aher (``Mind Expanding'')
\item keine Nebeneffekte (side effects \\
$\rightarrow$ Auswertungsreihenfolge einerlei (Theorem von Church/Rosser))
\item Zirkul\"are Definitionen sind m\"oglich
\item {\it ``h\"ubscher Code'' (Deklarationen, keine Iterationen)}
\end{itemize} 


\BS
\MYTITLE{Erste Schritte}

Funktionale Sprache $\rightarrow$ Evaluation von Funktionen als 
Grundprinzip

\begin{verbatim}
Prelude> 2*2
4
Prelude> fac 5 where fac = product . enumFromTo 1
120
Prelude> ['h','e','l','l','o'] ++ " world" 
"hello world"
Prelude> do_something 99 (\x -> x * x) where 
                      do_something x fn = fn x
9801
\end{verbatim}

\BS
\MYTITLE{Datentypen}

Integer, Bool, String (eigtl. liste von Char)

Tupel:
\begin{verbatim}
type Tier = (String, String, Int)

name   :: Tier -> String
linne  :: Tier -> String
nummer :: Tier -> Int

name (n,l,u) = n
linne (n,l,u) = l
nummer (n,l,u) = u
\end{verbatim}
pattern matching
\BS

\MYTITLE{Lazy Evaluation}

\begin{verbatim}
Prelude> enumFrom 1
[1,2,3,4,5,6,7,...
\end{verbatim}

endlose Ausgabe der Liste
\pause
\begin{verbatim}
Prelude> take 10 (enumFrom 1)
[1,2,3,4,5,6,7,8,9,10]
\end{verbatim}
... nur die ben\"otigten Elemente werden berechnet


\BS
\MYTITLE{Lambda-Operator, ...}

Zur Definition anonymer Funktionen

\begin{verbatim}
Prelude> do_something 99 (\x -> x * x) where 
                    do_something x fn = fn x
9801
msort = foldl (\s -> \t -> (\(u, v) -> u++[t]++v) 
                           (break (>t) s)  ) []
Prelude> msort "ZyXVAbCdE1230"
"0123ACEVXZbdy"
\end{verbatim}

\BS
\MYTITLE{tail recursion}

Nur ein Stack Frame f\"ur die Rekursion notwendig, daher nicht weniger
effizient und viel eleganter als eine iterative Variante:

\begin{verbatim}
fac :: [Integer] -> [Integer] -> Integer
fac c m  | m == 1 = c 
         | otherwise = fac (c*m) (m-1)

fac> fac 1 99
933262154439441526816992388562667004907159682643816214685929638952175999932
299156089414639761565182862536979208272237582511852109168640000000000000000
000000
\end{verbatim}

\BS
\MYTITLE{Currying}

Syntaktik nur einstellige Funktionen (-$>$ ...), durch Currying

\BS
\MYTITLE{Fallstricke/caveats}
http://www.haskell.org/tutorial/pitfalls.html
\begin{itemize} 
\item Typisierung: keine implizite Umwandlung
\item explizite Rekursion wegen der high order functions meist nicht notwendig\\
\begin{verbatim}
raise :: Num a => a -> [a] -> [a]
raise _ [] = []
raise x (y:ys) = x+y : raise x ys
\end{verbatim}
eleganter:\\
\begin{verbatim}
raise x ys = map (x+) ys
\end{verbatim}
\end{itemize} 
Syntax und Semantik kann f\"ur Anf\"angerInnen verwirrend sein

\BS
\MYTITLE{Iterative Programmeirung}
{\bf nicht} zur Nachahmung, von 
http://www.willamette.edu/~fruehr/haskell/evolution.html
\begin{verbatim}
fac n = result (for init next done)
        where init = (0,1)
              next   (i,m) = (i+1, m * (i+1))
              done   (i,_) = i==n
              result (_,m) = m

for i n d = until d n i
\end{verbatim}
\BS
\MYTITLE{Varianten}

\begin{itemize} 
\item GHS, HUGS s. o.
\item Objektorientierte Versionen: Haskell++, O\'{}Haskell und Mondrian
\item Distributed Haskell 
\item Eager Haskell 
\item Concurrent Clean: GUI-Integration, keine Monaden, sondern unique types\\
http://www.cs.ru.nl/\~{}clean/
\end{itemize} 



%    * Welche "Fallstricke" gibt es in der Sprache (C: "if(c = 3) do_something();")?
%    * Wie einfach ist die Syntax zu erlernen (Java: "public static void main(String[] args)")?
%    * Welche Konzepte vermittelt die Sprache vorwiegend (Rekursion, Vererbung, ...)?
%    * In welcher Reihenfolge werden diese Konzepte erklärt?
%    * Wie könnten erste Übungsbeispiele aussehen?
%    * Gibt es geeignete Entwicklungsumgebungen (IDEs)?
%    * Wie schwierig zu verwenden ist die Sprache (interpretiert, kompiliert, ...)?
%    * Welcher Familie gehört die Sprache an (prozedural, funktional, ...)?
%    * usw. usf. 
%


\BS
\MYTITLE{Links, weitere Informationen}

\begin{itemize} 
\item Eleven Reasons to use Haskell as a Mathematician \\
http://sigfpe.blogspot.com/2006/01/eleven-reasons-to-use-haskell-as.html
\item Haskellwiki \\
http://www.haskell.org/
\item Haskell Reference (zvon.org) \\
http://zvon.org/other/haskell/Outputglobal/index.html
\item Functional Programming in the Real World\\
http://homepages.inf.ed.ac.uk/wadler/realworld/index.html
\end{itemize} 

}% end LARGE font block
} % end of bold face block
} % end default text color block 
\end{document}

