We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4d85a7d commit 73c155aCopy full SHA for 73c155a
tests/pos/i5773a.scala
@@ -0,0 +1,17 @@
1
+trait Semigroup[T] {
2
+ def (x: T) combine (y: T): T
3
+}
4
+object Test {
5
+ implicit val IntSemigroup: Semigroup[Int] = new {
6
+ def (x: Int) combine (y: Int): Int = x + y
7
+ }
8
+ implicit def OptionSemigroup[T: Semigroup]: Semigroup[Option[T]] = new {
9
+ def (x: Option[T]) combine (y: Option[T]): Option[T] = for {
10
+ x0 <- x
11
+ y0 <- y
12
+ } yield x0.combine(y0)
13
14
+ 1.combine(2)
15
+ Some(1).combine(Some(2))
16
+ Option(1) combine Option(2)
17
0 commit comments