chalcolith / rslogic

A logic programming library (inspired by uKanren) in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to support unification for custom types?

liarokapisv opened this issue · comments

Hello, first of all thanks for taking the time to write this library!

I am interested in implementing unification for lists however I a having trouble understanding how to go about this. More specifically I am baffled by State being parameterized by a single type.
Are we supposed to add a single "Term" type and implement Unif for it?

I think I would like to have something like this:

struct Term {
    Num(i64),
    List(Vec<Box<Term>>)
}

How would I go about implementing the Unif trait for it? I am having trouble forwarding the unification to the i64 implementation since it changes the type of the state return. Am I going about this wrong?

I'm afraid I haven't looked at this for over 3 years. I'm surprised it even compiles. If I remember correctly, you need to implement the Unif trait for whatever type you want to use. If I have some free time I'll try to take a look at it.