code cleanup
This commit is contained in:
@@ -3,18 +3,14 @@
|
||||
Since thoughts are ideas, 'missing' operations here are implemented in [[emptyhead.idea.crud]]."
|
||||
(:require [emptyhead.idea.protocol :as prtc]
|
||||
[emptyhead.idea.crud :as idea]
|
||||
[emptyhead.idea.property :as prop]
|
||||
[emptyhead.contract.eval :as contract]
|
||||
[emptyhead.util.magic :as magic]))
|
||||
|
||||
;; TODO groups
|
||||
(defn make-thought
|
||||
"Helper function to make thought object.
|
||||
You may want `register-thought!` instead."
|
||||
[operator & {:keys [data ext-contract ext-stages transient]
|
||||
[operator & {:keys [data ext-contract ext-stages]
|
||||
:or {data {} ext-contract {}
|
||||
ext-stages [[:PRE-EXECUTE] [:EXECUTE] [:POST-EXECUTE]]
|
||||
transient true}}]
|
||||
ext-stages [[:PRE-EXECUTE] [:EXECUTE] [:POST-EXECUTE]]}}]
|
||||
(hash-map :operator operator
|
||||
:data data
|
||||
:ext-contract ext-contract
|
||||
@@ -25,18 +21,12 @@
|
||||
(defn register-thought!
|
||||
"Create a thought and register it in the state.
|
||||
Returns a reference to the created thought."
|
||||
[operator & {:keys [data ext-contract ext-stages transient group]
|
||||
[operator & {:keys [data ext-stages]
|
||||
:as args}]
|
||||
(idea/have-idea!
|
||||
:prefix (str "emptyhead.thought#" (magic/symbolize-ns operator))
|
||||
:properties [magic/thought-ns]
|
||||
:data (make-thought operator args)))
|
||||
|
||||
(defn contract
|
||||
"Get the extension contract of a `thought`.
|
||||
Returns the contract."
|
||||
[thought]
|
||||
(prtc/val-fn :ext-contract thought))
|
||||
(idea/have-idea!
|
||||
:prefix (str "emptyhead.thought#" (magic/symbolize-ns operator))
|
||||
:properties [magic/thought-ns]
|
||||
:data (make-thought operator args)))
|
||||
|
||||
(defn stages
|
||||
"Get the extension stages of a `thought`.
|
||||
@@ -63,8 +53,6 @@
|
||||
[thought]
|
||||
[(assoc thought :return (-> thought prtc/copy stack butlast vec)) (-> thought prtc/copy stack peek)])
|
||||
|
||||
(def root-thought (make-thought :root))
|
||||
|
||||
(defn add-ext-stage!
|
||||
[thought stage]
|
||||
(idea/mutate-idea! #(update % :ext-stages conj stage) thought))
|
||||
|
Reference in New Issue
Block a user