Open calvinlfer opened 6 years ago
Mention that instead of imposing a Monad implementation at the trait/class level, you can actually do it at the function level. So
// import flatMap/Monad syntax def capture(amount: Money)(implicit m: Monad[Effect]): Account => Effect[Account] = account => for { accWithMoney <- cancel(amount)(account) // remove the hold accResult <- debit(amount)(accWithMoney) // debit the account } yield accResult
This allows us to be surgical and precise and not require a Monad implementation to use cancel and debit which do not need it
cancel
debit
Return type can also be a Klesili[Effect, Account, Account]
Mention that instead of imposing a Monad implementation at the trait/class level, you can actually do it at the function level. So