Skip to content

Instantly share code, notes, and snippets.

@einblicker
Created January 22, 2012 11:49
Show Gist options
  • Save einblicker/1656692 to your computer and use it in GitHub Desktop.
Save einblicker/1656692 to your computer and use it in GitHub Desktop.
proof
object Proof {
type Not[A] = A => Nothing
trait All[P[_]] {
def apply[A]: P[A]
}
def DN[A](p: Not[Not[A]]): A =
p(return (_: A))
def DeMorgan[P[_]](p: Not[P[A] forSome {type A}]): All[({type X[A]=Not[P[A]]})#X] =
new All[({type X[A]=Not[P[A]]})#X] {
def apply[A]: Not[P[A]] = (x: P[A]) => p(x)
}
def AllByExist[P[_]](p: Not[Not[P[A]] forSome {type A}]): All[P] =
new All[P] {
def apply[A]: P[A] =
DN(DeMorgan[({type X[A]=Not[P[A]]})#X](p).apply[A])
}
def test = {
val genericNil = AllByExist[List](_(Nil))
val x: List[Int] = genericNil[Int]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment