Apply、Applicative、Monad 等用于猫的逆变函子?

Apply, Applicative, Monad, etc for contravariant functors in cats?

我有以下特点...

import cats._
import cats.implicits._

trait Preference[-A] {
  self =>

  def compare(a1: A, a2: A): Int

  final def ordering[A1 <: A]: Ordering[A1] = {
    new Ordering[A1] {
      def compare(a1: A1, a2: A1): Int = {
        self.compare(a1, a2)
      }
    }
  }

}


object Preference {

  implicit val contravariant: Contravariant[Preference] = {
    new Contravariant[Preference] {
      def contramap[A, B](fa: Preference[A])(f: B => A): Preference[B] = {
        new Preference[B] {
          def compare(b1: B, b2: B): Int = {
            fa.compare(f(b1), f(b2))
          }
        }
      }
    }
  }
}

我想定义 ApplyApplicative,甚至可能 Monad 这个特征的实例,但所有这些类型 类 都是 [=14= 的扩展]. Cats 中是否存在这些类型 类 的逆变函子版本?

Haskell 中 Applicative 的逆变等价物是 Divisible, and cats.ContravariantMonoidal allows to define both of its methods (divide is contramap2, conquer is trivial)。不过,我不能立即确定是否有 Divisible 在猫的意义上必须是 Monoidal

对于 Monad,Kmett 说

There is no contravariant Monad-like. You need C -> C, not C -> C^op. The twist denies you the ability to build nice structure.

还有.