I agree; I don't need dynamic rules. I more needed a hint as to the fact that they are supplied and loaded upon mk-session
.
To that end, I tried your advice, I think I did it faithfully, and wasn't able to make it work yet. My adjustments are at this commit: https://github.com/mpettis/clara-ns-ex/tree/0bdb72e98a8ef657de08579af6ee993c9008a738
When I run that, I still get that Myfact
class cannot be found. I think I'm probably missing something about using defrecord
definitions from other namespaces.
Also, for a baseline, this is how I make it work when everything is in the same namespace... https://github.com/mpettis/clara-ns-ex/blob/nonamespace/src/clara_ns_ex/core.clj
@matthew.pettis so you’re issue isn’t just referring to record symbols. Have to follow normal clojure symbol resolution rules.
So you require the ns that defines the records - to ensure it is compiled.
Then you typically would use :import in clj (not cljs) to refer to the record class name as the shortened version
Otherwise you’d have to fully qualify it each reference clara_ns_ex.facts.Myfact
Thanks. I thought about that a bit more after I posted, I'll think a bit more carefully about resolution rules, and think I may get it... Thanks for the help; learning Clojure as I learn Clara here...
No problem. Let me know if more questions
I’d give better examples but typing on mobile is hard hah
I really appreciate the help.
fyi, i think i'm closer, but I can't decipher the location of where the error of can't find Class for Myfact, as it won't tell me at what line it is failing. This is the state that I have it: https://github.com/mpettis/clara-ns-ex/tree/f3d6f67346eacb61294205f6da0e1f3073e7428a
I have the import statements, I tested that it worked. I referenced these pages that went with the hint that @mikerod gave me on using import: https://danielcompton.net/2016/05/04/requiring-records-clojure-clojurescript and https://stackoverflow.com/a/23420084/1022967
OK, I got it to work by playing with what did and did not need namespace qualified names, and where. I don't fully understand the rules of when I should and should not yet, but I have a working example to go off of, so thanks for all of your help! Here is the commit that has a working example: https://github.com/mpettis/clara-ns-ex/tree/d077c141d305ef217043bcf44a328c6921311847
@matthew.pettis nice, glad to see you sorted it out - looks better too
Thanks again for the help. I think it is helpful to have an example for clara-rules that leverages namespaces. I think I'll see if cerner/clara-examples would consider adding it as an example. Or somewhere. Nice to have a battery of examples for some of this...
@matthew.pettis yeah more examples could be good. Not sure when the last time that repo was updated. But perhaps it is the right place. There are also docs that maybe could explain some things more
@mikerod Yep, started there, read the documentation, some of it was vague to me, and not sure if is lack of experience on my part or it just doesn't have attention anymore to curate. Also, fwiw, I am making a different repo of collected small steps for myself for self-training. In this link, I use clara-rules to solve a logic puzzle, much like could be done with core.logic. However, I did it in clara-rules not because it was more efficient (oh, my example is real slow and memory hoggy), but because it mimicked a different scenario I think I want to apply clara-rules to. Here is that particular example... https://github.com/mpettis/clara-lien/blob/master/src/clara_lein/ex05.clj
that’s interesting, could be something nice to add to docs or examples