Generates a FunctorK instance
Generates a FunctorK instance
scala> import util.Try scala> import cats.~> scala> trait StringAlg[F[_]] { | def head(s: String): F[String] | } scala> val tryInterpreter = new StringAlg[Try] { | //for simplicity we use a Try here, but we are not encouraging it. | def head(s: String): Try[String] = Try(s.head).map(_.toString) | } scala> val derived = cats.tagless.Derive.functorK[StringAlg] scala> val optionInterpreter = derived.mapK(tryInterpreter)(λ[Try ~> Option]{ _.toOption }) scala> optionInterpreter.head("blah") res1: Option[String] = Some(b) scala> optionInterpreter.head("") res2: Option[String] = None