Skip to content

Instantly share code, notes, and snippets.

@arosien
Created March 14, 2019 19:33
Show Gist options
  • Save arosien/2caee726b9c31c693d7b085d2fe11c30 to your computer and use it in GitHub Desktop.
Save arosien/2caee726b9c31c693d7b085d2fe11c30 to your computer and use it in GitHub Desktop.
import cats._
import cats.data._
import cats.implicits._
object KleisliReader {
val k = Kleisli[Id, Int, String](i => (i + 1).toString)
Contravariant[Reader[?, String]] // not found
Contravariant[Kleisli[Id, ?, String]] // not found
val j: Kleisli[Id, (Int, Int), String] =
k.contramap { case (s: Int, t: Int) => s } // not found
type K[A] = Kleisli[Id, A, String]
val CK = Contravariant[K]
val k2: K[Int] = k
val j2: K[(Int, Int)] =
CK.contramap(k2)(_._1)
// k.contramap(_._1) // not found
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment