Skip to content

Instantly share code, notes, and snippets.

@markehammons
Created June 23, 2013 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markehammons/81edbf78b3872b45b61e to your computer and use it in GitHub Desktop.
Save markehammons/81edbf78b3872b45b61e to your computer and use it in GitHub Desktop.
The problem with implicit classes.
trait Height[P[_]] extends Any {
def self: P[_]
def height: Int
}
object Height {
implicit class ListHeight(val self: List[_]) extends AnyVal with Height[List] {
def height = self.size
}
}
object Main extends App {
import Height._
List(1,2,3).height //works!
def fn[T[_]: Height](t: T[_]) = t.height//doesn't
}
@markehammons
Copy link
Author

I wish they worked.

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