Extending core.logic to custom types

I am experimenting with core.logic and want to include my own custom data type to participate in logical expressions:

(deftype Expression [node vars]
  ....)

This is basically a node in a mathematical expression tree containing a node tree and a set of unrelated variables. nodeis either a constant, or a symbol, or a (Operator Expression Expression....)node tree . I would like to be able to use core.logic to manage mathematical expressions and map them to subtrees of such expressions.

How can I do this if possible?

I see from the source code core.logic, there are many protocols , that look as if they were good for expansion (eg IUnifyTerms, IReifyTermsetc.), but it is not clear how they are intended to be used, and which ones I really need to expand.

+5
source share
1 answer

core.logic is designed to extend to user types. However, this is not well documented, because the protocols can be changed, because we find out exactly what is needed. It is worth considering the namespace clojure.core.logic.nominalto understand what is required for the core.logic extension for custom types.

+1
source

All Articles