{"id":27056497,"url":"https://github.com/damesek/microscope","last_synced_at":"2025-04-05T10:17:52.267Z","repository":{"id":194030549,"uuid":"343775445","full_name":"damesek/microscope","owner":"damesek","description":"Focus on what happens in Clojure functions [helper for me/ us]","archived":false,"fork":false,"pushed_at":"2021-03-22T16:35:04.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-09-12T10:42:15.135Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/damesek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-03-02T12:59:26.000Z","updated_at":"2021-03-22T16:35:08.000Z","dependencies_parsed_at":"2023-09-11T10:36:24.025Z","dependency_job_id":null,"html_url":"https://github.com/damesek/microscope","commit_stats":null,"previous_names":["damesek/microscope"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damesek%2Fmicroscope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damesek%2Fmicroscope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damesek%2Fmicroscope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/damesek%2Fmicroscope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/damesek","download_url":"https://codeload.github.com/damesek/microscope/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318729,"owners_count":20919483,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-05T10:17:51.677Z","updated_at":"2025-04-05T10:17:52.257Z","avatar_url":"https://github.com/damesek.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# microscope\n\nThis is a **microscope** for Clojure functions.\u003cBR\u003e\n[I created a few years ago for myself to debug things.]\n\n`[hu.baader/microscope \"0.1.0-SNAPSHOT\"]`\n\n\nFew things:\n- I created this repo to test how to start a Clojars lib\n- UNDER DEVELOPMENT - do not use\n- defn\u003c\u003e bug plus missing meta etc handling, I created for quick fn tests\n- my first test repo, mainly for deployment test (use carefully)\n\nTodo: \n - missing tests\n - codox\n\n\nI didn't test in production environment.\u003cBR\u003e \nExplore, extract extract information.\n\n\n## Usage\n\nVery easy to use:\n\n```clojure\n(ns your.ns\n  (:require [microscope.monitor :refer [defn\u003c\u003e extract\u003c\u003e let\u003c\u003e\n                                        current-function-name\u003c\u003e line\u003c\u003e\n                                        filename\u003c\u003e methodname\u003c\u003e full\u003c\u003e]]))\n```\n\nUse defn\u003c\u003e microscope function instead of clojure.core defn:\n ```Clojure\n(defn\u003c\u003e deb [a b]\n          (for [x (into [] (range a))]\n            (* 3 (+ 2 b))))\n```\nYou will get back from `(ns user)`:\n\n```clojure\n(deb 2 3)\n0 () =\u003e microscope.monitor$deb\n\n :function name  microscope.monitor$deb \n :where          202:3 \n :fn-arglist     ([a b]) \n :got-args       {} \n -------------------------------- \n \n1 (range a) =\u003e (0 1)\n2 (into [] (range a)) =\u003e [0 1]\n3 (+ 2 b) =\u003e 5\n4 (* 3 (+ 2 b)) =\u003e 15\n5 (+ 2 b) =\u003e 5\n6 (* 3 (+ 2 b)) =\u003e 15\n7 (for [x (into [] (range a))] (* 3 (+ 2 b))) =\u003e (15 15)\n=\u003e (15 15)\n```\n\n\nUse let\u003c\u003e binding:\n\n```clojure\n (let\u003c\u003e\n   [x 1 y 2]\n   (+ x y))\n```\n\nYou will get back:\n\n```clojure\nuser$eval2835 x : 1\nuser$eval2835 y : 2\n=\u003e 3\n```\n\nUse extract\u003c\u003e for extract informations from loops, specific places. \n\n```clojure\n  (defn test2 [i]\n    (for [x (into [] (range i))]\n      (do (extract\u003c\u003e) x)))\n```\n\nYou will get back:\n\n```clojure\n(test2 3)\n{x 0,\n temp__5720__auto__ (0 1 2),\n i 3,\n b__2842\n #object[clojure.lang.ChunkBuffer 0x5097956b \"clojure.lang.ChunkBuffer@5097956b\"],\n i__2841 0,\n c__6288__auto__\n #object[clojure.lang.ArrayChunk 0x5465c307 \"clojure.lang.ArrayChunk@5465c307\"],\n iter__2839\n #object[user$test2$iter__2839__2843 0x2f1e5e7 \"user$test2$iter__2839__2843@2f1e5e7\"],\n size__6289__auto__ 3,\n s__2840 (0 1 2)}\n current ns user \n current function  user$test2$iter__2839__2843$fn__2844$fn__2845\nElapsed time:  30.849502  ms\n{x 1,\n temp__5720__auto__ (0 1 2),\n i 3,\n b__2842\n #object[clojure.lang.ChunkBuffer 0x5097956b \"clojure.lang.ChunkBuffer@5097956b\"],\n i__2841 1,\n c__6288__auto__\n #object[clojure.lang.ArrayChunk 0x5465c307 \"clojure.lang.ArrayChunk@5465c307\"],\n iter__2839\n #object[user$test2$iter__2839__2843 0x2f1e5e7 \"user$test2$iter__2839__2843@2f1e5e7\"],\n size__6289__auto__ 3,\n s__2840 (0 1 2)}\n current ns user \n current function  user$test2$iter__2839__2843$fn__2844$fn__2845\nElapsed time:  12.692063  ms\n{x 2,\n temp__5720__auto__ (0 1 2),\n i 3,\n b__2842\n #object[clojure.lang.ChunkBuffer 0x5097956b \"clojure.lang.ChunkBuffer@5097956b\"],\n i__2841 2,\n c__6288__auto__\n #object[clojure.lang.ArrayChunk 0x5465c307 \"clojure.lang.ArrayChunk@5465c307\"],\n iter__2839\n #object[user$test2$iter__2839__2843 0x2f1e5e7 \"user$test2$iter__2839__2843@2f1e5e7\"],\n size__6289__auto__ 3,\n s__2840 (0 1 2)}\n current ns user \n current function  user$test2$iter__2839__2843$fn__2844$fn__2845\nElapsed time:  8.50809  ms\n=\u003e (0 1 2)\n```\n\nUse other single-line functions as (I use for error messages sometimes): \n- `full\u003c\u003e`\n- `current-function-name\u003c\u003e`\n- `line\u003c\u003e`\n- `filename\u003c\u003e`\n\nFor example:\n\n```clojure\n(defn debug-test2 [i]\n    (pr (current-function-name\u003c\u003e)\n        (line\u003c\u003e)\n        (filename\u003c\u003e)\n        (full\u003c\u003e))\n    (for [x (into [] (range i))]\n      x))\n```\n\n Run `(debug-test2 2)` and you will get:\n \n ```clojure\n\"user$debug_test2\" 3 \"form-init2180815951943850242.clj\" \n[user$debug_test2 invokeStatic \"form-init2180815951943850242.clj\" 5]\n=\u003e (0 1)\n```\n\n\n## License\n\nCopyright © 2021 FIXME\n\nThis program and the accompanying materials are made available under the\nterms of the Eclipse Public License 2.0 which is available at\nhttp://www.eclipse.org/legal/epl-2.0.\n\nThis Source Code may also be made available under the following Secondary\nLicenses when the conditions for such availability set forth in the Eclipse\nPublic License, v. 2.0 are satisfied: GNU General Public License as published by\nthe Free Software Foundation, either version 2 of the License, or (at your\noption) any later version, with the GNU Classpath Exception which is available\nat https://www.gnu.org/software/classpath/license.html.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamesek%2Fmicroscope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdamesek%2Fmicroscope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdamesek%2Fmicroscope/lists"}