- About the (simple) exercise
- Higher Order Functions
- Throwing exceptions: here be dragons!!
- Sentinel values: better but not great
- The
Option
: error as an ADT - Functional combinators: add some sugar
- Trapping exceptions
- Defer exception handling
- Monad comprehensions with Arrow.kt
- HOFs (Higher Order Functions)
- Monad
- Functor
- Comprehension
Provide a function that performs a simple arithmetic calculation:
fun calculate(a: Int, b: Int): Result<Int, Int>
- Multiply the two numbers (product)
- Add the two numbers (sum)
- Divide the product (dividend) by the sum (divisor)
- Calculate the quotient and remainder as
Result<Int, Int>
All calculation steps to be performed over a dodgy network!!!
a = 11
b = 5
product = 55
sum = 16
quotient = 3
remainder = 7