Skip to content

Instantly share code, notes, and snippets.

@retronym
Created November 26, 2011 18:21
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retronym/1396084 to your computer and use it in GitHub Desktop.
Save retronym/1396084 to your computer and use it in GitHub Desktop.
universal quantification
scala> trait Forall[F[_]]{ def apply[A]: F[A] }
defined trait Forall
scala> type ListFun[A] = List[A] => List[A]
defined type alias ListFun
scala> object Reverse extends Forall[ListFun] { def apply[A] = _.reverse}
defined module Reverse
scala> Reverse[String](List("1", "2"))
res9: List[String] = List(2, 1)
scala> Reverse[Int](List(1, 2))
res10: List[Int] = List(2, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment