Last active
January 4, 2020 19:39
-
-
Save justinhj/f1f09691dd12806ebe9eebea8a8a5c40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class AccountState(balance: Int, accountHolder: LastOption[String]) | |
object AccountState { | |
implicit def accountStateShow[A] = new Show[AccountState] { | |
def show(a: AccountState): String = { | |
show"Balance: ${a.balance}\nAccount holder: ${a.accountHolder}" | |
} | |
} | |
implicit val accountMonoid = new Monoid[AccountState] { | |
def empty : AccountState = AccountState(0, None) | |
def combine(p1: AccountState, p2: AccountState) : AccountState = { | |
AccountState(p1.balance |+| p2.balance, p1.accountHolder |+| p2.accountHolder) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment