represents computations defined as sequences of steps: a type with a monad structure defines what it means to chain operations, or nest functions of that type together. This allows the programmer to build pipelines that process data in steps, in which each action is decorated with additional processing rules provided by the monad. *1 Monad (functional programming) - Wikipedia, the free encyclopedia
2. return f(unwrappedValue) directly without rewrapping*3 it *3 monad.map(f) will rewrap value of type U to Monad<U>. If U = Monad<V>, then returning type will have a nested Monad<Monad<V>>, so this is where flatMap shines, by map (unwrap & rewrap) + flatten (re-unwrap) to remove one nest to create Monad<V> *2 Functors, Applicatives, And Monads In Pictures - adit.io
switch x { case _ where x % 15 == 0: return "FizzBuzz" case _ where x % 3 == 0: return "Fizz" case _ where x % 5 == 0: return "Buzz" default: return "\(x)" } } ~>! println // prints each: 1, 2, Fizz, 4, Buzz, ...
always active (may lose data if not subscribed) • uses same underlying source (broadcasting) • Cold Observable ❄ • paused until subscription • clones underlying source (not broadcasting)