Data.Generics generic unification?

John Knottenbelt jak97 at
Wed Mar 24 21:05:39 EST 2004


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

The idea is to do the unifications in a state monad (like ), 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 

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

  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 ()



More information about the Glasgow-haskell-users mailing list