-
-
Save markehammons/81edbf78b3872b45b61e to your computer and use it in GitHub Desktop.
The problem with implicit classes.
This file contains 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 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wish they worked.