Data.Generics generic unification?

John Knottenbelt jak97 at doc.ic.ac.uk
Wed Mar 24 21:05:39 EST 2004


Hi

Has anybody done generic unification algorithm (e.g. using Data.Generics)? 

The idea is to do the unifications in a state monad (like 
http://portal.acm.org/citation.cfm?id=507648&dl=ACM&coll=portal ), but 
without having to have two level types.

It would be cool to have a data type, e.g.

data Var a = Bound a | Unbound

data STVar s a = STRef s (Var a)

So then I could define my own data type, say person, with a mix of logical 
variables and constants:

data Person :: Person s {
            ssn :: Int,
            name :: STVar s String,
            spouse :: STVar s (Person s)
         }

So ssn would be a constant, while name and spouse would be logical variables.

unify would need to be a generic function, bringing together basic functions 
like:

  unifyStringString :: String - > String -> ST s ()
  unifyVarString :: STVar s String - > String -> ST s ()
  (for basic types)

and
  
  genericUnify :: a -> a -> ST s ()
  genericVarActualUnify :: (STVar s a) -> a -> ST s ()
  genericActualVarUnify :: a -> (STVar s a) -> ST s ()
  genericVarVarUnify :: (STVar s a) -> (STVar s a) -> ST s ()

Cheers

John


More information about the Glasgow-haskell-users mailing list