Skip to content

Instantly share code, notes, and snippets.

@jdegoes
Created April 16, 2014 16:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jdegoes/10906010 to your computer and use it in GitHub Desktop.
Save jdegoes/10906010 to your computer and use it in GitHub Desktop.
Scalaz test bed
import scala.language.higherKinds
trait Monad[M[_]] {
implicit def `Monad ~> Functor`[M[_]: Monad]: Functor[M] = new Functor[M]{}
}
trait Functor[F[_]] {
}
object Functor {
implicit val OptionFunctor: Functor[Option] = new Functor[Option]{}
}
case class Foo[A]()
object Foo extends Monad[Foo] {
implicit val M: Monad[Foo] = new Monad[Foo]{}
}
def requiresFunctor[F[_]: Functor, A](f: F[A]) = 42
requiresFunctor(Foo[Int]())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment