Skip to content

Instantly share code, notes, and snippets.

@hgiddens
Last active December 12, 2015 10:39
Show Gist options
  • Select an option

  • Save hgiddens/4760532 to your computer and use it in GitHub Desktop.

Select an option

Save hgiddens/4760532 to your computer and use it in GitHub Desktop.
trait A
trait B
trait E
trait S {
def publish(e: E): Unit
}
object Foo {
def p[F[+_]](f: F[E])(implicit F: Functor[F], s: S): F[Unit] = f.map(s.publish)
def fn(a: A, b: B): E = new E {}
def test {
implicit val s = new S { def publish(e: E) {} }
p(fn) // lol no
// I want what's effectively an identity function i can pimp onto fn so I can go
p(fn.i)
// and have things actually compile
}
}
@hgiddens
Copy link
Author

e.g. p[({ type l[+a] = (A, B) => a })#l](fn) works but is ugly.

@puffnfresh
Copy link

How horrible is this? :)

object fn extends Function2[A, B, E] {
  type L[+Z] = (A, B) => Z
  def apply(a: A, b: B): E = new E{}
}

p[fn.L](fn)

@hgiddens
Copy link
Author

That's… striking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment