Skip to content

Instantly share code, notes, and snippets.

@manjuraj
Last active January 3, 2016 22:29
Show Gist options
  • Save manjuraj/8528864 to your computer and use it in GitHub Desktop.
Save manjuraj/8528864 to your computer and use it in GitHub Desktop.
Code snippets from "Generics of Higher Kinds" paper
// 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