Created
November 26, 2011 18:21
-
-
Save retronym/1396084 to your computer and use it in GitHub Desktop.
universal quantification
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
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