From 6e995fc51a9e3ce318b61d67737a9762323f5413 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 18 Apr 2015 16:04:14 +0200 Subject: [PATCH] Fix formatting --- VL1.tex | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/VL1.tex b/VL1.tex index 39f3c77..0378bfa 100644 --- a/VL1.tex +++ b/VL1.tex @@ -135,8 +135,8 @@ Unfortunately, with java we: \onslide<+-> 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"? \onslide<+-> -\\ \vspace{\baselineskip} +\\ We are lucky. There is. It's called \textbf{Haskell}. \end{frame} @@ -223,8 +223,9 @@ In haskell expressions are not evaluated until their results are actually needed \begin{frame} \frametitle{2.4. What does \textbf{statically typed} mean?} -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.\\ +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. \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). \end{frame} @@ -320,8 +321,9 @@ GHCi: \begin{frame}[fragile] \frametitle{4.3. Functions and control structures} Let's make our first function. We want something like the following mathematical function\\ -$f(x) = x * x$\\ +$f(x) = x * x$ \vspace{\baselineskip} +\\ How could the haskell code look like? \pause Almost the same: @@ -329,9 +331,10 @@ Almost the same: f x = x * x \end{haskellcode} \vspace{\baselineskip} -GHCi...\\ +GHCi... \pause \vspace{\baselineskip} +\\ What is a possible type signature for this function? \begin{haskellcode} f :: Int -> Int @@ -351,8 +354,9 @@ 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.\\ +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. \vspace{\baselineskip} +\\ What might happen if we remove the second or the third line? What is a \textbf{partial function} and a \textbf{total function}? \end{frame} @@ -446,9 +450,10 @@ Note that \code{(x:(y:zs))} may also be written as \code{(x:y:zs)}. 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:\\ \pause -$S = \{2 \times x\ |\ x \in \mathbb{N},\ x \leq 10\}$\\ +$S = \{2 \times x\ |\ x \in \mathbb{N},\ x \leq 10\}$ \vspace{\baselineskip} \pause +\\ How does this look in haskell? \pause \begin{haskellcode}