- A practical example of TDDing a bowling game then refactoring to safely use
undefined(& killingnulltoo) with a "Maybe/Optional" type (a Monad). - About the game, Bowling 101
- TDD bowling solution using a Maybe on branch
safe-undefined, see README.
Maybe source code, See notes in comments
Tests for Maybe type which show how it works... how to operate on values in a container type. See the tests using .map, .chain, and .ap
Bowling game src code and tests using the Maybe type. See the roll function and frame function which use a Maybe; and notice that the scoring functions operate on the values contained in the Maybe.
There are some functional programing utilities methods here, for partial application and currying.
- Article on Why Maybe
- Article with pictures on Functors, Applicatives, Monads
Libraries:
Functional programming: