The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

123avi (31) [Avatar] Offline
#1
Wouldn't it better that the close method will return Try[CloseAccount] and open will return Try[ActiveAccount] this way
credit and debit and close will be able to accept a:ActiveAccount or something like
def debit[A <:ActiveAccount](a: A, amount: Amount): Try[A]

and it seems more expressive. is that make sense ?
Debasish Ghosh (116) [Avatar] Offline
#2
We can do that. The technique is used to enforce type level restriction to prevent illegal states in entities. There's an entire section devoted to using this technique. Have a look at section 4.5.2 where we use Phantom Types to do implement this for another use case.

Thanks.