Last active
January 3, 2016 22:29
-
-
Save manjuraj/8528864 to your computer and use it in GitHub Desktop.
Code snippets from "Generics of Higher Kinds" paper
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
// First-order parametric polymorphism - abstract over types (simple types or proper types) | |
// Higher-order parametric polymorphism - abstract over type constructors (type functions) | |
// Other names for Higher-order polymorphism | |
// - Type constructor polymorphism | |
// - Higher-kinded types | |
// Higher-kinded types enables us to use type constructor as type parameters and abstract type members | |
// Higher-kinded types is a type that abstract over types that abstract over types | |
trait Iterable[T] { | |
def filter(p: T => Boolean): Iterable[T] | |
def remove(p: T => Boolean): Iterable[T] = filter{ x => !p(x) } | |
} | |
trait List[T] { | |
def filter(p: T => Boolean): List[T] | |
def remove(p: T => Boolean): List[T] = filter{ x => !p(x) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment