Arc Forumnew | comments | leaders | submitlogin
Ellipsize REPL Output
3 points by fallintothis 3350 days ago | discuss
Prompted by the side note at, here's a fun toy I whipped up to solve the problem of overly-long REPL output.

  (def terse-repl ((o limit 80))
    (prn "Use (verbose-repl) to turn off ellipsized output.")
      (while t
        (disp "arc> ")
        (on-err [do (disp "Error: ") (write (details _)) (prn)]
                (fn ()
                  (let expr (read)
                    (if (is expr ':a)
                        (iso expr '(verbose-repl))
                         (do (prn "Turning off ellipsized output.")
                         (let val (eval expr)
                           (prn (ellipsize (tostring (write val)) limit))
                           (= that val thatexpr expr)))))))))

  arc> (terse-repl)
  Use (verbose-repl) to turn off ellipsized output.
  arc> (= x (n-of 1000000 (rand)))
  (0.9777547694679798 0.07493917168754799 0.13700886175451876 0.6612940629825846 0...
  arc> (verbose-repl)
  Turning off ellipsized output.
  arc> (len x)
Not very useful, but I thought I'd share it anyway.