VL1: translate into german
This commit is contained in:
parent
de46c5c18c
commit
19abcc037e
@ -5,14 +5,14 @@
|
||||
% title page information
|
||||
\author{Julian Ospald}
|
||||
\institute{FH Bielefeld}
|
||||
\title{Haskell: introduction}
|
||||
\title{Haskell: \ifger{Einführung}{introduction}}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\frame{\titlepage}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Table of Contents}
|
||||
\frametitle{\ifger{Inhaltsverzeichnis}{Table of Contents}}
|
||||
\tableofcontents[hidesubsections=true]
|
||||
\end{frame}
|
||||
|
||||
|
@ -1,64 +1,64 @@
|
||||
\section{Why haskell?}
|
||||
\section{\ifger{Wieso haskell?}{Why haskell?}}
|
||||
|
||||
\slidetoc
|
||||
|
||||
\slide{./content/VL1_why_haskell1.tex}
|
||||
|
||||
\subsection{Comparsion C and C++}
|
||||
\subsection{\ifger{Vergleich mit C und C++}{Comparsion C and C++}}
|
||||
|
||||
\slide{./content/VL1_why_haskell2.tex}
|
||||
\slide{./content/VL1_why_haskell3.tex}[ (cnt.)]
|
||||
|
||||
\subsection{Comparsion Java}
|
||||
\subsection{\ifger{Vergleich mit Java}{Comparsion Java}}
|
||||
\slide{./content/VL1_why_haskell4.tex}
|
||||
\slide{./content/VL1_why_haskell5.tex}[ (cnt.)]
|
||||
|
||||
|
||||
\section{What is haskell?}
|
||||
\section{\ifger{Was ist Haskell?}{What is haskell?}}
|
||||
|
||||
\slidetoc
|
||||
\slide{./content/VL1_what_is_haskell.tex}
|
||||
|
||||
|
||||
\subsection{What does functional mean?}
|
||||
\subsection{\ifger{Was bedeutet funktional?}{What does functional mean?}}
|
||||
|
||||
\slide{./content/VL1_what_does_functional_mean1.tex}
|
||||
\slide{./content/VL1_what_does_functional_mean2.tex}
|
||||
|
||||
|
||||
\subsection{What does pure mean?}
|
||||
\subsection{\ifger{Was bedeutet pure?}{What does pure mean?}}
|
||||
|
||||
\slide{./content/VL1_what_does_pure_mean.tex}
|
||||
|
||||
\subsection{What does lazy mean?}
|
||||
\subsection{\ifger{Was bedeutet lazy?}{What does lazy mean?}}
|
||||
|
||||
\slide{./content/VL1_what_does_lazy_mean.tex}
|
||||
|
||||
\subsection{What does statically typed mean?}
|
||||
\subsection{\ifger{Was bedeutet statisch typisiert?}{What does statically typed mean?}}
|
||||
|
||||
\slide{./content/VL1_what_does_statically_typed_mean.tex}
|
||||
|
||||
\subsection{What is haskell, Summary}
|
||||
\subsection{\ifger{Zusammenfassung: Was ist Haskell?}{Summary: what is haskell?}}
|
||||
|
||||
\slide{./content/VL1_what_is_haskell_summary.tex}
|
||||
|
||||
\section{How to think haskell?}
|
||||
\section{\ifger{In Haskell denken}{How to think haskell?}}
|
||||
|
||||
\slide{./content/VL1_how_to_think_haskell.tex}
|
||||
|
||||
\section{How to write haskell?}
|
||||
\section{\ifger{Haskell schreiben}{How to write haskell?}}
|
||||
|
||||
\slidetoc
|
||||
|
||||
\subsection{Declarations}
|
||||
\subsection{\ifger{Deklarationen}{Declarations}}
|
||||
|
||||
\slide{./content/VL1_declarations.tex}
|
||||
|
||||
\subsection{Arithmetic and co.}
|
||||
\subsection{\ifger{Arithmetic und co.}{Arithmetic and co.}}
|
||||
|
||||
\slide{./content/VL1_arithmetic_and_co.tex}
|
||||
|
||||
\subsection{Functions and control structures}
|
||||
\subsection{\ifger{Funktionen und Kontrollstrukturen}{Functions and control structures}}
|
||||
|
||||
\slidetoc
|
||||
|
||||
@ -72,11 +72,11 @@
|
||||
|
||||
\slide{./content/VL1_case_of.tex}
|
||||
|
||||
\subsubsection{Guards and recursion}
|
||||
\subsubsection{\ifger{Guards und Rekursion}{Guards and recursion}}
|
||||
|
||||
\slide{./content/VL1_guards_and_recursion.tex}
|
||||
|
||||
\subsection{Lists}
|
||||
\subsection{\ifger{Listen}{Lists}}
|
||||
|
||||
\slide{./content/VL1_lists1.tex}
|
||||
\slide{./content/VL1_lists2.tex}[ (cnt.)]
|
||||
@ -86,11 +86,11 @@
|
||||
|
||||
\slide{./content/VL1_lists4.tex}
|
||||
|
||||
\subsection{Pairs}
|
||||
\subsection{\ifger{Tuple/Paare}{Pairs}}
|
||||
|
||||
\slide{./content/VL1_pairs.tex}
|
||||
|
||||
\subsection{Algebraic Data Types}
|
||||
\subsection{\ifger{Algebraische Datentypen}{Algebraic Data Types}}
|
||||
|
||||
\slide{./content/VL1_ADT1.tex}
|
||||
\slide{./content/VL1_ADT2.tex}[ (cnt.)]
|
||||
@ -102,7 +102,7 @@
|
||||
\slide{./content/VL1_ADT5.tex}
|
||||
\slide{./content/VL1_ADT6.tex}[ (cnt.)]
|
||||
|
||||
\subsubsection{ADTs generalized}
|
||||
\subsubsection{ADTs \ifger{allgemein}{generalized}}
|
||||
|
||||
\slide{./content/VL1_ADT7.tex}
|
||||
|
||||
@ -110,11 +110,11 @@
|
||||
|
||||
\slidetoc
|
||||
|
||||
\subsection{Questions so far?}
|
||||
\subsection{\ifger{Fragen soweit?}{Questions so far?}}
|
||||
|
||||
\slide{./content/VL1_questions_from_you.tex}
|
||||
|
||||
\subsection{Common misconceptions}
|
||||
\subsection{\ifger{Häufige Vorurteile}{Common misconceptions}}
|
||||
|
||||
\slide{./content/VL1_common_misconceptions.tex}
|
||||
|
||||
@ -122,7 +122,7 @@
|
||||
|
||||
\slide{./content/VL1_pitfalls.tex}
|
||||
|
||||
\subsection{Difficulties}
|
||||
\subsection{\ifger{Schwierigkeiten}{Difficulties}}
|
||||
|
||||
\slide{./content/VL1_difficulties1.tex}
|
||||
\slide{./content/VL1_difficulties2.tex}[ (cnt.)]
|
||||
@ -131,19 +131,19 @@
|
||||
|
||||
\slide{./content/VL1_toolchain.tex}
|
||||
|
||||
\section{Reflection}
|
||||
\section{\ifger{Reflexion}{Reflection}}
|
||||
|
||||
\slidetoc
|
||||
|
||||
\subsection{What you should know}
|
||||
\subsection{\ifger{Was Sie wissen sollten}{What you should know}}
|
||||
|
||||
\slide{./content/VL1_what_you_should_know.tex}
|
||||
|
||||
\subsection{Questions for you}
|
||||
\subsection{\ifger{Fragen an Sie}{Questions for you}}
|
||||
|
||||
\slide{./content/VL1_questions_for_you.tex}
|
||||
|
||||
\section{References}
|
||||
\section{\ifger{Referenzen}{References}}
|
||||
|
||||
\slidetoc
|
||||
|
||||
@ -151,6 +151,6 @@
|
||||
|
||||
\slide{../common/content/VL_links.tex}
|
||||
|
||||
\subsection{Sources}
|
||||
\subsection{\ifger{Quellen}{Sources}}
|
||||
|
||||
\slide{../common/content/VL_sources.tex}
|
@ -6,7 +6,7 @@
|
||||
|
||||
% title page information
|
||||
\author{Julian Ospald}
|
||||
\title{Haskell: introduction}
|
||||
\title{Haskell: \ifger{Einführung}{introduction}}
|
||||
|
||||
\maketitle
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
Of course we can also define our own data types in haskell. One very common type is the \emph{enumeration}. For example, we could define a data type for the Week:
|
||||
\ifger{Natürlich können wir auch unsere eigenen Datentypen definieren. Ein sehr häufiger Typ ist die \emph{Enumeration}. Z.b. können wir den Wochentag definieren als:}{Of course we can also define our own data types in haskell. One very common type is the \emph{enumeration}. For example, we could define a data type for the Week:}
|
||||
\begin{haskellcode}
|
||||
data WeekDay = Monday
|
||||
| Tuesday
|
||||
@ -8,10 +8,10 @@ data WeekDay = Monday
|
||||
| Saturday
|
||||
| Sunday
|
||||
\end{haskellcode}
|
||||
This declares the new data type \hinline{WeekDay} with 7 \emph{constructors}. That means \hinline{Monday}, \hinline{Tuesday} etc. are all values of the type \hinline{WeekDay}.
|
||||
\ifger{Dies erzeugt den neuen Datentyp}{This creates the new data type} \hinline{WeekDay} \ifger{mit}{with} 7 \emph{\ifger{Konstruktoren}{constructors}}. \ifger{Das bedeutet, dass}{That means} \hinline{Monday}, \hinline{Tuesday} etc. \ifger{alles Werte vom Typ}{are all values of the type} \hinline{WeekDay}\ifger{ sind.}{.}
|
||||
\pause
|
||||
\\
|
||||
We could now define a whole week, by creating a list:
|
||||
\ifger{Jetzt können wir auch eine ganze Woche definieren mittels einer Liste:}{We could now define a whole week, by creating a list:}
|
||||
\pause
|
||||
\begin{haskellcode}
|
||||
week :: [WeekDay]
|
||||
|
@ -1,4 +1,4 @@
|
||||
And we can again \emph{pattern match} on our \hinline{WeekDay} type. Let's find out if a given day is a Monday:
|
||||
\ifger{Und auch auf unserem \hinline{WeekDay} Typ können wir \emph{pattern matchen}. Wir wollen z.B. herausfinden, ob ein gegebener Tag ein Montag ist:}{And we can again \emph{pattern match} on our \hinline{WeekDay} type. Let's find out if a given day is a Monday:}
|
||||
\pause
|
||||
\begin{haskellcode}
|
||||
isMonday :: WeekDay -> Bool
|
||||
|
@ -1,11 +1,11 @@
|
||||
But we can do more than enumerations. How about we do some error handling? Let's say we want a function to return an \hinline{Int}, but in case something went horribly wrong, we don't just want to return a 0 or some magic number, but a proper error message. Here we go:
|
||||
\ifger{Wir können natürlich auch mehr als nur Enumerationen. Wie wäre es mit Fehlerbehandlung? Z.B. wollen wir eine Funktion, die einen Int zurückgibt, aber falls etwas schief gelaufen ist wollen wir nicht einfach nur eine 0 oder einen magischen Wert, sondern eine richtige Fehlernachricht zurückgeben:}{But we can do more than enumerations. How about we do some error handling? Let's say we want a function to return an \hinline{Int}, but in case something went horribly wrong, we don't just want to return a 0 or some magic number, but a proper error message. Here we go:}
|
||||
\pause
|
||||
\begin{haskellcode}
|
||||
data MaybeInt = NoError Int
|
||||
| Error String
|
||||
\end{haskellcode}
|
||||
\pause
|
||||
So constructors are just \emph{functions}! And they can have arguments, just like functions. Let's check their types:
|
||||
\ifger{D.h. Konstruktoren sind auch gewöhnliche \emph{Funktionen}! Und sie können Argumente haben, genau wie Funktionen. Hier ist die Typsignatur:}{So constructors are just \emph{functions}! And they can have arguments, just like functions. Let's check their types:}
|
||||
\begin{haskellcode}
|
||||
> :t NoError
|
||||
NoError :: Int -> MaybeInt
|
||||
|
@ -1,4 +1,4 @@
|
||||
And now we can do sanity checks:
|
||||
\ifger{Und jetzt können wir Sicherheitsabfragen machen:}{And now we can do sanity checks:}
|
||||
\begin{haskellcode}
|
||||
calcSomething :: Int -> MaybeInt
|
||||
calcSomething x
|
||||
@ -6,10 +6,10 @@ calcSomething x
|
||||
| otherwise = Error "Int out of range!"
|
||||
\end{haskellcode}
|
||||
\pause
|
||||
And pattern match on it as well:
|
||||
\ifger{Und darauf \emph{pattern matchen}}{And pattern match on it as well}:
|
||||
\begin{haskellcode}
|
||||
addIntToList :: MaybeInt -> [Int]
|
||||
addIntToList (NoError x) = [x]
|
||||
addIntToList (Error str) = []
|
||||
\end{haskellcode}
|
||||
So if we got an error, we just return an empty list, otherwise we return a list with the \hinline{Int} as its only element.
|
||||
\ifger{D.h. wenn wir hier einen Error bekommen, geben wir einfach eine leere Liste zurück. Ansonsten geben wir die Liste mit dem \hinline{Int} als einziges Element zurück.}{So if we got an error, we just return an empty list, otherwise we return a list with the \hinline{Int} as its only element.}
|
@ -1,16 +1,16 @@
|
||||
Let's define something more complex. How about a tree?
|
||||
\ifger{Jetzt wollen wir etwas komplexere ADTs definieren. Z.b. einen Tree:}{Let's define something more complex. How about a tree?}
|
||||
\pause
|
||||
\begin{haskellcode}
|
||||
data Tree = Leaf Char
|
||||
| Node Tree Int Tree
|
||||
\end{haskellcode}
|
||||
Uh... that looks mean. Let's examine this.\\
|
||||
\ifger{Verwirrt? Schauen wir genauer hin.}{Uh... that looks mean. Let's examine this.}\\
|
||||
\pause
|
||||
We have:
|
||||
\ifger{Wir haben}{We have}:
|
||||
\begin{itemizep}
|
||||
\item defined a data type \hinline{Tree}
|
||||
\item a constructor \hinline{Leaf} of type \hinline{Tree} with one arguments of type \hinline{Char}
|
||||
\item a constructor \hinline{Node} of type \hinline{Tree} with 3 arguments
|
||||
\item \ifger{den Datentyp \hinline{Tree} definiert}{defined a data type \hinline{Tree}}
|
||||
\item \ifger{einen Konstruktor \hinline{Leaf} vom Typ \hinline{Tree} mit einem Argument vom Typ \hinline{Char}}{a constructor \hinline{Leaf} of type \hinline{Tree} with one arguments of type \hinline{Char}}
|
||||
\item \ifger{einen Konstruktor \hinline{Node} vom Typ \hinline{Tree} mit 3 Argumenten}{a constructor \hinline{Node} of type \hinline{Tree} with 3 arguments}
|
||||
\begin{itemizep}
|
||||
\item \hinline{Tree}
|
||||
\item \hinline{Int}
|
||||
@ -18,6 +18,6 @@ We have:
|
||||
\end{itemizep}
|
||||
\end{itemizep}
|
||||
\slidep
|
||||
That means: a \hinline{Tree} can either be a \hinline{Leaf} or an internal \hinline{Node} with two sub-trees. If we want to create a \hinline{Leaf}, we have to pass the constructor a \hinline{Char}. If we want to create a \hinline{Node}, we have to pass 3 arguments, in order: another \hinline{Tree}, an \hinline{Int} and yet another \hinline{Tree}.\\
|
||||
So we can save information in the leafs (\hinline{Char}) and in the internal nodes (\hinline{Int}).\\
|
||||
This is just an example. There are endless more ways of trees.
|
||||
\ifger{Das bedeutet: ein \hinline{Tree} kann entweder ein \hinline{Leaf} oder eine interne \hinline{Node} sein mit 2 Subtrees. Wollen wir einen \hinline{Leaf} erzeugen, müssen wir dem Konstruktor einen \hinline{Char} übergeben. Wollen wir eine \hinline{Node} bauen, müssen wir 3 Argumente in Reihenfolge übergeben: ein weiterer \hinline{Tree}, ein \hinline{Int} und noch ein \hinline{Tree}.}{That means: a \hinline{Tree} can either be a \hinline{Leaf} or an internal \hinline{Node} with two sub-trees. If we want to create a \hinline{Leaf}, we have to pass the constructor a \hinline{Char}. If we want to create a \hinline{Node}, we have to pass 3 arguments, in order: another \hinline{Tree}, an \hinline{Int} and yet another \hinline{Tree}.}\\
|
||||
\ifger{D.h. wir können Informationen sowohl in den leafs (\hinline{Char}) als auch in den internen nodes (\hinline{Int}) speichern. Dies ist nur ein Beispiel.}{So we can save information in the leafs (\hinline{Char}) and in the internal nodes (\hinline{Int}).\\
|
||||
This is just an example. There are endless more ways of trees.}
|
@ -1,4 +1,4 @@
|
||||
Let's build our tree:
|
||||
\ifger{Wir bauen unseren Tree:}{Let's build our tree:}
|
||||
\begin{haskellcode}
|
||||
tree :: Tree
|
||||
tree = Node
|
||||
@ -10,4 +10,4 @@ tree = Node
|
||||
(Leaf 'z')
|
||||
)
|
||||
\end{haskellcode}
|
||||
See board...
|
||||
\ifger{Siehe Tafel...}{See board...}
|
@ -1,4 +1,4 @@
|
||||
So if we want to generalize it, an algebraic data type has one or more \textbf{constructors}, and each of them can have zero or more arguments. E.g.:
|
||||
\ifger{D.h. wenn wir verallgemeinern müssten, hat ein algebraischer Datentyp einen oder mehr \textbf{Konstruktoren}, von denen jeder null oder mehr \textbf{Argumente} hat. Z.B.:}{So if we want to generalize it, an algebraic data type has one or more \textbf{constructors}, and each of them can have zero or more \textbf{arguments}. E.g.:}
|
||||
\begin{haskellcode}
|
||||
data AlgDataType = Constr1 Type11 Type12
|
||||
| Constr2 Type21
|
||||
|
@ -1,5 +1,4 @@
|
||||
We can also pattern match on the result of a real expression, not just the input. For that, we write:
|
||||
|
||||
\ifger{Wir können auch auf dem Ergebnis eines Ausdruckes pattern matchen, nicht nur auf Eingabeargumente. Dafür schreiben wir:}{We can also pattern match on the result of a real expression, not just the input. For that, we write:}
|
||||
\begin{haskellcode}
|
||||
f :: Int -> Bool
|
||||
f x = case x - 2 of
|
||||
@ -7,4 +6,4 @@ f x = case x - 2 of
|
||||
5 -> True
|
||||
y -> False
|
||||
\end{haskellcode}
|
||||
This allows more powerful pattern matching, especially when we define our own data structures.
|
||||
\ifger{Das erlaubt uns etwas mächtigeres pattern matching}{This allows more powerful pattern matching}.
|
@ -1,7 +1,7 @@
|
||||
Now that we know the basics, let's clear up some common misconceptions about haskell.
|
||||
\ifger{Jetzt, da wir die Grundlagen kennen, sollten wir ein paar häufige Missverständnisse ausräumen:}{Now that we know the basics, let's clear up some common misconceptions about haskell.}
|
||||
\begin{itemizep}
|
||||
\item haskell is only a language for university professors
|
||||
\item haskell is not used in real world, see \url{https://wiki.haskell.org/Haskell_in_industry}
|
||||
\item \ifger{Haskell ist eine Sprache nur für Universitätsprofessoren}{haskell is only a language for university professors}
|
||||
\item \ifger{Haskell wird nicht in der Industrie verwendet, siehe}{haskell is not used in real world, see \url{https://wiki.haskell.org/Haskell_in_industry}}
|
||||
\begin{itemize}
|
||||
\item Microsoft
|
||||
\item NVIDIA
|
||||
@ -10,11 +10,11 @@ Now that we know the basics, let's clear up some common misconceptions about has
|
||||
\item Intel
|
||||
\item AT\Q{&}T
|
||||
\end{itemize}
|
||||
\item you cannot model states in haskell
|
||||
\item you cannot write larger programs in haskell
|
||||
\item you cannot write useful programs in haskell
|
||||
\item you cannot implement imperative algorithms
|
||||
\item you cannot do concurrency, cryptography, web development, ... in haskell
|
||||
\item \ifger{man kann keine Zustände in Haskell modellieren}{you cannot model states in haskell}
|
||||
\item \ifger{man kann keine komplexeren Programme in Haskell schreiben}{you cannot write larger programs in haskell}
|
||||
\item \ifger{man kann keine nützlichen Programme in Haskell schreiben}{you cannot write useful programs in haskell}
|
||||
\item \ifger{man kann keine imperativen Algorithmen in Haskell implementieren}{you cannot implement imperative algorithms}
|
||||
\item \ifger{man kann keine Nebenläufigkeit, Kryptographie, Webdevelopment, ... in Haskell machen}{you cannot do concurrency, cryptography, web development, ... in haskell}
|
||||
\end{itemizep}
|
||||
\slidep
|
||||
You can!
|
||||
\ifger{Doch, kann man! Vorführung?}{You can! Need proof?}
|
@ -1,4 +1,4 @@
|
||||
Let's go!
|
||||
\ifger{Auf!}{Let's go!}
|
||||
\begin{haskellcode}
|
||||
x :: Int
|
||||
x = 3
|
||||
|
@ -1,9 +1,9 @@
|
||||
Haskell is very powerful and can be used for pretty much anything. However, there are difficulties in any language. Let's name a few for haskell:
|
||||
\ifger{Haskell ist sehr mächtig und kann für praktisch alles verwendet werden. Trotzdem hat es wie jede Sprache auch einige Härten bzw. Schwierigkeiten:}{Haskell is very powerful and can be used for pretty much anything. However, there are difficulties in any language. Let's name a few for haskell:}
|
||||
\begin{itemizep}
|
||||
\item intellectual complexity? New way of thinking?
|
||||
\item although you rarely need it in haskell, debugging can be difficult at times
|
||||
\item because the type system is extremely powerful/complex, type error messages can be very confusing and don't always show the error you expected
|
||||
\item no premium-like IDE with every possible feature (yet)
|
||||
\item dynamic linking is sort of WIP yet, lots of ABI breakage
|
||||
\item because most of the world thinks in imperative style languages, it's often difficult to find pseudo-code for functional style languages, so you end up reverse-engineering algorithms
|
||||
\item \ifger{intellektuelle Komplexität? Neue Art zu Denken?}{intellectual complexity? New way of thinking?}
|
||||
\item \ifger{obwohl man es selten braucht... debuggen kann unter Umständen schwierig sein}{although you rarely need it in haskell, debugging can be difficult at times}
|
||||
\item \ifger{da das Typsystem extrem mächtig ist, sind die Fehlermeldungen des type-checkers manchmal verwirrend und zeigen nicht immer den Fehler, den man erwartet hätte}{because the type system is extremely powerful/complex, type error messages can be very confusing and don't always show the error you expected}
|
||||
\item \ifger{(noch) keine premium-IDE mit allen möglichen features}{no premium-like IDE with every possible feature (yet)}
|
||||
\item \ifger{dynamisches linking ist noch WIP und man hat sehr häufig ABI-Inkompatibilität}{dynamic linking is sort of WIP yet, lots of ABI breakage}
|
||||
\item \ifger{da der Groteil der IT in imperativen Programmiersprachen denkt, ist es häufig schwierig pseudo-code für funktionale Sprachen zu finden, weshalb man letztendlich Algorithmen reverse-engineeren muss}{because most of the world thinks in imperative style languages, it's often difficult to find pseudo-code for functional style languages, so you end up reverse-engineering algorithms}
|
||||
\end{itemizep}
|
@ -1,5 +1,5 @@
|
||||
\begin{itemizep}
|
||||
\item some problems that are trivial in imperative languages, can be very difficult to solve in idiomatic haskell and vice versa
|
||||
\item practical cryptography is possible, but a difficult topic in haskell, see \url{https://mail.haskell.org/pipermail/haskell-cafe/2015-February/118059.html}
|
||||
\item although haskell is \emph{lazy}, there are a few things that can break laziness, see \url{https://wiki.haskell.org/Maintaining_laziness}
|
||||
\item \ifger{einige Probleme die trivial in imperativen Sprachen sind, sind sehr schwierig in idiomatischem Haskell zu lösen und umgekehrt}{some problems that are trivial in imperative languages, can be very difficult to solve in idiomatic haskell and vice versa}
|
||||
\item \ifger{praktische Kryptographie ist möglich, aber ein schwieriges Thema, siehe}{practical cryptography is possible, but a difficult topic in haskell, see}\footnote{\url{https://mail.haskell.org/pipermail/haskell-cafe/2015-February/118059.html}}
|
||||
\item \ifger{obwohl Haskell \emph{lazy} ist, gibt es ein paar Dinge, die laziness zunichte machen können, siehe auch}{although haskell is \emph{lazy}, there are a few things that can break laziness, see}\footnote{\url{https://wiki.haskell.org/Maintaining_laziness}}
|
||||
\end{itemizep}
|
@ -1,10 +1,10 @@
|
||||
Let's make our first function. We want something like the following mathematical function\\
|
||||
\ifger{Schreiben wir unsere erste Funktion. Wir wollen etwas wie die folgende mathematische Funktion:}{Let's make our first function. We want something like the following mathematical function}\\
|
||||
$f(x) = x * x$
|
||||
\vspace{\baselineskip}
|
||||
\\
|
||||
How could the haskell code look like?
|
||||
\ifger{Wie könnte der Haskell code aussehen?}{How could the haskell code look like?}
|
||||
\pause
|
||||
Almost the same:
|
||||
\ifger{Beinahe genauso:}{Almost the same:}
|
||||
\begin{haskellcode}
|
||||
f x = x * x
|
||||
\end{haskellcode}
|
||||
@ -13,9 +13,9 @@ GHCi...
|
||||
\pause
|
||||
\vspace{\baselineskip}
|
||||
\\
|
||||
What is a possible type signature for this function?
|
||||
\ifger{Was ist eine mögliche Typsignatur dieser Funktion?}{What is a possible type signature for this function?}
|
||||
\begin{haskellcode}
|
||||
f :: Int -> Int
|
||||
f x = x * x
|
||||
\end{haskellcode}
|
||||
So the function gets an Int and returns an Int. Don't get confused by "\verb|->|". Just think of it as a symbol for separating input and output.
|
||||
\ifger{Also, die Funktion bekommt einen \hinline{Int} als Eingabe und gibt einen \hinline{Int} als Ausgabe zurück. Lasst Euch nicht von}{So the function gets an \hinline{Int} and returns an \hinline{Int}. Don't get confused by} \hinline{->} \ifger{verwirren.}{.} \ifger{Seht es einfach als Symbol zum Trennen von Eingabe und Ausgabe}{Just think of it as a symbol for separating input and output}.
|
@ -1,4 +1,4 @@
|
||||
How about \emph{recursion}? Let's define the modulo of any \emph{Int} to \emph{2}.
|
||||
\ifger{Wie sieht es mit \emph{Rekursion} aus? Wir wollen den Modulo von einem beliebigen \emph{Int} zu \emph{2} definieren.}{How about \emph{recursion}? Let's define the modulo of any \emph{Int} to \emph{2}.}
|
||||
\pause
|
||||
\begin{haskellcode}
|
||||
mod2 :: Int -> Int
|
||||
@ -7,4 +7,4 @@ mod2 x
|
||||
| x - 2 < 0 = x
|
||||
| otherwise = mod2 (x - 2)
|
||||
\end{haskellcode}
|
||||
These \verb#|# things above are called \textbf{guards} and are similar to \emph{pattern matching}. They are processed in order. If the condition on the left side of the equation is true, then it returns what stands on the right side of the equation. If it's false, then it processes the next line.\\ \hinline{otherwise} on the last line is just defined as \hinline{True}, to make these constructs easier to read and catch all other cases of input.
|
||||
\ifger{Diese}{These} \hinline{|} \ifger{Zeichen nennt man \textbf{guards} und sie sind dem \emph{pattern matching} sehr ähnlich. Sie werden von oben nach unten abgearbeitet. Wenn die Bedingung auf der linken Seite der Gleichung wahr ist, dann gibt die gesamte Funktion das heraus, was auf der rechten Seite der Gleichung steht. Ansonsten wird die nächste Zeile ausprobiert. \hinline{otherwise} in der letzten Zeile ist lediglich \hinline{True}, um dieses Konstrukt lesbarer zu machen und fungiert quasi als allgemeines \emph{else}.}{things above are called \textbf{guards} and are similar to \emph{pattern matching}. They are processed in order. If the condition on the left side of the equation is true, then it returns what stands on the right side of the equation. If it's false, then it processes the next line.\\ \hinline{otherwise} on the last line is just defined as \hinline{True}, to make these constructs easier to read and catch all other cases of input.}
|
@ -1,19 +1,19 @@
|
||||
\begin{itemizep}
|
||||
\item forget about imperative, procedural, OOP; forget about any programming language
|
||||
\item think in types!
|
||||
\item \ifger{vergesst was Ihr über imperative, prozedurale oder OOP basierte Sprachen wisst... am besten vergesst alles, was Ihr über Programmiersprachen wisst}{forget about imperative, procedural, OOP; forget about any programming language}
|
||||
\item \ifger{denkt in Typen!}{think in types!}
|
||||
\begin{itemizep}
|
||||
\item don't be afraid of type errors
|
||||
\item let the type-checker do the work for you (does this function do what I think it does?)
|
||||
\item understand functions just by looking at their type signature?
|
||||
\item \ifger{keine Angst vor Typfehlern!}{don't be afraid of type errors}
|
||||
\item \ifger{lass den type-checker die ganze Arbeit tun (macht diese Funktion auch das, was ich denke?)}{let the type-checker do the work for you (does this function do what I think it does?)}
|
||||
\item \ifger{Funktionen nur durch das Lesen ihrer Typsignatur verstehen?}{understand functions just by looking at their type signature?}
|
||||
\end{itemizep}
|
||||
\item think abstract!
|
||||
\item \ifger{abstrakt denken!}{think abstract!}
|
||||
\begin{itemizep}
|
||||
\item don't repeat yourself!
|
||||
\item "develop a solution space, rather than an individual solution" -- Ralf Hinze
|
||||
\item "imagine a graph, rather than a single path" -- Ralf Hinze
|
||||
\item "first solve a more general problem, then extract the interesting bits and pieces by transforming the general program into more specialised ones" -- Ralf Hinze
|
||||
\item ''develop a solution space, rather than an individual solution'' -- Ralf Hinze
|
||||
\item ''imagine a graph, rather than a single path'' -- Ralf Hinze
|
||||
\item ''first solve a more general problem, then extract the interesting bits and pieces by transforming the general program into more specialised ones'' -- Ralf Hinze
|
||||
\end{itemizep}
|
||||
\item solve atomic parts of general problems and combine them into greater solutions
|
||||
\item don't be afraid of recursion!
|
||||
\item write less, think more!
|
||||
\item \ifger{löse atomare Teile eines größeren Problems und kombiniere die Einzellösungen zu größeren Lösungen zusammen}{solve atomic parts of general problems and combine them into greater solutions}
|
||||
\item \ifger{keine Angst vor Rekursion!}{don't be afraid of recursion!}
|
||||
\item \ifger{weniger schreiben, mehr denken!}{write less, think more!}
|
||||
\end{itemizep}
|
@ -1,12 +1,12 @@
|
||||
The list is probably the most basic data structure in Haskell. Like the array in C. It is a singly-linked list and is very lazy. The compiler has numerous ways to optimize lists, so don't be afraid to use them, even for huge things.
|
||||
\ifger{Die Liste ist vermutlich der grundlegendste Datentyp in Haskell, ähnlich wie das Array in C. Sie ist singly-linked und lazy. Der Compiler beherrscht viele Tricks, die Liste zu optimieren, deshalb kann man sie auch für komplexere Probleme benutzen.}{The list is probably the most basic data structure in Haskell. Like the array in C. It is a singly-linked list and is very lazy. The compiler has numerous ways to optimize lists, so don't be afraid to use them, even for huge things.}
|
||||
\pause
|
||||
We build lists by using either the \hinline{[]} notation:
|
||||
\ifger{Wir erzeugen Listen entweder mit der}{We build lists by using either the} \hinline{[]} \ifger{Notation:}{notation:}
|
||||
\begin{haskellcode}
|
||||
list1 :: [Integer]
|
||||
list1 = [1, 2]
|
||||
\end{haskellcode}
|
||||
\pause
|
||||
or by using the \emph{cons} operator \hinline{(:)} which takes an element and a list and produces a new list with the element prepended to the front.
|
||||
\ifger{oder mit dem}{or by using the} \emph{cons} \ifger{Operator}{operator} \hinline{(:)} \ifger{welcher ein Element nimmt und es an den Anfang einer Liste setzt und somit eine neue Liste erzeugt.}{which takes an element and a list and produces a new list with the element prepended to the front.}
|
||||
\begin{haskellcode}
|
||||
emptyList = []
|
||||
|
||||
@ -16,7 +16,7 @@ list2 = 1 : []
|
||||
list3 = [1, 2] == 1 : 2 : []
|
||||
\end{haskellcode}
|
||||
\pause
|
||||
How about something more interesting:
|
||||
\ifger{Wie wäre es mit etwas interessanterem:}{How about something more interesting:}
|
||||
\begin{haskellcode}
|
||||
infiniteList = [1..]
|
||||
\end{haskellcode}
|
@ -1,4 +1,4 @@
|
||||
Let's check on a few very common list operations:
|
||||
\ifger{Ein paar häufig verwendete List-Operationen}{Let's check on a few very common list operations:}
|
||||
\begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
|
||||
> [1, 2] ++ [4, 5] -- append two lists
|
||||
> head [1, 2, 3] -- first element
|
||||
@ -10,7 +10,7 @@ Let's check on a few very common list operations:
|
||||
> elem 7 [1, 2, 3] -- is there a 7 in the list?
|
||||
\end{haskellcode*}
|
||||
\pause
|
||||
A String in haskell is just a list of Chars!
|
||||
\ifger{Ein String in Haskell ist einfach nur eine Liste von Chars!}{A String in haskell is just a list of Chars!}
|
||||
\begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
|
||||
> ['a', 'b', 'c']
|
||||
> 'a' : []
|
||||
|
@ -1,15 +1,15 @@
|
||||
Again, we can do pattern matching on lists.
|
||||
\ifger{Erneut können wir pattern matching anwenden, auch auf Listen.}{Again, we can do pattern matching on lists.}
|
||||
\begin{haskellcode}
|
||||
listLen :: [Integer] -> Integer
|
||||
listLen [] = 0
|
||||
listLen (x:xs) = 1 + listLen xs
|
||||
\end{haskellcode}
|
||||
\pause
|
||||
We can also nest pattern matching:
|
||||
\ifger{Pattern matching können wir auch schachteln:}{We can also nest pattern matching:}
|
||||
\begin{haskellcode}
|
||||
sumEveryTwo :: [Integer] -> [Integer]
|
||||
sumEveryTwo [] = 0
|
||||
sumEveryTwo (x:[]) = [x]
|
||||
sumEveryTwo (x:(y:zs)) = (x + y) : sumEveryTwo zs
|
||||
\end{haskellcode}
|
||||
Note that \hinline{(x:(y:zs))} may also be written as \hinline{(x:y:zs)}.
|
||||
\ifger{Hinweis...}{Note that} \hinline{(x:(y:zs))} \ifger{kann man auch als}{may also be written as} \hinline{(x:y:zs)}\ifger{ schreiben.}{.}
|
@ -1,19 +1,19 @@
|
||||
Haskell also supports \textbf{list comprehension} which is basically syntactic sugar for what we already know from maths.\\
|
||||
Let's define a set that contains the first ten even natural numbers:\\
|
||||
\ifger{Haskell erlaubt auch}{Haskell also supports} \textbf{list comprehension} \ifger{, was eigentlich nur Syntaxsugar ist und der mathematischen Schreibweise sehr ähnelt.}{which is basically syntactic sugar for what we already know from maths.}\\
|
||||
\ifger{Wir wollen ein Set definieren, das die ersten 10 geraden Zahlen beinhaltet:}{Let's define a set that contains the first ten even natural numbers:}\\
|
||||
\pause
|
||||
$S = \{2 \times x\ |\ x \in \mathbb{N},\ x \leq 10\}$
|
||||
\vspace{\baselineskip}
|
||||
\pause
|
||||
\\
|
||||
How does this look in haskell?
|
||||
\ifger{Wie könnte das in Haskell aussehen?}{How does this look in haskell?}
|
||||
\pause
|
||||
\begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
|
||||
> [ 2 * x | x <- [1..10]]
|
||||
\end{haskellcode*}
|
||||
\pause
|
||||
Now let's say we want all numbers between 50 and 100 that have the remainder 0 when divided by 12:
|
||||
\ifger{Jetzt wollen wir alle Zahlen zwischen 50 und 100 die als Rest 0 haben, wenn wir sie modulo 12 nehmen:}{Now let's say we want all numbers between 50 and 100 that have the remainder 0 when divided by 12:}
|
||||
\pause
|
||||
\begin{haskellcode*}{bgcolor=mygrey,frame=single,numbers=none,label=GHCi}
|
||||
> [x | x <- [50..100], mod x 12 == 0]
|
||||
\end{haskellcode*}
|
||||
\hinline{x <- [50..100]} is the binding, while \hinline{mod x 12 == 0} is the predicate, separated by a comma. We can have multiple predicates.
|
||||
\hinline{x <- [50..100]} \ifger{ist das Binding, während}{is the binding, while} \hinline{mod x 12 == 0} \ifger{das Prädikat ist}{is the predicate}, \ifger{getrennt durch ein Komma}{separated by a comma}. \ifger{Wir können mehrere Prädikate haben}{We can have multiple predicates.}
|
@ -1,4 +1,4 @@
|
||||
Defining a pair is easy.
|
||||
\ifger{Ein Tuple zu definieren ist leicht:}{Defining a pair is easy.}
|
||||
\begin{haskellcode}
|
||||
p :: (Int, Char) -- this is the type
|
||||
p = (2, 'y') -- this is how we construct the pair
|
||||
@ -8,4 +8,4 @@ sumPair :: (Int, Int) -> Int
|
||||
sumPair (x, y) = x + y
|
||||
\end{haskellcode}
|
||||
\pause
|
||||
Note: we use \hinline{(x, y)} notation for both the type and the definition! Those are still two different things. We can also have triples, quadruples etc.
|
||||
\ifger{Hinweis: wir benutzen}{Note: we use} \hinline{(x, y)} \ifger{als Notation sowohl für den Typ als auch die Definition! Dies sind trotzdem 2 verschiedene Dinge. Wir können auch Triple, Quadruple etc. haben.}{notation for both the type and the definition! Those are still two different things. We can also have triples, quadruples etc.}
|
@ -1,4 +1,4 @@
|
||||
In haskell we often use \textbf{pattern matching}. That means we define a function multiple times, but e.g. for different values of its input arguments. Let's see:
|
||||
\ifger{In Haskell wird häufig das sogenannte}{In haskell we often use} \textbf{pattern matching}\ifger{ benutzt.}{.} \ifger{Das bedeutet, dass wir eine Funktion mehrmals definieren, aber z.b. für unterschiedliche Werte ihrer Eingabeargumente. Ungefähr so:}{That means we define a function multiple times, but e.g. for different values of its input arguments. Let's see:}
|
||||
\pause
|
||||
\begin{haskellcode}
|
||||
isZero :: Int -> Bool
|
||||
@ -6,8 +6,8 @@ isZero 0 = True
|
||||
isZero x = False
|
||||
\end{haskellcode}
|
||||
\vspace{\baselineskip}
|
||||
So if we pass it 0, we get True. If we do not pass 0, we get False and the value we passed gets basically ignored.
|
||||
\ifger{D.h. wenn wir eine \hinline{0} übergeben, bekommen wir \hinline{True} zurück. Wenn wir keine \hinline{0} übergeben, dann bekommen wir \hinline{False} zurück und der Eingabewert wird quasi nicht weiter betrachtet.}{So if we pass it \hinline{0}, we get \hinline{True}. If we do not pass \hinline{0}, we get \hinline{False} and the value we passed gets basically ignored.}
|
||||
\vspace{\baselineskip}
|
||||
\\
|
||||
\pause
|
||||
What might happen if we remove the second or the third line? What is a \textbf{partial function} and a \textbf{total function}?
|
||||
\ifger{Was könnte passieren wenn wir die 2. oder 3. Zeile löschen? Was ist eine}{What might happen if we remove the second or the third line? What is a} \textbf{partial function} \ifger{und eine}{and a} \textbf{total function}?
|
@ -1,3 +1,3 @@
|
||||
\begin{itemizep}
|
||||
\item none...
|
||||
\item \ifger{keine}{none}...
|
||||
\end{itemizep}
|
@ -1,13 +1,13 @@
|
||||
\begin{itemize}
|
||||
\item What are side effects?
|
||||
\item What is referential transparency?
|
||||
\item Can you have referential transparency with side effects?
|
||||
\item What does the output of a haskell function depend on?
|
||||
\item What is laziness?
|
||||
\item When are types checked in haskell?
|
||||
\item What are the differences between lists and pairs?
|
||||
\item \ifger{was sind Seiteneffekte?}{What are side effects?}
|
||||
\item \ifger{was ist referenzielle Transparenz?}{What is referential transparency?}
|
||||
\item \ifger{kann ich referenzielle Transparenz mit Seiteneffekten haben?}{Can you have referential transparency with side effects?}
|
||||
\item \ifger{wovon hängt die Ausgabe einer Haskell Funktion ab?}{What does the output of a haskell function depend on?}
|
||||
\item \ifger{was ist}{What is} laziness?
|
||||
\item \ifger{Wann werden Typen in Haskell geprüft?}{When are types checked in haskell?}
|
||||
\item \ifger{Was sind die Unterschiede zwischen Listen und Tuplen?}{What are the differences between lists and pairs?}
|
||||
\end{itemize}
|
||||
Does this compile? If not, fix it. Is this a total or a partial function?
|
||||
\ifger{Ist dies eine \emph{total} oder eine \emph{partial} Funktion? Wie müsste man sie eventuell umschreiben?}{Is this a total or a partial function? Would you extend it? How?}
|
||||
\begin{haskellcode}
|
||||
data IntOrDouble = MkDouble Double
|
||||
| MkInt Int
|
||||
|
@ -1,4 +1,4 @@
|
||||
\begin{itemize}
|
||||
\item How do functions with multiple parameters look like?
|
||||
\item \ifger{Wie sehen Funktionen mit mehreren Argumenten aus?}{How do functions with multiple arguments look like?}
|
||||
\item ...
|
||||
\end{itemize}
|
@ -1,8 +1,8 @@
|
||||
How to get started? You need:
|
||||
\ifger{Um loszulegen benötigen wir:}{How to get started? You need:}
|
||||
\begin{itemize}
|
||||
\item \textbf{GHC}: this is the Haskell compiler
|
||||
\item \textbf{GHCi}: this an interactive environment of GHC, similar to the interactive ruby shell \emph{irb}
|
||||
\item \textbf{The Haskell Platform}: a collection including GHC, GHCi and basic libraries
|
||||
\item \textbf{GHC}: \ifger{das ist der Haskell Compiler}{this is the Haskell compiler}
|
||||
\item \textbf{GHCi}: \ifger{das ist die interaktive Compiler-Umgebung, ähnlich der ruby shell \emph{irb}}{this an interactive environment of GHC, similar to the interactive ruby shell \emph{irb}}
|
||||
\item \textbf{The Haskell Platform}: \ifger{eine Kollektion die GHC, GHCi und Standardbibliotheken beinhaltet}{a collection including GHC, GHCi and basic libraries}
|
||||
\end{itemize}
|
||||
Go to \url{https://www.haskell.org/platform}\\
|
||||
For haskell IDEs, see \url{https://wiki.haskell.org/IDEs}
|
||||
\ifger{Siehe}{Go to}\footnote{\url{https://www.haskell.org/platform}}\\
|
||||
\ifger{Für Haskell IDEs, siehe}{For haskell IDEs, see}\footnote{\url{https://wiki.haskell.org/IDEs}}
|
@ -1,13 +1,13 @@
|
||||
Think of haskell functions as regular \emph{mathematical} functions.
|
||||
\ifger{Stell dir Haskell Funktionen als ganz normale \emph{mathematische Funktionen} vor.}{Think of haskell functions as regular \emph{mathematical} functions.}
|
||||
\slidep
|
||||
\vspace{\baselineskip}
|
||||
\begin{center}
|
||||
\includegraphics*[scale=0.35]{./images/function-machine.png}
|
||||
\end{center}
|
||||
\begin{itemizep}
|
||||
\item does this function write to the hard drive?
|
||||
\item does the output depend on anything else except the input (e.g. time, environment, ...)?
|
||||
\item \ifger{schreibt diese Funktion auf die Festplatte?}{does this function write to the hard drive?}
|
||||
\item \ifger{hängt die Ausgabe von irgendetwas ausser der Eingabe ab (z.b. Zeit, Umgebung...)?}{does the output depend on anything else except the input (e.g. time, environment, ...)?}
|
||||
\end{itemizep}
|
||||
\slidep
|
||||
\vspace{\baselineskip}
|
||||
It's all about \emph{input} and \emph{output} of functions! And that's it. Nothing else to worry about.
|
||||
\ifger{Es geht tatsächlich nur um \emph{Eingabe} und \emph{Ausgabe} von Funktionen. Und sonst nichts! Wir haben keine anderen Sorgen.}{It's all about \emph{input} and \emph{output} of functions! And that's it. Nothing else to worry about.}
|
@ -1,4 +1,4 @@
|
||||
So, functional means:
|
||||
\ifger{Funktional bedeutet:}{So, functional means:}
|
||||
\begin{itemizep}
|
||||
\item \emph{first-class} citizens: functions are values and can be used as such
|
||||
\item a haskell program is what happens when \emph{expressions are evaluated}, it's not about executing instructions
|
||||
|
@ -1,7 +1,7 @@
|
||||
In haskell expressions are not evaluated until their results are actually needed. That has a lot of consequences, a few of them being:
|
||||
\ifger{Ausdrücke in Haskell werden erst evaluiert, wenn ihr Ergebnis tatsächlich benötigt wird. Das bringt viele Konsequenzen mit sich. Einige davon sind:}{In haskell expressions are not evaluated until their results are actually needed. That has a lot of consequences, a few of them being:}
|
||||
\slidep
|
||||
\begin{itemizep}
|
||||
\item infinite data structures are now possible (recursive and non-recursive)
|
||||
\item defining new control structures by just defining a function (since not everything is evaluated... who needs if-then-else anyway?)
|
||||
\item important for compositional programming and efficiency
|
||||
\item \ifger{unendliche Datenstrukturen sind möglich, sowohl rekursive als auch nicht-rekursive}{infinite data structures are now possible (recursive and non-recursive)}
|
||||
\item \ifger{neue Kontrollstrukturen können sehr leicht durch Definieren von Funktionen erzeugt werden, wir benötigen nicht unbedingt if-then-else}{defining new control structures by just defining a function (since not everything is evaluated... who needs if-then-else anyway?)}
|
||||
\item \ifger{sehr wichtig für die Programmierung mit Komposition (z.b. Funktionskomposition) und Effizienz}{important for compositional programming and efficiency}
|
||||
\end{itemizep}
|
@ -1,19 +1,19 @@
|
||||
\emph{Referential transparency}, as in:
|
||||
\emph{\ifger{Referenzielle Transparenz}{Referential transparency}}, \ifger{also}{as in}:
|
||||
\slidep
|
||||
\begin{itemizep}
|
||||
\item everything (variables, data structures...) is \emph{immutable}
|
||||
\item expressions never have side-effects (remember: mathematical functions)
|
||||
\item same input $\mapsto$ same output... \emph{always}!
|
||||
\item replace a function with it's (return) value? Yes. What happens in C or java if you do that? Remember \cppinline{void pop();}?
|
||||
\item \ifger{alles (Variablen, Datenstrukturen)}{everything (variables, data structures...)} \ifger{ist}{is} \emph{immutable}
|
||||
\item \ifger{Ausdrücke haben niemals Seiteneffekte (Erinnerung: mathematische Funktionen)}{expressions never have side-effects (remember: mathematical functions)}
|
||||
\item \ifger{gleiche Eingabe}{same input} $\mapsto$ \ifger{gleiche Ausgabe}{same output}... \emph{\ifger{immer}{always}}!
|
||||
\item \ifger{wir können eine Funktion mit ihrem (Rückgabe-)Wert ersetzen... was passiert, wenn wir das in C oder java tun? (Erinnerung:}{replace a function with it's (return) value? Yes. What happens in C or java if you do that? Remember} \cppinline{void pop();}\ifger{)}{?}
|
||||
\end{itemizep}
|
||||
\slidep
|
||||
\vspace{\baselineskip}
|
||||
possible benefits?
|
||||
\ifger{mögliche Vorteile?}{possible benefits?}
|
||||
\begin{itemizep}
|
||||
\item parallelism
|
||||
\item equational reasoning and refactoring
|
||||
\item less bugs!
|
||||
\item \ifger{Parallelisierung}{parallelism}
|
||||
\item \ifger{Denken in Gleichungen und hohes Refactoring-Potenzial}{equational reasoning and refactoring}
|
||||
\item \ifger{weniger Bugs!}{less bugs!}
|
||||
\end{itemizep}
|
||||
\slidep
|
||||
\vspace{\baselineskip}
|
||||
Question: call-by-value? call-by-reference? call-by-need?
|
||||
\ifger{Frage:}{Question:} call-by-value? call-by-reference? call-by-need?
|
@ -1,4 +1,4 @@
|
||||
Every haskell expression has a type and types are always checked at \emph{compile-time}. Programs with errors will not compile and definitely not run.
|
||||
\ifger{Jeder Haskell Ausdruck hat einen Typ und Typen werden immer zur \emph{Kompilierzeit} geprüft}{Every haskell expression has a type and types are always checked at \emph{compile-time}}. \ifger{Programme mit Typfehlern werden nicht kompilieren und erst recht nicht laufen.}{Programs with errors will not compile and definitely not run.}
|
||||
\vspace{\baselineskip}
|
||||
\\
|
||||
It is possible to simulate dynamic types however, i.e. types which may be converted to the type you need them in, following rigid rules. In the end, they are still statically type-checked (as in: the compiler always knows what's going on).
|
||||
\ifger{Es ist jedoch möglich dynamische Typen zu simulieren. D.h. Typen, die wir zu den Typen konvertieren möchten, die wir gerade brauchen. Dabei müssen allerdings sehr starre Regeln eingehalten werden. Am Ende gilt, dass wir trotzdem statische Typisierung haben (also: der Compiler weiss immer was los ist)}{It is possible to simulate dynamic types however, i.e. types which may be converted to the type you need them in, following rigid rules. In the end, they are still statically type-checked (as in: the compiler always knows what's going on).}
|
@ -2,4 +2,4 @@ Haskell is a \textbf{functional}, \textbf{pure}, \textbf{lazy} and \textbf{stati
|
||||
\vspace{\baselineskip}
|
||||
\pause
|
||||
\\
|
||||
A few of the following facts will be white lies. But let's not worry about that. It's maybe more about "how to think in terms of haskell?" than "what is haskell?".
|
||||
\ifger{Ein paar der folgenden Dinge werden vermutlich Notlügen sein. Aber das soll uns nicht weiter stören. Es geht uns mehr um die Frage "Wie denke ich in Haskell"\ als "Was genau ist Haskell?".}{A few of the following facts will be white lies. But let's not worry about that. It's maybe more about "how to think in terms of haskell?" than "what is haskell?".}
|
@ -1,9 +1,9 @@
|
||||
Let's reiterate. Haskell is:
|
||||
\ifger{Um zusammenzufassen, Haskell ist...}{Let's reiterate. Haskell is:}
|
||||
\begin{itemize}
|
||||
\item functional
|
||||
\item \ifger{funktional}{functional}
|
||||
\item pure
|
||||
\item lazy
|
||||
\item statically typed (and truly type-safe)
|
||||
\item even garbage collected
|
||||
\item the world's finest imperative language (what??)
|
||||
\item \ifger{statisch typisiert (und typsicher)}{statically typed (and truly type-safe)}
|
||||
\item \ifger{sogar}{even} garbage collected
|
||||
\item \ifger{die beste imperative Programmiersprache der Welt (was??)}{the world's finest imperative language (what??)}
|
||||
\end{itemize}
|
@ -1,7 +1,7 @@
|
||||
\begin{itemize}
|
||||
\item what haskell is
|
||||
\item how you write haskell functions
|
||||
\item how you handle lists and pairs
|
||||
\item how you do pattern matching
|
||||
\item how you create your own data types
|
||||
\item \ifger{was ist Haskell und seine Vorteile?}{what haskell is and what advantages does it provide?}
|
||||
\item \ifger{wie schreibe ich Haskell Funktionen?}{how you write haskell functions?}
|
||||
\item \ifger{wie gehe ich mit Listen und Tuplen um?}{how you handle lists and pairs?}
|
||||
\item \ifger{wie funktioniert pattern matching?}{how you do pattern matching?}
|
||||
\item \ifger{wie man seine eigenen Datentypen definiert}{how you create your own data types}
|
||||
\end{itemize}
|
@ -1,15 +1,15 @@
|
||||
A Haskeller might claim: haskell...
|
||||
\ifger{Ein Haskeller könnte behaupten: Haskell...}{A Haskeller might claim: haskell...}
|
||||
\begin{itemizep}
|
||||
\item eliminates certain classes of bugs
|
||||
\item not only disallows bad programs, but also defines what constitutes a bad program
|
||||
\item makes it easy to reason about code
|
||||
\item decreases the bus-factor
|
||||
\item makes it possible to apply huge changes to large programs without worrying about the implicit state machine
|
||||
\item makes it easier to program complex problems
|
||||
\item allows for clean APIs, even without any OOP
|
||||
\item a haskell program of 10K LOC isn't that much different to maintain as a 100K LOC
|
||||
\item refactoring in haskell means abstraction
|
||||
\item \ifger{eliminiert eine ganze Klasse von bugs}{eliminates certain classes of bugs}
|
||||
\item \ifger{weist schlechte Programme nicht nur zurück, sondern definiert auch was ein schlechtes Programm ausmacht}{not only disallows bad programs, but also defines what constitutes a bad program}
|
||||
\item \ifger{macht es einfach Schlussfolgerungen innerhalb von Programmen zu ziehen}{makes it easy to reason about code}
|
||||
\item \ifger{verringert den Bus-Faktor}{decreases the bus-factor}
|
||||
\item \ifger{erlaubt es tiefgreifende Änderungen an Programmen zu machen ohne sich über den impliziten Zustandsautomaten Gedanken zu machen}{makes it possible to apply huge changes to large programs without worrying about the implicit state machine}
|
||||
\item \ifger{macht es einfacher komplexe Probleme zu lösen}{makes it easier to solve complex problems}
|
||||
\item \ifger{erlaubt saubere APIs, sogar ohne OOP}{allows for clean APIs, even without any OOP}
|
||||
\item \ifger{ein Haskell Programm mit 10k LOC ist von der Wartung her nicht anders als 100k LOC}{a haskell program of 10K LOC isn't that much different to maintain as a 100K LOC}
|
||||
\item \ifger{Refactoring in Haskell bedeutet Abstraktion}{refactoring in haskell means abstraction}
|
||||
\end{itemizep}
|
||||
\vspace{\baselineskip}
|
||||
\slidep
|
||||
We'll have to see if this holds true.
|
||||
\ifger{Wir werden sehen, ob all dies zutrifft.}{We'll have to see if this holds true.}
|
@ -1,9 +1,9 @@
|
||||
From C++ std:
|
||||
\ifger{Aus der C++ Standard library}{From C++ std}:
|
||||
\begin{cppcode}
|
||||
void pop();
|
||||
\end{cppcode}
|
||||
\pause
|
||||
From the C FLINT library:
|
||||
\ifger{Aus der}{From the} C FLINT library:
|
||||
\begin{ccode}
|
||||
void fmpz_mod_poly_add(
|
||||
fmpz_mod_poly_t res,
|
||||
@ -12,12 +12,12 @@ void fmpz_mod_poly_add(
|
||||
\end{ccode}
|
||||
\vspace{\baselineskip}
|
||||
\pause
|
||||
Regular C functions in real-world (omitting examples on purpose):
|
||||
\ifger{Reguläre C-Funktionen im Alltag (Beispiele absichtlich unterschlagen)}{Regular C functions in real-world (omitting examples on purpose):}
|
||||
\begin{itemizep}
|
||||
\item 100+ LOC
|
||||
\item at least 7 ifs, 4 whiles, 12 variables, 1 goto
|
||||
\item accesses both static and global variables
|
||||
\item indenting level of 5 or more
|
||||
\item a lot of memory management and custom-made error handling
|
||||
\item references everywhere!
|
||||
\item \ifger{mindestens}{at least} 7 ifs, 4 whiles, 12 variables, 1 goto
|
||||
\item \ifger{greift sowohl auf statisch als auch auf globale Variablen zu}{accesses both static and global variables}
|
||||
\item indenting level \ifger{von 5 oder mehr}{of 5 or more}
|
||||
\item \ifger{viel Speicherverwaltung und programmspezifisches Error-Handling}{a lot of memory management and custom-made error handling}
|
||||
\item \ifger{überall Referenzen!}{references everywhere!}
|
||||
\end{itemizep}
|
@ -1,13 +1,13 @@
|
||||
You need to change only one single line in such a C function. You have to know:
|
||||
\ifger{Wir müssen nur eine einzige Zeile in dieser C Funktionen ändern. Dafür sollten wir wissen:}{You need to change only one single line in such a C function. You have to know:}
|
||||
\begin{itemizep}
|
||||
\item does the order of function calls matter?
|
||||
\item how does the change effect the memory management? Do we have memory leaks? Do we access invalid memory?
|
||||
\item does it change the state of static or global variables?
|
||||
\item does it change the state of out-parameters?
|
||||
\item if it changes any of those states, is the function still correct?
|
||||
\item what happens if the program flow reaches this code-path with variable X in that particular state, while variable Z is NULL, and...
|
||||
\item did you just nuke a small former Soviet state?
|
||||
\item \ifger{spielt die Reihenfolge der Funktionen eine Rolle?}{does the order of function calls matter?}
|
||||
\item \ifger{wie beeinflusst die Änderung die Speicherverwaltung? Haben wir memory leaks? Greifen wir auf unerlaubte Speicherbereiche zu?}{how does the change effect the memory management? Do we have memory leaks? Do we access invalid memory?}
|
||||
\item \ifger{ändern wir den Zustand von statischen oder globalen Variablen?}{does it change the state of static or global variables?}
|
||||
\item \ifger{ändern wir den Zustand von out-parametern?}{does it change the state of out-parameters?}
|
||||
\item \ifger{wenn wir irgendeine dieser Zustände ändern, ist die Funktion immer noch korrekt?}{if it changes any of those states, is the function still correct?}
|
||||
\item \ifger{was passiert wenn der Programmfluss diesen Code-Pfad erreicht mit Variable X in diesem Zustand, während Variable Z NULL ist und...}{what happens if the program flow reaches this code-path with variable X in that particular state, while variable Z is NULL, and...}
|
||||
\item \ifger{haben wir gerade einen ehemaligen Sovjetstaat bombardiert?}{did you just nuke a small former Soviet state?}
|
||||
\end{itemizep}
|
||||
\vspace{\baselineskip}
|
||||
\slidep
|
||||
Conclusion: you really need to understand the complete environment of that line/function.
|
||||
\ifger{Schlussfolgerung: wir müssen tatsächlich die vollständige Umgebung der Zeile/Funktion verstehen.}{Conclusion: you really need to understand the complete environment of that line/function.}
|
@ -1,7 +1,7 @@
|
||||
But java helps! Does it?
|
||||
Sort of, because:
|
||||
\ifger{Kann Java hier Abhilfe schaffen?}{But java helps! Does it?}
|
||||
\ifger{Ein wenig, denn:}{Sort of, because:}
|
||||
\begin{itemizep}
|
||||
\item it improves APIs compared to C, since you can hide or encapsulate information in the state of an object
|
||||
\item it has a garbage collector, so you don't need to worry too much about memory
|
||||
\item an experienced programmer will find it easier to manage side-effects in Java, because you can e.g. have every impure functions throw an IO exception
|
||||
\item \ifger{es ermöglicht bessere APIs im Vergleich zu C, da wir Informationen im Zustand eines Objektes verstecken bzw. kapseln können}{it improves APIs compared to C, since you can hide or encapsulate information in the state of an object}
|
||||
\item \ifger{es hat einen garbage collector, also müssen wir uns nicht allzu viele Sorgen um die Speicherverwaltung machen}{it has a garbage collector, so you don't need to worry too much about memory}
|
||||
\item \ifger{ein erfahrener Programmierer wird es teilweise einfacher finden Seiteneffekte in Java zu bewältigen, denn er kann für jede behaftete Funktion IO exceptions schmeissen}{an experienced programmer will find it easier to manage side-effects in Java, because you can e.g. have every impure functions throw an IO exception}
|
||||
\end{itemizep}
|
@ -1,12 +1,12 @@
|
||||
Unfortunately, with java we:
|
||||
\ifger{Leider hat Java auch einige Probleme:}{Unfortunately, with java we:}
|
||||
\begin{itemizep}
|
||||
\item now got even more states to keep track of (intellectual complexity?)
|
||||
\item have clouded the program flow... it's now about object-interaction with their explicit and implicit states and because of the increase of indirection, it might get even harder to do actual abstraction
|
||||
\item still have \textbf{side effects} everywhere: one object changes the state of another and vice versa, may arbitrarily write to the hard drive, do kernel calls or launch a missile
|
||||
\item \ifger{wir müssen uns jetzt um noch mehr Zustände kümmern (intellektuelle Komplexität?)}{now got even more states to keep track of (intellectual complexity?)}
|
||||
\item \ifger{wir haben den Programmfluss verschleiert... jetzt geht es um Objektinteraktion mit ihren impliziten und expliziten Zuständen und aufgrund des erhöhten Levels an Indirektion wird es teilweise noch schwieriger zu abstrahieren}{have clouded the program flow... it's now about object-interaction with their explicit and implicit states and because of the increase of indirection, it might get even harder to do actual abstraction}
|
||||
\item \ifger{wir haben immer noch \textbf{Seiteneffekte} überall: ein Objekt ändert den Zustand eines anderen und umgekehrt, könnte zufällig auf die Festplatte schreiben, den Kernel ansprechen oder eine Rakete starten}{still have \textbf{side effects} everywhere: one object changes the state of another and vice versa, may arbitrarily write to the hard drive, do kernel calls or launch a missile}
|
||||
\end{itemizep}
|
||||
\slidep
|
||||
Some parts of the implicit state machine have been made explicit by modelling classes, but it's still there and we have to deal with it, because we are modelling everything around states. Wouldn't it be nice if we could just forget about the global state machine? Maybe there is even a way to remove side effects and have more "predictability"?
|
||||
\ifger{Einige Teile der impliziten Zustandsmaschine haben wir explizit gemacht durch das modellieren von Klassen, aber sie ist immer noch da und wir müssen damit umgehen, weil wir alles um Zustände herum modellieren. Wäre es nicht schön, wenn wir die implizite Zustandsmaschine einfach vergessen könnten? Vielleicht gibt es sogar einen Weg Seiteneffekte vollständig zu entfernen, um mehr Vorhersagbarkeit zu haben?}{Some parts of the implicit state machine have been made explicit by modelling classes, but it's still there and we have to deal with it, because we are modelling everything around states. Wouldn't it be nice if we could just forget about the global state machine? Maybe there is even a way to remove side effects and have more "predictability"?}
|
||||
\slidep
|
||||
\vspace{\baselineskip}
|
||||
\\
|
||||
We are lucky. There is. It's called \textbf{Haskell}.
|
||||
\ifger{Wir haben Glück. Die Antwort ist: \textbf{Haskell}}{We are lucky. There is. It's called \textbf{Haskell}.}
|
@ -1,3 +1,9 @@
|
||||
% language
|
||||
\usepackage[english,german]{babel}
|
||||
\usepackage{iflang}
|
||||
\babeltags{de = german}
|
||||
\newcommand{\ifger}[2]{\IfLanguageName{german}{#1}{#2}}
|
||||
|
||||
% color definition
|
||||
\definecolor{solarized}{HTML}{002B36}
|
||||
\definecolor{mygreen}{HTML}{009900}
|
||||
|
@ -1,8 +1,8 @@
|
||||
\begin{itemize}
|
||||
\item the most popular haskell course from Brent Yorgey:\\ \url{https://www.seas.upenn.edu/~cis194/fall14/spring13/lectures.html}
|
||||
\item very verbose and enthusiastic haskell book, good for reading once:\\ \url{http://learnyouahaskell.com}
|
||||
\item collection of websites teaching haskell:\\ \url{https://github.com/bitemyapp/learnhaskell}
|
||||
\item haskell programming tips (and wiki):\\ \url{https://wiki.haskell.org/Haskell_programming_tips}
|
||||
\item the standard module (similar to libc in C):\\ \url{https://hackage.haskell.org/package/base-4.7.0.0/docs/Prelude.html}
|
||||
\item debugging in haskell:\\ \url{https://wiki.haskell.org/Debugging}
|
||||
\item \ifger{der wohl populärste Haskell-Kurs von Brent Yorgey}{the most popular haskell course from Brent Yorgey}\footnote{\url{https://www.seas.upenn.edu/~cis194/fall14/spring13/lectures.html}}
|
||||
\item \ifger{sehr ausführliches und enthusiastisches Haskell-Buch, gut zum einmal lesen.}{very verbose and enthusiastic haskell book, good for reading once.}\footnote{\url{http://learnyouahaskell.com}}
|
||||
\item \ifger{eine Kollektion von Webseiten, mit deren Hilfe man Haskell lernen kann}{collection of websites teaching haskell}\footnote{\url{https://github.com/bitemyapp/learnhaskell}}
|
||||
\item \ifger{Haskell Programmiertips (und wiki)}{haskell programming tips (and wiki)}\footnote{\url{https://wiki.haskell.org/Haskell_programming_tips}}
|
||||
\item \ifger{Das Standardmodul (ähnlich wie libc in C)}{the standard module (similar to libc in C)}\footnote{\url{https://hackage.haskell.org/package/base-4.7.0.0/docs/Prelude.html}}
|
||||
\item \ifger{debuggen in Haskell}{debugging in haskell}\footnote{\url{https://wiki.haskell.org/Debugging}}
|
||||
\end{itemize}
|
@ -1,6 +1,6 @@
|
||||
\begin{itemize}
|
||||
\item much content was borrowed or is based on the haskell course from Brent Yorgey:\\ \url{https://www.seas.upenn.edu/~cis194/fall14/spring13/lectures.html}
|
||||
\item a few small pieces from the LYAH book \url{http://learnyouahaskell.com}
|
||||
\item general information from wikipedia: \\ \url{https://en.wikipedia.org}
|
||||
\item general information from haskell wiki: \\ \url{https://wiki.haskell.org}
|
||||
\item \ifger{viel Stoff ist entlehnt von oder basiert auf dem Haskell-Kurs von Brent Yorgey}{much content was borrowed or is based on the haskell course from Brent Yorgey}\footnote{\url{https://www.seas.upenn.edu/~cis194/fall14/spring13/lectures.html}}
|
||||
\item \ifger{ein paar kleinere Teile aus dem LYAH Buch}{a few small pieces from the LYAH book}\footnote{\url{http://learnyouahaskell.com}}
|
||||
\item \ifger{allgemeine Informationen von Wikipedia}{general information from wikipedia}\footnote{\url{https://en.wikipedia.org}}
|
||||
\item \ifger{allgemeine Informationen vom Haskell Wiki}{general information from haskell wiki}\footnote{\url{https://wiki.haskell.org}}
|
||||
\end{itemize}
|
Loading…
Reference in New Issue
Block a user