Skip to content

Instantly share code, notes, and snippets.

@rossabaker
Created March 3, 2015 05:00
Show Gist options
  • Save rossabaker/bf76b4d3449636a18c12 to your computer and use it in GitHub Desktop.
Save rossabaker/bf76b4d3449636a18c12 to your computer and use it in GitHub Desktop.
scala> class Foo[A]
defined class Foo
scala> trait Monad[F[_]]; trait Catchable[F[_]]; trait Runner[F[_]]
warning: there were 3 feature warning(s); re-run with -feature for details
defined trait Monad
defined trait Catchable
defined trait Runner
scala> implicit def runner[F[_]](implicit M: Monad[F], C: Catchable[F]) = new Runner[F] {}
warning: there were 1 feature warning(s); re-run with -feature for details
runner: [F[_]](implicit M: Monad[F], implicit C: Catchable[F])Runner[F]
scala> implicitly[Runner[Foo]]
<console>:13: error: could not find implicit value for parameter e: Runner[Foo]
implicitly[Runner[Foo]]
^
scala> implicit val FooCatchable = new Catchable[Foo] {}
FooCatchable: Catchable[Foo] = $anon$1@6a41eaa2
scala> implicit val FooMonad = new Monad[Foo] {}
FooMonad: Monad[Foo] = $anon$1@335eadca
scala> implicitly[Runner[Foo]]
res1: Runner[Foo] = $anon$1@7d70d1b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment