I need to rename variables for an application where I am unifying terms, and the way I have done it in the past has been to use (gensym)-like features, and replace the name of the var with the gensym-ed name, usually mangled to a string. I also need to compare the names of variables.
so (rename (logvar1 "foo")) would return (logvar1 "#:23322) - or whatever, and I can get hold of the "#:23322" and check it against any other logical vars in the terms.
In haskell, I am not sure how to do that. I have found Data.Unique, which returns a IO Unique. Unique is part of Eq, but of course IO Unique isn't.
What is the best way to write this function
m = newUnique
n = newUnique
test :: (Monad m, Eq a) => m a -> m a -> m Bool
test u1 u2 = do
v1 <- u1
v2 <- u2
if v1 == v2 then return True else return False
I would like True of False back, not IO True or IO False.
Of course, you can't always get what you want.....
I'm grateful for any help. I understand why the IO is there, I'm just not sure how best do deal with it in the rest of my program where I just want to compare