Created
February 20, 2011 05:21
-
-
Save softprops/835732 to your computer and use it in GitHub Desktop.
trying to recollect type class teachings of Mark Harrah
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 Builder[M[_], N[_]] { | |
type Apply[T] = M[N[T]] | |
} | |
implicit def optionIntListBuilder: Builder[List, Option]#Apply[Int] = List.empty[Option[Int]] | |
// make a list of option[T] | |
def make[T](implicit p: Builder[List, Option]#Apply[T]): List[Option[T]] = p | |
make[Int] // List[Option[Int]] | |
make[String] // error: could not find implicit value for parameter p: List[Option[String]] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment