Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.tinkoff.travel.utils
- import cats.{Monoid, MonoidK}
- import shapeless.tag
- import shapeless.tag.@@
- object monoids {
- type Endo[X] = Endo.T[X]
- object Endo {
- abstract class Tag private()
- type T[X] = (X => X) @@ Tag
- def apply[X](f: X => X): T[X] = tag[Tag].apply[X => X](f)
- implicit val endoMonoidK = new MonoidK[T] {
- def empty[A]: T[A] = Endo(identity[A])
- def combineK[A](x: T[A], y: T[A]): T[A] = Endo(x.compose(y))
- }
- implicit def endoMonoid[A] = endoMonoidK.algebra[A]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement