typed prolog-like term for type inference, with unification and visitor