Circular Instance Declarations

Ashley Yakeley ashley@semantic.org
Sun, 07 Sep 2003 21:26:37 -0700


In article <Pine.GSO.4.44.0309072012230.3951-100000@blinky>,
 Brandon Michael Moore <brandon@its.caltech.edu> wrote:

> Actually, I'm surprised someone else has a use for this. I wanted
> circular instances for playing with the paper "Recursion Schemes from
> Comonads". What are you trying to do?

It's for HScheme. The Object type has a pluggable reference type, so 
that both IO-based and pure functional Scheme variants are possible.

The general idea is something like this:

    data Object ref = NilObject |
      PairObject (ref (Object ref)) (ref Object ref));
    
    instance (Eq (ref (Object ref))) => Eq (Object ref) where
       etc.
    
    newtype Constant a = MkConstant a deriving Eq;

    equalConstant :: Object Constant;
    equalConstant = (==);

    equalIORef :: Object IORef;
    equalIORef = (==);

-- 
Ashley Yakeley, Seattle WA