Recursion Function defined inside a function Function calling it-self Defining an infinite set of objects by a finitestatement (Recursion Power by Wikipedia) Same behavior as loop, for, while, etc…
Monads => NO State on a world FULL ofState, Looks nonsense!? WTF?
FP/Haskell are against state? Hell No!It’s all about discipline state…
How to Deal with state without globalshared state variables ?
Workaround => Truck Food as Monad !!! (Abstraction)
Monads Deal with side-effects in a functional way Mathematical construct Without monads PURE FP would be nuts Functional able todo IO Good to Control tracking of things Similar to AOP Interceptors Function Composition: LINQ, Unix Pipes You can build environments that support exactlythe features that you want (Scala Option[A]) Encapsulating two things: control flow (Maybe, Error, List, Continuation, parser monads) state propagation (State, Reader, Writer, IO)
Monads have laws… its not just type/classes Make possible assumptions about the type/class and his behavior.1. Left Identity (apply function to value) return x >>= f (the same as) f x sample: return 3 >>= (x -> Just (x+100000))2. Right Identity (value to feed return) m >>= return (the same as) m sample: [1,2,3,4] >>= (x -> return x)3. Associativity (no matter how nested chain) (m >>= f) >>= g (the same as) m >>= (x -> f x >>= g) sample: return (0,0) >>= landRight 2 >>= landLeft 2 >>= landRight 2