                (zip/next loc))))))
 
 (defn topsort
+  "Takes a signal and returns a topologically sorted sequence of all signals in its graph."
   [output]
   (-> output
       output-node->dependency-map

                                            (first (filter fresh? messages)))}}))

(defn merge
  [& sigs]
  (mergeseq sigs))

(defn combine
  [sigs]
  (mapseq vector sigs))

(defn sample-on
  [sampler-sig value-sig]
  (map->Signal {:init (:init value-sig)
                :message-emitter {:sources [sampler-sig value-sig]

             (vals signal-map))))

(defn foldp
  "Create a past-dependent signal (\"fold into the past\"). The values of a `foldp`
  signal are obtained by calling `f` with two arguments: the current value of the
  `source` signal, and the previous value of the new `foldp` signal (acting as the
  \"accumulator\"). `init` provides the initial value of the new signal, and
  therefore acts as the seed accumulator."
  [f init source]
  (map->Signal {:init init
                :message-emitter {:sources [source]
