First published at 07:06 UTC on March 26th, 2018.
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 understan…
MORE
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 (Part 2 covers only slides 9 to end)
Code examples: https://github.com/winitzki/scala-examples/tree/master/chapter07/src
LESS