-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes
50 lines (39 loc) · 2.42 KB
/
notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Intro
=====
* how much introductory stuff should be there?
* what is the assumend background of the audience?
--> just ask:
* how many people have already seen/done some functional programming?
* how many of them are familiar with Haskell?
* does anybody know what Functors are?
* functional programming intro
* mathematical intro? (category theory)
Why is functional programming awesome?
--------------------------------------
* immutability - variables are immutable - no chance letting anyone overwrite something you needed;
--> calling a function twice with the same arguments will always return the same result - there is no programm state we depend on; so it's much easier to understand and predict the behavior of the programm
* concurrency - because of the immutability, it's not an issue letting several clients accessing the same data - they cannot tamper it anyway
* first class functions - functions can be assigned to variables and passed as arguments to other functions
* elegancy - problems which need loads of code in a procedural or object oriented language often solvable in very few lines of code
Category theory in mathematics
------------------------------
* mathematical abstraction
* many areas could be represented as categories: sets, vector spaces, or types for computer science
* there are mappings between them: an object can be "tranferred" from one category to another
* mappings are structures preservent: we can "map" out data to another category and do some operations on it (because it's easier in this one)
Functors (mathematics)
----------------------
* "A functor associates to every object of one category an object of another category, and to every morphism in the first category a morphism in the second."
* "Functors are structure preserving maps between categories" // this relates to the fmap function
(I need a specific example for this later lists to trees or something like this)
Motivation: why do we actually want to have functors?
Functors
========
* what's the definition of the Functor type class
* ok, let's give an example for an instance of that type class
** List
* informal description
"Types that can act like a box can be functors. You can think of a list as a box that can be empty or have something inside it, including another box."
-- from "Learn U a Haskell for Great Good"
* formal description: Haskell notation + naturality property + the natural transformation
* example for characterizing alpha