Last active
November 26, 2016 09:31
-
-
Save jpablo/6d941ec8737c91585f73d6e66a24b61d to your computer and use it in GitHub Desktop.
It is only safe to forget
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
def Environment[A, X](x: X) = { | |
val a: A = x | |
// this is safe iff X <: A | |
// in other words, if we discard information | |
// (otherwise we might try to use `a` in an operation it doesn't support) | |
// in other words: it is only safe to forget information | |
// another form: | |
def f(a: A) = { | |
// ... | |
} | |
f(x) | |
// again only safe if X <: A | |
// inside f, only information available in A can be used. | |
// another form: | |
def g: A = x | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment