Implementing RefMonads in Haskell without ST,IO

Tomasz Zielonka t.zielonka@students.mimuw.edu.pl
Fri, 30 May 2003 12:18:08 +0200


Hi!

On Fri, May 30, 2003 at 12:00:26AM -0500, Tim Sweeney wrote:
> Hi Derek,
> 
> How can one implement RefMonad below directly in Haskell?
> 
> But how can one implement RefMonad to support references of all possible
> types simultaneously?
> 
> The problem is that "readRef" needs to return elements of an arbitrary type,
> so it has to be able to extract them from some sort of "heap" function or
> data structure.  But what does the heap data structure look like?  The
> values that "readRef :: r a -> m a" depend on type "a", and I can't figure
> out how to implement that, because "a" is local to that declaration.

Typing is one problem. The second problem is with Garbage Collection.
In the straightforward implementation individual references are not
collected - either the whole heap is collected or nothing at all.

Regards,
Tom

-- 
.signature: Too many levels of symbolic links