-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Reference cells that need two independent indices to be accessed. -- -- Reference cells that need two independent indices to be accessed. @package data-quotientref @version 0.1 -- | 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 a and -- b, then if either a or b gets -- cleaned up by the garbage collector, then so does the cell, because it -- would not be able to be accessed anymore. -- -- There are two different types of indices, LeftRef and -- RightRef. You need one of each, of the same type, to access a -- cell. -- -- The name comes from the idea that the product of two indices is a -- reference, so each index is a quotient. -- -- Example usage: -- --
-- 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 --module Data.QuotientRef -- | The left half of a reference cell. Combine this with a RightRef -- to access a cell. data LeftRef a -- | The right half of a reference cell. Combine this with a LeftRef -- to access a cell. data RightRef a newLeft :: IO (LeftRef a) newRight :: IO (RightRef a) -- | Combine the two halves of a reference and return the result if it -- exists. read :: LeftRef a -> RightRef a -> IO (Maybe a) -- | Combine the two halves of a reference and write a value to the -- product. write :: LeftRef a -> RightRef a -> a -> IO ()