Created
November 13, 2011 20:31
-
-
Save robsimmons/1362633 to your computer and use it in GitHub Desktop.
Contravariance
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
datatype foo = A | B | C | D | |
(*[ datasort ab = A | B ]*) | |
(*[ datasort bc = B | C ]*) | |
(*[ datasort abc = A | B | C ]*) | |
(* This works *) | |
(*[ val x: ab & bc ]*) | |
val x = B | |
(* This, however, does not... | |
(*[ val y: ab & bc ]*) | |
val y = A | |
*) | |
(* Intuition: ab \/ bc = abc *) | |
(*[ val f: (ab -> ab) & (bc -> bc) ]*) | |
fun f A = A | |
| f B = B | |
| f C = C |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment