here is another possible implementation of the “ML‐style references” example. do what you want with it.
it is in substance an automated mechanism to nest the single state example. it does not require an universal type (nor a phony failwith), and is in this sense simpler. however, as in Alain Frisch’s implementation of universal type, a reference is a first‐value module with its own constructor (effects here). instead of having an universal list of all the values of all the references, we have nested handlers, one block per reference, plus one for reference creation. the cost of propagating effects through those nested handlers is comparable to the one of finding the value in the list (or would be if the previous implementation took care of removing outdated values from the list).
hello,
here is another possible implementation of the “ML‐style references” example. do what you want with it.
it is in substance an automated mechanism to nest the single state example. it does not require an universal type (nor a phony
failwith
), and is in this sense simpler. however, as in Alain Frisch’s implementation of universal type, a reference is a first‐value module with its own constructor (effects here). instead of having an universal list of all the values of all the references, we have nested handlers, one block per reference, plus one for reference creation. the cost of propagating effects through those nested handlers is comparable to the one of finding the value in the list (or would be if the previous implementation took care of removing outdated values from the list).