hoplon

2023-07-03T13:36:52.223789Z

Hey @alandipert, If I want my deftype to be handled by hoplon elements as a map {} or vec [] what do I need to do?

2023-07-03T13:38:07.537549Z

Sorry if it's a big question, I'm digging inside hoplon.core myself I was just wondering if you already have the answer

2023-07-03T13:40:15.544699Z

I believe the answer is here somewhere:

(defn parse-args
  "Parses a sequence of element arguments into attributes and children."
  [args]
  (loop [attr (transient {})
         kids (transient [])
         [arg & args] args]
    (if-not (or arg args)
      [(persistent! attr) (persistent! kids)]
      (cond (map? arg)       (recur (reduce-kv assoc! attr arg) kids args)
            (set? arg)       (recur (reduce #(assoc! %1 %2 true) attr arg) kids args)
            (attribute? arg) (recur (assoc! attr arg (first args)) kids (rest args))
            (seq? arg)       (recur attr (reduce conj! kids (vflatten arg)) args)
            (vector? arg)    (recur attr (reduce conj! kids (vflatten arg)) args)
            :else            (recur attr (conj! kids arg) args)))))

2023-07-11T02:04:03.065099Z

Hm looks like seq? is the most general test there that does splicing

2023-07-12T11:48:15.852669Z

Thank you 🙏 I've managed something

2023-07-12T16:20:42.243119Z

Awesome, look forward to hear about it. Saw you mention AMOP elsewhere, big CLOS fan myself. Would love it in clj/s