Fork me on GitHub

Hi everyone - I develop Cursive, and I’ve been chatting to @zylox about the possibility of adding support for the Clara macros to Cursive.


Since Cursive indexes source, it needs some support to understand macro forms - I’m planning to open an API for that, but that’s way off since it’s a large project.


One thing I’m interested in is being able to add support using grammars migrated from specs for macros, since I expect there will be more of them in the future.


Has anyone investigated or thought about creating specs for the Clara macro forms? That would be a big help in adding support for them to Cursive.


As well as selfishly meaning that I can actually try to migrate some macro specs to Cursive - I haven’t seen any in the wild yet.


Since the macro forms also seem quite complex, it seems like having specs for them would also be generally useful to developers using Clara.


@cfleming Hey, cool idea. I haven't really used specs for macros yet, but I think it would be straightforward to do so for Clara's macros. The structure is pretty well defined (the defrule and defquery macros already have a schema defining their return values) and has been stable for some time.


@ryanbrush Nice. So is there actually a grammar for the macros themselves anywhere? I see some railroad docs, but they seem incomplete.


The schema I guess is for the returned data, right? Not the actual macros?


We had written quite a bit of error handling code for malformed defrule macros to make it easier to debug, but we don't have a formal grammer besides the (incomplete) EBNF we used for the railroad docs.)


Right, the schema is for the returned data.


I agree this could be helpful for rule authors.


Are there examples of Clara rules in any OSS projects? I don’t work with it myself so I’m not sure how a lot of the tricky cases (destructuring etc) work.


Sort of. The precent project ( uses Clara, but is more of a wrapper so isn't the most common usage.


The best place for examples is probably the clara-examples project itself:


Thanks, I’ll take a look at those.


Hi, I'd like to use Clara in my app which uses Component. I'm currently scratching my head on how I can create a rule that when matched writes to a channel supplied by Component when the application starts. Would anyone be able to give me guidance on how I might do it?


Okay silly me, I'm adding the required components as facts and I can pull them out as needed in the rule for use in the right hand side.


i thought as much but i didnt know enough about Component to say anything haha


@cfleming FWIW, I have a cursive license, we have 100s of hand-written rules, and would be happy to be a guinea pig


i could also share sanitized rules