Git Product home page Git Product logo

hashp's Introduction

Hashp

Hashp is a better prn for debugging Clojure code. Inspired by projects like Spyscope, Hashp (ab)uses data readers to make it easier to get useful debugging data sent to STDOUT.

Usage

Once installed, you can add #p in front of any form you wish to print:

(ns example.core)

(defn mean [xs]
  (/ (double #p (reduce + xs)) #p (count xs)))

It's faster to type than (prn ...), returns the original result, and produces more useful output by printing the original form, function and line number:

user=> (mean [1 4 5 2])
#p[example.core/mean:4] (reduce + xs) => 12
#p[example.core/mean:4] (count xs) => 4
3.0

Install

Leiningen

Add the following to ~/.lein/profiles.clj:

{:user
 {:dependencies [[hashp "0.2.1"]]
  :injections [(require 'hashp.core)]}}

Boot

Add the following to ~/.boot/profile.boot:

(set-env! :dependencies #(conj % '[hashp "0.2.1"]))

(require 'hashp.core)
(boot.core/load-data-readers!)

Shadow-CLJS

Add the following to shadow-cljs.edn:

{:dependencies [hashp "0.2.1"]
 :builds {:app {:devtools {:preloads [hashp.core]}}}}

Or alternatively via ~/.shadow-cljs/config.edn and --config-merge:

~/.shadow-cljs/config.edn:

{:dependencies [[hashp "0.2.1"]]}

Run:

shadow-cljs watch app --config-merge '{:devtools {:preloads [hashp.core]}}'

License

Copyright © 2021 James Reeves

Released under the MIT license.

hashp's People

Contributors

codeasone avatar lucywang000 avatar tggreene avatar weavejester avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.