portal

sheluchin 2024-03-14T17:11:14.373199Z

Cross-posting from #beginners: Is there some way to prevent Portal from printing infinite sequences? https://clojurians.slack.com/archives/C053AK3F9/p1710434608001979

djblue 2024-03-14T20:39:09.423629Z

Currently, Portal doesn't try to deal with infinite seqs but you can deal with them in a custom submit function such as:

(require '[clojure.walk :as walk])

(defn truncate-seqs [v]
  (walk/prewalk #(if (seq? %) (take 10 %) %) v))

(add-tap (comp portal.api/submit truncate-seqs))

(tap> (range))

1
djblue 2024-03-14T20:43:48.633319Z

In very early versions of Portal, it did try to handle infinite lazy seqs, but it made the client much more complicated and I found myself not needing it very often.

sheluchin 2024-03-14T21:03:55.617629Z

@djblue Thank you!