Last active
May 24, 2022 18:15
-
-
Save nefilim/44f48974ca4b9b423aea1e46f68afbb3 to your computer and use it in GitHub Desktop.
This file contains 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
object SuppliedSemigroup { | |
import cats.kernel.Semigroup | |
implicit val maxDurationSemigroup: Semigroup[Duration] = Semigroup((a, b) => if (a > b) a else b) | |
// implicit val optionMonoid: Monoid[Option[Duration]] = cats.kernel.instances.option.catsKernelStdMonoidForOption(maxDurationSemigroup) | |
def optionDurationCombineSemigroup(rp1: Option[Duration], rp2: Option[Duration])(implicit mo: Semigroup[Option[Duration]]): Option[Duration] = { | |
mo.combine(rp1, rp2) | |
} | |
def main(args: Array[String]): Unit = { | |
println(optionDurationCombineSemigroup(Some(2.minute), Some(90.seconds))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment