Tomer Ben David (8) [Avatar] Offline
So the account service looks as following:

trait AccountService[Account, Amount, Balance] { #A
open(no: String, name: String, openDate: Option[Date]): Try[Account]
close(account: Account, closeDate: Option[Date]): Try[Account]
debit(account: Account, amount: Amount): Try[Account]
credit(account: Account, amount: Amount): Try[Account]
balance(account: Account): Try[Balance]

so its great it has Try as return type so it can be combined with other operations. So Try is great but it scares me because what if at some point in future I would find out I want this API to be async? I would then need to change it to Future (or to something else). So is there a way out of this? can I have Try or Future or some other combinator that will allow me to have changes in requirements which are unknown today (lets say in future it was unknown that I would need to change the api to async) without chanign the signature of my API?

Debasish Ghosh (116) [Avatar] Offline
I discuss exactly this topic in chapter 6, section 6.2. Using the power of type system and monad transformers you can achieve this. Feel free to get back if you need more information on this even after reading section 6.2.