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?
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.