Category theory, composition & functional programming презентация

Содержание

Слайд 2

Introduction

/63

Слайд 3

THIS IS NOT A LECTURE

/63

Слайд 4

Lets inquire and discover together!

/63

Слайд 5

What is programming?

/63

Слайд 6

OOP point of view Class diagram

/63

Слайд 7

OOP point of view Sequence diagram

/63

Слайд 8

FP point of view

/63

Слайд 9

FP point of view

/63

Слайд 10

What is similar between those POVs?

/63

Слайд 11

Composition

/63

Слайд 12

Programming is Composition

/63

Слайд 13

Is there any science which is focused on composition?

/63

Слайд 14

Yes, it is Category Theory

/63

Слайд 15

Why to study CT?

/63

Слайд 16

Source: http://rs.io/why-category-theory-matters/

/63

Слайд 17

Why to study CT?

Extremely general and wide-applicable
Gives the new way (not set-theoretic) to

look at the foundations of mathematics and programming
Connect different fields and shows their similarities

/63

Слайд 18

Why to study CT?

programming

/63

Слайд 19

Why to study CT for software engineer?

Growing complexity of software systems and multicore\distributed

systems revolution
CT is a source of extremely useful programming ideas
Gives you a great theoretic foundation for programming
CT is the kind of math that is particularly well suited for the minds of programmers

/63

Слайд 20

What is a Category?

/63

Слайд 22

Category is:

Objects
Arrows between objects
Composition rule: ( . ) :: (a → b) → (b

→ c) → (a → c)
g . f = \x → g (f x)

/63

Слайд 23

Associativity of composition What?

/63

Слайд 24

Associativity of composition What?

/63

Слайд 25

Order of the operations doesn’t matter

Associativity of composition Why?

/63

Слайд 26

Identity Arrow What?

/63

Слайд 27

 

Identity Arrow What?

/63

Слайд 28

Identity Arrow What?

/63

Слайд 29

It is neutral element (‘zero’) for the composition (id x = х).
It gives

us a possibility to define the notion of sameness - isomorphism:

Identity Arrow Why?

/63

Слайд 30

Examples

/63

Слайд 31

Category 3

/63

Слайд 32

Category 1

/63

Слайд 33

Category 0

/63

Слайд 34

Integer Category

Objects: singleton (set with only one element in it)
Arrows: all possible integers
Composition:

+ - integer addition
Identity: 0 - zero.

/63

Слайд 35

String Category

Objects: singleton
Arrows: all possible strings
Composition: ++ - string concatenation
Identity: «» - empty

string

/63

Слайд 36

Monoids Set-theoretic approach

Set M
Binary operation •: M × M → M
For all a,

b and c in M:
(a • b) • c = a • (b • c)
Exists e in M that for all a in M:
e • a = a • e = a.

/63

Слайд 37

Examples:

Monoids Category-theoretic approach

/63

Слайд 38

Monoids Category-theoretic approach

/63

Слайд 39

Set Category

Objects: all sets.
Arrows: functions between sets.
Identity: id function between sets.
Composition:
( . )

:: (A → B) → (B → C) → (A → C)

/63

Слайд 40

Hask Category

Objects: types in Haskell
Arrows: functions between them (everything is pure!)
Identity: id function:

id x = x.
Composition:
( . ) :: (a → b) → (b → c) → (a → c)

/63

Слайд 42

Functions

/63

Слайд 43

Functions in categories: Functors

/63

Слайд 44

Functors: preserving composition

/63

Слайд 45

Functors: preserving identities

/63

Слайд 46

Functors: in brief

Maps objects to objects
Maps arrows to arrows
Preserve composition and identities

/63

Слайд 47

Example

/63

Слайд 49

Why is that useful?

/63

Слайд 51

41/50

51/63

Слайд 53

Wait, but what if you’ll need
one more container type ?

53/63

Слайд 56

How to rescue the situation?

56/63

Слайд 58

Conclusions and some further thoughts

CT and programming are tightly connected through composition

CT – source of useful patterns for programming: Functors, Monoids, Monads, Lenses, F-algebras, Zippers and more.
CT helps to understand FP better
CT – is in some sense – Science about thinking: the proof is the extremely wide applicability of CT – from logic to biology, from physics and CS to ecology.

/63

Слайд 59

Acknowledgements

/63

Слайд 60

Acknowledgements

/63

Слайд 61

Acknowledgements

Richard Feynman

Jiddu Krishnamurti

/63

Имя файла: Category-theory,-composition-&-functional-programming.pptx
Количество просмотров: 17
Количество скачиваний: 0