|Maintainer||Luke Palmer <firstname.lastname@example.org>|
A Quotient Reference is a reference cell that needs two values to
dereference. In a way it is a two-dimensional table indexed by references.
The trick is that if a cell is indexed by
b, then if either
b gets cleaned up by the garbage collector, then so does the
cell, because it would not be able to be accessed anymore.
The name comes from the idea that the product of two indices is a reference, so each index is a quotient.
do l_1 <- newLeft l_2 <- newLeft r_1 <- newRight r_2 <- newRight write l_1 r_1 "Foo" write l_2 r_1 "Bar" print =<< read l_1 r_1 -- Just "Foo" print =<< read l_1 r_2 -- Nothing print =<< read l_2 r_1 -- Just "Bar" print =<< read l_2 r_2 -- Nothing
The left half of a reference cell. Combine this with a RightRef to access a cell.
The right half of a reference cell. Combine this with a LeftRef to access a cell.
Combine the two halves of a reference and return the result if it exists.