CLOJURE – Extension Core.Logic to Custom Types

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

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

Basically, this means a node in the mathematical expression tree, including the node tree and a set of unused unbound variables . node is a constant, symbol or (Operator Expression Expression ….) tree node. I want to be able to use core.logic to manipulate mathematical expressions and match subtrees of these expressions.

If possible, How can I do this?

I saw from the core.logic source code that there is a number of protocols that looks like it can be extended (e.g. IUnifyTerms, IReifyTerms, etc.) but they are not completely clear about how these are used, and how I Really need to be extended.

core.logic is designed to be extendable to a custom type. However, because We understand what exactly is needed, so the protocol may change, so it is not documented in detail. It is worth checking the clojure.core.logic.nominal namespace to understand what is required to extend core.logic to custom types.

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

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

Basically, this means a node in a mathematical expression tree, including a node tree and a set of unused unbound variables. node Is a constant, symbol or (Operator Expression Expression ….) tree node. I want to be able to use core.logic to manipulate mathematical expressions and match subtrees of these expressions.

If possible, how can I Can this be done?

I saw from the core.logic source code that there is a number of protocols that looks like it can be extended (e.g. IUnifyTerms, IReifyTerms, etc.) but they are not completely clear about how these are used, and how I It really needs to be extended.

core.logic is designed to be extensible to a custom type. However, since we understand what is needed, the agreement may happen Changes, so it is not documented in detail. It is worth checking the clojure.core.logic.nominal namespace to understand what is required to extend core.logic to custom types.

Leave a Comment

Your email address will not be published.