I'm trying to write Robinson's unification algorithm using recursion schemes. The unification algorithm takes two types and spits a result. A type is a:
data TypeF a
= TypeApplication a a
| TypeVariable Name
deriving (Read,Show,Eq,Functor,Foldable,Traversable)
type Type = Fix TypeF
unify :: Type -> Type -> Result
unify = ...
How can this be done elegantly using recursion schemes?
I'd just suggest currying and a hylomorphism.
As an aside, I would probably with
TypeF
as follows, using the recursion-schemes package.This will automatically generate exactly what you want in this case, with no need to use to
Fix
.