I'm experimenting with core.logic, and want to enable my own custom data type to participate in logic expressions:
(deftype Expression [node vars]
....)
Basically this represents a node in a mathematical expression tree, containing a node tree and a set of unbound variables used. node
is either a constant, a symbol or an (Operator Expression Expression....)
tree node. I'd like to be able to use core.logic to manipulate mathematical expressions, and match against subtrees of such expresssions.
How can I do this, if possible?
I see from the core.logic source code that there are a number of protocols that look like they would be good to extend (e.g. IUnifyTerms
, IReifyTerms
etc.) but it's not totally clear how these are all meant to be used, and which ones I really need to extend.
core.logic is designed to extensible to custom types. However this is not well documented as the protocols are subject to change as we learn what exactly is needed. It's worth examining the clojure.core.logic.nominal
namespace to get a sense of what's required to extend core.logic to custom types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With