
What polymorphism and garbage collection have in common (2013) - gbrown_
http://okmij.org/ftp/ML/generalization.html
======
ncmncm
The main thing is that the less you care about performance, the more useful
they both are. And vice versa.

------
sagebird
Is there a more direct way to encode garbage collection in type unification
without separate treatment?

Eg can you chain pure fuctions together that pass a world(memory block) around
inside of some user defined monad that does the memory management/garbage
collection for you?

~~~
vilhelm_s
Back in the 90s there was some work on "region-based memory management", which
is kindof this. The type of every function that allocates memory is
parameterized on a region to allocate it, and the type of every value is
tagged with the region it was allocated in. It's then possible to use
something similar to the Hindley-Milner algorithm to infer what the regions
should be. At the point when Hindley-Milner would generalize to make a
polymorphic type, you know that the corresponding region variable is no longer
"leaking", so you can insert the operations to allocate/free it.

[http://www.elsman.com/mlkit/pdf/toplas98.pdf](http://www.elsman.com/mlkit/pdf/toplas98.pdf)

