Fork me on GitHub
#precept
<
2018-05-17
>
dominicm16:05:55

Is it possible to create an anonymous session? Like mk-session in clara.

alex-dixon16:05:43

Not currently. Why do you ask?

dominicm16:05:13

I'm fooling around in the repl, it's quite convenient to be anonymous. I'm not doing anything with clojurescript at all.

dominicm16:05:03

(My questions become moot if the #clara datom system is separate, but that's a separate conversation)

alex-dixon16:05:41

I haven’t used it much in CLJ but want to (stream processing in particular). Let me look at the code real quick see if there’s something that might be halfway helpful

alex-dixon16:05:22

Not sure if you have the repo cloned but I think if session returned that you’d have a defless session

dominicm16:05:15

I do have it :) yeah.

dominicm16:05:48

Are subscriptions the equivalent of Clara queries? Sorry, I appreciate I'm coming at this in an unorthodox way.

alex-dixon16:05:28

Live queries basically. They’re rules under the covers. They don’t take parameters currently. They still get compiled into the rete graph because they’re rules

alex-dixon16:05:48

Queries do too though

alex-dixon16:05:11

I’ve wanted to use the ave eav indexes we have for queries instead. Could be more performant

alex-dixon17:05:42

In CLJS they end up being just like reframe subscriptions and are implemented with reagent cursors/atoms. In CLJ it might be more appropriate to back them with core.async

dominicm17:05:06

I was getting nil for the visible to-do subscription. Any reason they might not work in Clojure?

alex-dixon17:05:52

Yeah. I haven’t found or implemented a cursor equivalent

alex-dixon17:05:04

I’m surprised I don’t have an issue open for it cause it’s been on my mind. But not sure whether in CLJ it’d be more useful to have something like a core.async channel that receives updates vs a dereffable thing

alex-dixon17:05:45

If you’re poking around:

(defn get-sub [state-m k]
  (let [sub-name->sub-map (->> (:subscriptions state-m)
                               (vals)
                               (util/key-by :name))]
    (get-in sub-name->sub-map [k :lens])))

(defn list-subs [state-m]
  (->> (:subscriptions state-m)
       (vals)
       (map :name)))

(defn get-attributes [store-m]
  (->> store-m
       (vals)
       (into {})
       (keys)))

(defn get-entity [store-m eid]
  (get store-m eid))

alex-dixon17:05:34

where store-m is @precept.state/store, state-m is @precept.state/state

dominicm17:05:07

Rather than core.async, callbacks are more "open". Rh advice is to use them rather than a hard dependency.

alex-dixon17:05:15

Ok. I’m interested to hear you thoughts… on all of this. Cause I don’t know. I’m not sure what people would want to use Clara or Precept for, especially with CLJ. For me I’d want a stream of matches for a rule, maybe with the ability to apply transducers. I don’t know…interface could be both I guess

dominicm17:05:22

I'll have a poke.

alex-dixon17:05:32

In part because in CLJ my aspirations would be stream processing with Kafka

dominicm17:05:11

My use case is unusual, so probably not the best basis. I want to derive JSON from facts, with rules to enrich facts with inferences.

alex-dixon17:05:39

Well, I’m really interested if you’re able and willing to say more. Curious for one, helps think about possible implementations a lot too though

dominicm18:05:06

I am able. I am willing. I want an API to talk at a highish level about deployments. a runs Clojure. A talks to b. B is a database, etc. Then a series of rules will generate facts about auto scaling groups, adding RDS databases, setting up firewall rules and so on. I will then collect up all the data and create terraform or cloud formation.

alex-dixon18:05:43

Are you designing it as a one time calculation? Or are you doing something like live monitoring

dominicm18:05:50

One time calculation. Which I know is unusual.

alex-dixon18:05:31

Not so sure about that with rule engines actually. From what I’ve heard about Cerner it’s more “solve this” rather than a constantly running thing. Very cool

dominicm18:05:21

We're all very comfortable with Datomic, so having tuples for facts is ideal.

alex-dixon18:05:08

That’s great. Hoping I have a chance to use it at work soon. How do you handle things like ordered lists, sets, and other collections of things? We made the decision to allow anything in the value slot which I think makes some sense for UI at least

dominicm19:05:11

I'll let you know. I've not gone that far yet.