Created
May 3, 2022 09:25
-
-
Save choplin/0d187de7e4a0f84875a9d8b9a9cf7709 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
import cats._ | |
object Moneys: | |
opaque type Money = Double | |
object Money: | |
def apply(d: Double): Money = d | |
given Monoid[Money] = { | |
import cats.implicits._ | |
summon[Monoid[Double]] | |
} | |
@main def main: Unit = | |
import cats.implicits._ | |
import Moneys._ | |
println(Money(1.0) |+| Money(2.0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment