Fork me on GitHub
#clara
<
2017-06-29
>
cfleming01:06:11

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

cfleming01:06:54

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.

cfleming01:06:36

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.

cfleming01:06:20

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.

cfleming01:06:41

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.

cfleming01:06:29

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

ryanbrush02:06:46

@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.

cfleming02:06:30

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

cfleming02:06:53

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

ryanbrush02:06:07

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.)

ryanbrush02:06:31

Right, the schema is for the returned data.

ryanbrush02:06:52

I agree this could be helpful for rule authors.

cfleming02:06:28

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.

ryanbrush02:06:59

Sort of. The precent project (https://github.com/CoNarrative/precept) uses Clara, but is more of a wrapper so isn't the most common usage.

ryanbrush02:06:09

The best place for examples is probably the clara-examples project itself: https://github.com/cerner/clara-examples/tree/master/src/main/clojure/clara/examples

cfleming02:06:26

Thanks, I’ll take a look at those.

flipmokid09:06:20

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?

flipmokid16:06:34

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.

zylox16:06:16

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

devn21:06:40

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

devn21:06:28

i could also share sanitized rules