 ;; mapcat-stream is somewhat simpler.
 ;;
 ;;     clojure.lang.IFn
-;;     (mapcat-stream [$ g] #(mapcat-stream ($) g))
+;;     (mapcat-stream [stream g] #(mapcat-stream (stream) g))
 ;;
 ;; The basic concept here is pretty straightforward: make a new thunk which,
 ;; when executed later, will do some work and then mapcat `g` over the result.

;; TODO: explain why this needs to be wrapped in a thunk
(extend-protocol IStream
  clojure.lang.IFn
  (merge-streams [$1 $2] #(merge-streams $2 ($1)))
  (mapcat-stream [$ g] #(mapcat-stream ($) g))
  (realize-stream-head [$] (trampoline $)))

(defn stream [s] (StreamNode. s empty-stream))

;; #### Seq conversion
;;

  realize-stream-head.

  This is useful for defining recursive goals."
  [goal]
  `(fn delayed-goal-outer [state#]
     (fn delayed-goal-inner [] (~goal state#))))

(defmacro ldisj+
  "Extended version of the `ldisj` function. This one handles multiple
