Skip to content

Instantly share code, notes, and snippets.

@jpablo
Last active November 26, 2016 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpablo/6d941ec8737c91585f73d6e66a24b61d to your computer and use it in GitHub Desktop.
Save jpablo/6d941ec8737c91585f73d6e66a24b61d to your computer and use it in GitHub Desktop.
It is only safe to forget
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