practicalli / practicalli/clojure
Inspecting Clojure Objects
Nobody has claimed this yet.
- Dominant language
- Makefile
- Stars
- 117
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
What's a good way to inspect a Clojure object? I miss Pythons dir https://docs.python.org/3.5/library/functions.html#dir
9 replies
andy.fingerhut 17 hours ago
(type x) tells you what type a value is. If it is a map, (keys x) tells you the keys. You can just type x at a REPL and see the value, although it might be bigger than you want to look at. (pprint x) can show it with nicer formatting, rather than one long line.
andy.fingerhut 17 hours ago
Cognitect's REBL has a graphical UI for exploring large and/or nested values in various ways.
andy.fingerhut 17 hours ago
I will mention clojure.inspector/inspect-tree but at the same time warn you that it has some limitations of what kinds of values it works with that can be annoying. REBL is more general purpose and polished by far.
andy.fingerhut 17 hours ago
Some Clojure IDEs have their own value inspectors they provide, but I have not used any of them.
bfabry 17 hours ago
for inspecting Java objects, bean is good
Eric Ihli 17 hours ago
Rad. Thanks. I'll dig into some of these.
bfabry 17 hours ago
or, if you want to really deeply inspect a java object, clojure.reflect/reflect will give you way more information than you could ever want. just remember it's pretty slow
seancorfield 17 hours ago
(ns-publics ns) will show you all the public symbols defined in the current namespace, as a hash map from symbols to Vars, so something like (keys (ns-publics 'clojure.set)) is probably easier to read.
kelveden 2 hours ago
For simple inspecting of clojure data structure like a map, I've found the reader tag #spy/p from https://github.com/dgrnbrg/spyscope invaluable.
dgrnbrg/spyscope
Trace-oriented debugging tools for Clojure
Stars
502
Language
Clojure
https://github.com/dgrnbrg/spyscope|dgrnbrg/spyscopedgrnbrg/spyscope | 20 Oct 2012 | Added by GitHub
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository files, tests, or entry points, and the discussion is a question about inspecting Clojure values rather than a defined change. Review the suggested approaches in the thread, then clarify whether a documentation update or a new inspection tool is wanted before defining what completion means.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100