(ns buddho.dhamma.state
  (:require [buddho.core.dhamma :as d]
            [buddho.core.meta :as meta]
            [buddho.core.state :as s]))

(defn dh-have-idea
  [n-ideas
   & {:keys [data is-aspect-of? cascade asp-props transient]
      :as args}]
  (d/make-dhamma
   :have-idea
   :data {:n-ideas n-ideas}
   (update args :data #(merge {:n-ideas n-ideas} %))))

(defn have-idea!
  [n-ideas
   & {:keys [data is-aspect-of? cascade asp-props transient]
      :as args}]
  (d/register-dhamma!
   :have-idea
   :transient nil
   :data {:n-ideas n-ideas}
   (update args :data #(merge {:n-ideas n-ideas} %))))

(defmethod d/impl! :have-idea [dhamma & [whole]]
  (let [n-ideas (or (d/get-data dhamma :n-ideas)
                    (d/get-data whole :n-ideas)
                    1)]
    (d/assoc-data whole :ideas (repeatedly n-ideas s/have-idea!))))

(meta/register-meta!
 :have-idea
 :singleton-fn #(have-idea! nil))


(defmethod d/impl! :store-idea [dhamma & [whole]]
  (let [])
  )
