<commit_before>Functional programming, chapter 7. Monads and semimonads. Part 1: Intuitions, examples, use cases

Functional programming in the mathematical spirit.

Long and difficult, yet boring explanations given in excruciating detail.

Start by reading the slides, go through the worked examples and exercises. Watch the video when you cannot fully understand something in the slides.

Chapter 7: Computations in a functor context II. Monads and semimonads. Part 1: Practical work with monads and semimonads

Using "functor blocks" (for/yield syntax) for nested iteration
The difference between semimonads and monads
Visual explanation of how flatMap operates on sequences
Intuitions behind using several generator arrows with sequences
The different kinds of monads: list-like, pass/fail, tree-like, single-value
Examples of working with list-like monads: permutations, 8 queens, and other tasks
Using recursion in a functor block
Pass/fail monads: Option, Either, Try, Future
Examples of working with pass/fail monads to achieve safety and to sequence computations
How to make Futures parallel even though they are sequenced within a functor block
Examples of functor-shaped tree constructions
Visual explanation of how flatMap grafts subtrees on trees, and what "flattening" means for trees
Single-value monads: Writer, Reader, Eval, Cont, State; representing a "single value with context"
Using Writer as a semimonad, to keep track of elapsed time
Using the continuation monad to avoid "callback hell"
A systematic derivation of the Writer, Reader, Cont, State type constructors from the type signature of flatMap
Worked examples and exercises

Slides: https://github.com/winitzki/talks/blo...  (Part 2 covers only slides 9 to end)

Code examples: https://github.com/winitzki/scala-exa...

There was an error in the presentation: The power-of-2 tree can be represented as a recursive type constructor, contrary to what I said. Download the latest slides for the corrected text.<commit_msg>update blurb<commit_after>Functional programming, chapter 7. Monads and semimonads. Part 1: Intuitions, examples, use cases

Functional programming in the mathematical spirit.

Long and difficult, yet boring explanations given in excruciating detail.

Start by reading the slides, go through the worked examples and exercises. Watch the video when you cannot fully understand something in the slides.

Chapter 7: Computations in a functor context II. Monads and semimonads. Part 1: Practical work with monads and semimonads

Using "functor blocks" (for/yield syntax) for nested iteration
The difference between semimonads and monads
Visual explanation of how flatMap operates on sequences
Intuitions behind using several generator arrows with sequences
The different kinds of monads: list-like, pass/fail, tree-like, single-value
Examples of working with list-like monads: permutations, 8 queens, and other tasks
Using recursion in a functor block
Pass/fail monads: Option, Either, Try, Future
Examples of working with pass/fail monads to achieve safety and to sequence computations
How to make Futures parallel even though they are sequenced within a functor block
Examples of functor-shaped tree constructions
Visual explanation of how flatMap grafts subtrees on trees, and what "flattening" means for trees
Single-value monads: Writer, Reader, Eval, Cont, State; representing a "single value with context"
Using Writer as a semimonad, to keep track of elapsed time
Using the continuation monad to avoid "callback hell"
A systematic derivation of the Writer, Reader, Cont, State type constructors from the type signature of flatMap
Worked examples and exercises

Slides: https://github.com/winitzki/talks/blob/master/ftt-fp/07-monads-part1.pdf

Code examples: https://github.com/winitzki/scala-examples/tree/master/chapter07/src

There was an error in the presentation: The power-of-2 tree can be represented as a recursive type constructor, contrary to what I said. Download the latest slides for the corrected text.
{'fraction_non_alphanumeric': 0.04605426935524023, 'fraction_numerical': 0.004729897933781429, 'mean_word_length': 5.162576687116564, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4100670', 'n_tokens_mistral': 1040, 'n_tokens_neox': 959, 'n_words': 552}