(ns emptyhead.lib.compose
  (:require [emptyhead.idea.memtag :as memtag]
            [emptyhead.thought.extend :as extend]
            [emptyhead.thought.crud :as thought]
            [emptyhead.thought.define :as def]))

;; Append `(:data thought)` as execution child of `parent`.
(def/define! [:emptyhead :compose :append]
  (fn [thought parent]
    (let [op (:data thought)
          stage [:emptyhead :compose :append (memtag/uid-of parent) (memtag/uid-of op)]
          op (extend/register-extension! op stage)
          parent (thought/add-ext-stage! parent stage)]

      [parent nil])))
