Browse Source

Add TOC and sections

Julian Ospald 4 years ago
parent
commit
b76d88090b
No account linked to committer's email address
1 changed files with 87 additions and 38 deletions
  1. 87
    38
      VL1.tex

+ 87
- 38
VL1.tex View File

@@ -64,8 +64,15 @@
64 64
 
65 65
 \frame{\titlepage}
66 66
 
67
+\begin{frame}[allowframebreaks=0.8]
68
+\frametitle{Table of Contents}
69
+\tableofcontents
70
+\end{frame}
71
+
72
+\section{1. Why haskell?}
73
+
67 74
 \begin{frame}
68
-\frametitle{Why haskell?}
75
+\frametitle{1. Why haskell?}
69 76
 A Haskeller might claim: haskell...
70 77
 \begin{itemize}[<+->]
71 78
 \item eliminates certain classes of bugs
@@ -84,7 +91,7 @@ We'll have to see if this holds true.
84 91
 \end{frame}
85 92
 
86 93
 \begin{frame}[fragile]
87
-\frametitle{Why haskell? (ctn.)}
94
+\frametitle{1. Why haskell? (ctn.)}
88 95
 From C++ std:
89 96
 \setCppCodeStyle
90 97
 \begin{lstlisting}
@@ -113,7 +120,7 @@ Regular C functions in real-world (omitting examples on purpose):
113 120
 \end{frame}
114 121
 
115 122
 \begin{frame}
116
-\frametitle{Why haskell? (ctn.)}
123
+\frametitle{1. Why haskell? (ctn.)}
117 124
 You need to change only one single line in such a C function. You have to know:
118 125
 \begin{itemize}[<+->]
119 126
 \item does the order of function calls matter?
@@ -130,7 +137,7 @@ Conclusion: you really need to understand the complete environment of that line/
130 137
 \end{frame}
131 138
 
132 139
 \begin{frame}
133
-\frametitle{Why haskell? (ctn.)}
140
+\frametitle{1. Why haskell? (ctn.)}
134 141
 But java helps! Does it?
135 142
 Sort of, because:
136 143
 \begin{itemize}[<+->]
@@ -141,7 +148,7 @@ Sort of, because:
141 148
 \end{frame}
142 149
 
143 150
 \begin{frame}
144
-\frametitle{Why haskell? (ctn.)}
151
+\frametitle{1. Why haskell? (ctn.)}
145 152
 Unfortunately, with java we:
146 153
 \begin{itemize}[<+->]
147 154
 \item now got even more states to keep track of (intellectual complexity?)
@@ -156,16 +163,20 @@ Some parts of the implicit state machine have been made explicit by modelling cl
156 163
 We are lucky. There is. It's called \textbf{Haskell}.
157 164
 \end{frame}
158 165
 
166
+\section{2. What is haskell?}
167
+
159 168
 \begin{frame}
160
-\frametitle{What is haskell?}
169
+\frametitle{2. What is haskell?}
161 170
 Haskell is a \textbf{functional}, \textbf{pure}, \textbf{lazy} and \textbf{statically typed} high-level programming language.\\
162 171
 \onslide<+->
163 172
 \vspace{\baselineskip}
164 173
 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?".
165 174
 \end{frame}
166 175
 
176
+\subsection{2.1. What does functional mean?}
177
+
167 178
 \begin{frame}
168
-\frametitle{What does \textbf{functional} mean?}
179
+\frametitle{2.1. What does \textbf{functional} mean?}
169 180
 Think of haskell functions as regular \emph{mathematical} functions.
170 181
 \onslide<+->
171 182
 \vspace{\baselineskip}
@@ -180,15 +191,17 @@ It's all about \emph{input} and \emph{output} of functions! And that's it. Nothi
180 191
 \end{frame}
181 192
 
182 193
 \begin{frame}
183
-\frametitle{What does \textbf{functional} mean? (ctn.)}
194
+\frametitle{2.1. What does \textbf{functional} mean? (ctn.)}
184 195
 \begin{itemize}[<+->]
185 196
 \item \emph{first-class} citizens: functions are values and can be used as such
186 197
 \item a haskell program is what happens when \emph{expressions are evaluated}, it's not about executing instructions
187 198
 \end{itemize}
188 199
 \end{frame}
189 200
 
201
+\subsection{2.2. What does pure mean?}
202
+
190 203
 \begin{frame}
191
-\frametitle{What does \textbf{pure} mean?}
204
+\frametitle{2.2. What does \textbf{pure} mean?}
192 205
 \emph{Referential transparency}, as in:
193 206
 \onslide<+->
194 207
 \begin{itemize}[<+->]
@@ -210,8 +223,10 @@ possible benefits?
210 223
 Question: call-by-value? call-by-reference? call-by-need?
211 224
 \end{frame}
212 225
 
226
+\subsection{2.3. What does lazy mean?}
227
+
213 228
 \begin{frame}
214
-\frametitle{What does \textbf{lazy} mean?}
229
+\frametitle{2.3. What does \textbf{lazy} mean?}
215 230
 In haskell expressions are not evaluated until their results are actually needed. That has a lot of consequences, a few of them being:
216 231
 \onslide<+->
217 232
 \begin{itemize}[<+->]
@@ -221,15 +236,19 @@ In haskell expressions are not evaluated until their results are actually needed
221 236
 \end{itemize}
222 237
 \end{frame}
223 238
 
239
+\subsection{2.4. What does statically typed mean?}
240
+
224 241
 \begin{frame}
225
-\frametitle{What does \textbf{statically typed} mean?}
242
+\frametitle{2.4. What does \textbf{statically typed} mean?}
226 243
 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.\\
227 244
 \vspace{\baselineskip}
228 245
 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).
229 246
 \end{frame}
230 247
 
248
+\subsection{2.5. Summary}
249
+
231 250
 \begin{frame}
232
-\frametitle{What is haskell again?}
251
+\frametitle{2.5. What is haskell again?}
233 252
 Let's reiterate. Haskell is:
234 253
 \begin{itemize}
235 254
 \item functional
@@ -241,8 +260,10 @@ Let's reiterate. Haskell is:
241 260
 \end{itemize}
242 261
 \end{frame}
243 262
 
263
+\section{3. How to think haskell?}
264
+
244 265
 \begin{frame}
245
-\frametitle{How to think haskell?}
266
+\frametitle{3. How to think haskell?}
246 267
 \begin{itemize}[<+->]
247 268
 \item forget about imperative, procedural, OOP; forget about any programming language
248 269
 \item think in types!
@@ -262,8 +283,10 @@ Let's reiterate. Haskell is:
262 283
 \end{itemize}
263 284
 \end{frame}
264 285
 
286
+\section{4. Declarations}
287
+
265 288
 \begin{frame}[fragile]
266
-\frametitle{Declarations}
289
+\frametitle{4. Declarations}
267 290
 Let's go!
268 291
 \setHaskellCodeStyle
269 292
 \begin{lstlisting}
@@ -288,8 +311,10 @@ s = "Hello, world?"
288 311
 \end{lstlisting}
289 312
 \end{frame}
290 313
 
314
+\section{5. Arithmetic and co.}
315
+
291 316
 \begin{frame}[fragile]
292
-\frametitle{Arithmetic and co.}
317
+\frametitle{5. Arithmetic and co.}
293 318
 \setHaskellCodeStyle
294 319
 GHCi:
295 320
 \begin{lstlisting}
@@ -302,8 +327,10 @@ GHCi:
302 327
 \end{lstlisting}
303 328
 \end{frame}
304 329
 
330
+\section{6. Functions and control structures}
331
+
305 332
 \begin{frame}[fragile]
306
-\frametitle{Functions and control structures}
333
+\frametitle{6. Functions and control structures}
307 334
 \setHaskellCodeStyle
308 335
 Let's make our first function. We want something like the following mathematical function\\
309 336
 $f(x) = x * x$\\
@@ -327,7 +354,7 @@ So the function gets an Int and returns an Int. Don't get confused by "\verb|->|
327 354
 \end{frame}
328 355
 
329 356
 \begin{frame}[fragile]
330
-\frametitle{Functions and control structures (ctn.)}
357
+\frametitle{6. Functions and control structures (ctn.)}
331 358
 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:
332 359
 \pause
333 360
 \setHaskellCodeStyle
@@ -344,7 +371,7 @@ What might happen if we remove the second or the third line? What is a \textbf{p
344 371
 \end{frame}
345 372
 
346 373
 \begin{frame}[fragile]
347
-\frametitle{Functions and control structures (ctn.)}
374
+\frametitle{6. Functions and control structures (ctn.)}
348 375
 How about \emph{recursion}? Let's define the modulo of any \emph{Int} to \emph{2}.
349 376
 \pause
350 377
 \setHaskellCodeStyle
@@ -359,8 +386,10 @@ mod2 x
359 386
 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.\\ \code{otherwise} on the last line is just defined as \code{True}, to make these constructs easier to read and catch all other cases of input.
360 387
 \end{frame}
361 388
 
389
+\section{7. Pairs/Tuples}
390
+
362 391
 \begin{frame}[fragile]
363
-\frametitle{Pairs/Tuples}
392
+\frametitle{7. Pairs/Tuples}
364 393
 Defining a pair is easy.
365 394
 \setHaskellCodeStyle
366 395
 \begin{lstlisting}
@@ -375,8 +404,10 @@ sumPair (x, y) = x + y
375 404
 Note: we use \code{(x, y)} notation for both the type and the definition! Those are still two different things. We can also have triples, quadruples etc.
376 405
 \end{frame}
377 406
 
407
+\section{8. Lists}
408
+
378 409
 \begin{frame}[fragile]
379
-\frametitle{Lists}
410
+\frametitle{8. Lists}
380 411
 \setHaskellCodeStyle
381 412
 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.
382 413
 \pause
@@ -403,7 +434,7 @@ infiniteList = [1..]
403 434
 \end{frame}
404 435
 
405 436
 \begin{frame}[fragile]
406
-\frametitle{Lists (ctn.)}
437
+\frametitle{8. Lists (ctn.)}
407 438
 Let's check on a few very common list operations:
408 439
 \setHaskellCodeStyle
409 440
 \begin{lstlisting}
@@ -428,7 +459,7 @@ A String in haskell is just a list of Chars!
428 459
 \end{frame}
429 460
 
430 461
 \begin{frame}[fragile]
431
-\frametitle{Lists (ctn.)}
462
+\frametitle{8. Lists (ctn.)}
432 463
 Again, we can do pattern matching on lists.
433 464
 \setHaskellCodeStyle
434 465
 \begin{lstlisting}
@@ -448,7 +479,7 @@ Note that \code{(x:(y:zs))} may also be written as \code{(x:y:zs)}.
448 479
 \end{frame}
449 480
 
450 481
 \begin{frame}[fragile]
451
-\frametitle{Lists (ctn.)}
482
+\frametitle{8. Lists (ctn.)}
452 483
 Haskell also supports \textbf{list comprehension} which is basically syntactic sugar for what we already know from maths.\\
453 484
 Let's define a set that contains the first ten even natural numbers:\\
454 485
 \pause
@@ -471,8 +502,10 @@ Now let's say we want all numbers between 50 and 100 that have the remainder 0 w
471 502
 \code{x <- [50..100]} is the binding, while \code{mod x 12 == 0} is the predicate, separated by a comma. We can have multiple predicates.
472 503
 \end{frame}
473 504
 
505
+\section{9. Algebraic Data Types}
506
+
474 507
 \begin{frame}[fragile]
475
-\frametitle{Algebraic Data Types}
508
+\frametitle{9. Algebraic Data Types}
476 509
 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:
477 510
 \setHaskellCodeStyle
478 511
 \begin{lstlisting}
@@ -498,7 +531,7 @@ week = [Monday, Tuesday, Thursday, Wednesday
498 531
 \end{frame}
499 532
 
500 533
 \begin{frame}[fragile]
501
-\frametitle{Algebraic Data Types (ctn.)}
534
+\frametitle{9. Algebraic Data Types (ctn.)}
502 535
 And we can again \emph{pattern match} on our \code{WeekDay} type. Let's find out if a given day is a Monday:
503 536
 \pause
504 537
 \setHaskellCodeStyle
@@ -510,7 +543,7 @@ isMonday x      = False
510 543
 \end{frame}
511 544
 
512 545
 \begin{frame}[fragile]
513
-\frametitle{Algebraic Data Types (ctn.)}
546
+\frametitle{9. Algebraic Data Types (ctn.)}
514 547
 But we can do more than enumerations. How about we do some error handling? Let's say we want a function to return an \code{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:
515 548
 \pause
516 549
 \setHaskellCodeStyle
@@ -539,7 +572,7 @@ calcSomething x
539 572
 \end{frame}
540 573
 
541 574
 \begin{frame}[fragile]
542
-\frametitle{Algebraic Data Types (ctn.)}
575
+\frametitle{9. Algebraic Data Types (ctn.)}
543 576
 And pattern match on it as well:
544 577
 \setHaskellCodeStyle
545 578
 \begin{lstlisting}
@@ -551,7 +584,7 @@ So if we got an error, we just return an empty list, otherwise we return a list
551 584
 \end{frame}
552 585
 
553 586
 \begin{frame}[fragile]
554
-\frametitle{Algebraic Data Types (ctn.)}
587
+\frametitle{9. Algebraic Data Types (ctn.)}
555 588
 Let's define something more complex. How about a tree?
556 589
 \pause
557 590
 \setHaskellCodeStyle
@@ -579,7 +612,7 @@ This is just an example. There are endless more ways of trees.
579 612
 \end{frame}
580 613
 
581 614
 \begin{frame}[fragile]
582
-\frametitle{Algebraic Data Types (ctn.)}
615
+\frametitle{9. Algebraic Data Types (ctn.)}
583 616
 Let's build our tree:
584 617
 \setHaskellCodeStyle
585 618
 \begin{lstlisting}
@@ -597,7 +630,7 @@ See board...
597 630
 \end{frame}
598 631
 
599 632
 \begin{frame}[fragile]
600
-\frametitle{Algebraic Data Types (ctn.)}
633
+\frametitle{9. Algebraic Data Types (ctn.)}
601 634
 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.:
602 635
 \setHaskellCodeStyle
603 636
 \begin{lstlisting}
@@ -608,16 +641,20 @@ data AlgDataType = Constr1 Type11 Type12
608 641
 \end{lstlisting}
609 642
 \end{frame}
610 643
 
644
+\section{10. Questions so far?}
645
+
611 646
 \begin{frame}
612
-\frametitle{Questions?}
647
+\frametitle{10. Questions so far?}
613 648
 \begin{itemize}
614 649
 \item How do functions with multiple parameters look like?
615 650
 \item ...
616 651
 \end{itemize}
617 652
 \end{frame}
618 653
 
654
+\section{11. Common misconceptions}
655
+
619 656
 \begin{frame}
620
-\frametitle{Common misconceptions}
657
+\frametitle{11. Common misconceptions}
621 658
 Now that we know the basics, let's clear up some common misconceptions about haskell.
622 659
 \begin{itemize}[<+->]
623 660
 \item haskell is only a language for university professors
@@ -640,8 +677,10 @@ Now that we know the basics, let's clear up some common misconceptions about has
640 677
 You can!
641 678
 \end{frame}
642 679
 
680
+\section{12. Difficulties}
681
+
643 682
 \begin{frame}
644
-\frametitle{Difficulties}
683
+\frametitle{12. Difficulties}
645 684
 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:
646 685
 \begin{itemize}[<+->]
647 686
 \item intellectual complexity? New way of thinking?
@@ -655,8 +694,10 @@ Haskell is very powerful and can be used for pretty much anything. However, ther
655 694
 \end{itemize}
656 695
 \end{frame}
657 696
 
697
+\section{13. Toolchain}
698
+
658 699
 \begin{frame}
659
-\frametitle{Toolchain}
700
+\frametitle{13. Toolchain}
660 701
 How to get started? You need:
661 702
 \begin{itemize}
662 703
 \item \textbf{GHC}: this is the Haskell compiler
@@ -667,8 +708,10 @@ Go to \url{https://www.haskell.org/platform}\\
667 708
 For haskell IDEs, see \url{https://wiki.haskell.org/IDEs}
668 709
 \end{frame}
669 710
 
711
+\section{14. Links}
712
+
670 713
 \begin{frame}
671
-\frametitle{Further reading and useful links}
714
+\frametitle{14. Further reading and useful links}
672 715
 \begin{itemize}
673 716
 \item the most popular haskell course from Brent Yorgey:\\ \url{https://www.seas.upenn.edu/~cis194/fall14/spring13/lectures.html}
674 717
 \item very verbose and enthusiastic haskell book, good for reading once:\\ \url{http://learnyouahaskell.com}
@@ -679,8 +722,10 @@ For haskell IDEs, see \url{https://wiki.haskell.org/IDEs}
679 722
 \end{itemize}
680 723
 \end{frame}
681 724
 
725
+\section{15. What you should know}
726
+
682 727
 \begin{frame}
683
-\frametitle{What you should know now}
728
+\frametitle{15. What you should know now}
684 729
 \begin{itemize}
685 730
 \item what haskell is
686 731
 \item how you write haskell functions
@@ -690,8 +735,10 @@ For haskell IDEs, see \url{https://wiki.haskell.org/IDEs}
690 735
 \end{itemize}
691 736
 \end{frame}
692 737
 
738
+\section{16. Questions for you}
739
+
693 740
 \begin{frame}[fragile]
694
-\frametitle{You should be able to answer these questions}
741
+\frametitle{16. Questions for you}
695 742
 \begin{itemize}
696 743
 \item What are side effects?
697 744
 \item What is referential transparency?
@@ -712,8 +759,10 @@ f 0 = 0.5
712 759
 \end{lstlisting}
713 760
 \end{frame}
714 761
 
762
+\section{17. Sources}
763
+
715 764
 \begin{frame}
716
-\frametitle{Sources}
765
+\frametitle{17. Sources}
717 766
 \begin{itemize}
718 767
 \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}
719 768
 \item a few small pieces from the LYAH book \url{http://learnyouahaskell.com}