Skip to content

Commit 549a284

Browse files
committed
Fixed README Monoid example
1 parent 90479dc commit 549a284

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ import shapeless3.deriving.*
4040
// Type class definition, eg. from Cats
4141
trait Monoid[A]:
4242
def empty: A
43-
extension (x: A)
44-
@alpha("combine") def |+| (y: A): A
43+
def combine(x: A, y: A): A
44+
extension (x: A) def |+| (y: A): A = combine(x, y)
4545

4646
object Monoid:
47-
inline def apply[A](using ma: Monoid[A]): Monoid[A] = ma
48-
4947
given Monoid[Unit] with
5048
def empty: Unit = ()
5149
def combine(x: Unit, y: Unit): Unit = ()
@@ -75,7 +73,7 @@ case class ISB(i: Int, s: String, b: Boolean) derives Monoid
7573
val a = ISB(23, "foo", true)
7674
val b = ISB(13, "bar", false)
7775

78-
a |+| b // == ISB(36, "foobar", true)
76+
val c = a |+| b // == ISB(36, "foobar", true)
7977
```
8078

8179
A similar derivation for [`Functor`][functor] allows the following,

0 commit comments

Comments
 (0)