Level 1 (Loops) - (map
, reduce
, filter
, more).
Level 2 (Callbacks/Async) - Use Promise
s (or better yet, Future
s).*.
Level 3 (Assignment) - pipe
or compose
functions together to avoid unnecessary intermediate variable declarations.
A wild monad appears! Monet Olé!
Level 4 (null
/undefined
) - Use Maybe
monad.*.
Level 5 (throw
) - Just return
Error
s instead. The function
in this case will have a union/variant return type e.g. Int | Error
. Alternatively, use the Task
monad.
Level 6 (Branches) - Use Either
monad*
Purity enters the stage
Level 7 (Side-effects) - Use I/O Monad*
Continue using other OO patterns!
🚨🚨🚨Use this!🚨🚨🚨: https://mat3e.github.io/brains/# and thank creator
Inspired by: https://www.youtube.com/watch?v=SfWR3dKnFIo