All Downloads are FREE. Search and download functionalities are using the official Maven repository.

monocats.instances.comonad.scala Maven / Gradle / Ivy

The newest version!
package monocats.instances

import cats.Comonad
import monocats.MonoComonad
import scala.language.higherKinds

package object comonad extends ComonadInstances

trait ComonadInstances {
  implicit def monocatsComonadInstances[F[_]: Comonad, A] =
    new ComonadMonoComonadInstance[F, A]
}

private[instances] class ComonadMonoComonadInstance[F[_], A](
    implicit F: Comonad[F])
    extends FunctorMonoFunctorInstance[F, A]
    with MonoComonad[F[A]] {
  def extract(fa: F[Element]): Element = F.extract(fa)

  def coflatMap(fa: F[Element])(f: F[Element] => Element): F[Element] =
    F.coflatMap(fa)(f)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy