Last active
December 12, 2015 10:39
-
-
Save hgiddens/4760532 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } | |
| } |
Author
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)
Author
That's… striking.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
e.g.
p[({ type l[+a] = (A, B) => a })#l](fn)works but is ugly.