File tree 1 file changed +17
-5
lines changed
1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -512,8 +512,11 @@ object hasLength {
512
512
common def unit: This
513
513
}
514
514
515
- extension IntOps for Int : Monoid {
515
+ extension IntSemiGroup for Int : SemiGroup {
516
516
def add(that: Int) = this + that
517
+ }
518
+
519
+ extension IntMonoid for Int : Monoid {
517
520
common def unit = 0
518
521
}
519
522
@@ -567,13 +570,22 @@ object semiGroups {
567
570
}
568
571
}
569
572
570
- implicit object IntOps extends Monoid .Common {
573
+ implicit object IntSemiGroup extends SemiGroup .Common { self =>
574
+ type This = Int
575
+ type Instance = SemiGroup { val `common` : self.type }
576
+ def inject ($this : Int ) = new SemiGroup {
577
+ val `common` : self.type = self
578
+ def add (that : Int ): Int = $this + that
579
+ }
580
+ }
581
+
582
+ implicit object IntMonoid extends Monoid .Common { self =>
571
583
type This = Int
572
- type Instance = Monoid { val `common` : IntOps .type }
584
+ type Instance = Monoid { val `common` : self .type }
573
585
def unit : Int = 0
574
586
def inject ($this : Int ) = new Monoid {
575
- val `common` : IntOps . this . type = IntOps . this
576
- def add (that : This ): This = $this + that
587
+ val `common` : self. type = self
588
+ def add (that : This ): This = IntSemiGroup .inject( $this ).add( that)
577
589
}
578
590
}
579
591
You can’t perform that action at this time.
0 commit comments