yaml / yamlscript

Programming in YAML
MIT License
382 stars 31 forks source link

Compile `.?` and `?:` to Clojure `tap>` #162

Open kloimhardt opened 3 months ago

kloimhardt commented 3 months ago

Summary: tap> is a Clojure/babashka core functionality for logging. Compiling .? and ?: to Clojure tap> opens up extended data visualisation capabilities.

Details: Basic tap> works by first registering some printing/logging function as a tap handler

(add-tap (bound-fn* clojure.pprint/pprint))

and then log some data through that handler

(tap> "Hello world")

A more sophisticated use case is the data inspecting library https://github.com/djblue/portal hooking into tap>. Start babashka with

bb -Sdeps '{:deps {djblue/portal {:mvn/version "0.56.0"}}}'

and in the Repl

user=> (require '[portal.api :as p])
nil
user=> (do     
  (.addShutdownHook (Runtime/getRuntime)
                    (Thread. (fn [] (p/close))))
  (def portal (p/open {:app true}))
  (add-tap #'p/submit))

with Chrome browser installed, a window opens automatically. Typing

user=> (tap> :hello)

shows the following screen

Screenshot 2024-06-24 at 16 48 48