Skip to content

Instantly share code, notes, and snippets.

@souenzzo
Created April 13, 2021 12:47
Show Gist options
  • Save souenzzo/a481848bc9591d71e252b31b06fd4284 to your computer and use it in GitHub Desktop.
Save souenzzo/a481848bc9591d71e252b31b06fd4284 to your computer and use it in GitHub Desktop.
(def spy-plugin
{::pc/wrap-resolve (fn [resolve]
(fn [env input]
(let [resolver-sym (-> env ::pc/resolver-data ::pc/sym)
_ (prn {:sym resolver-sym
:input input
:entity (p/entity env)})
output (resolve env input)]
(prn {:sym resolver-sym
:output output
:entity (p/entity env)})
output)))})
(let [parser (p/parser {::p/plugins [(pc/connect-plugin)
spy-plugin]})
indexes (pc/register {}
[(pc/constantly-resolver :a 42)
(pc/single-attr-resolver :a :c inc)])
env {::p/reader [p/map-reader
pc/reader2
pc/open-ident-reader
p/env-placeholder-reader]
::pc/indexes indexes
::p/placeholder-prefixes #{">"}}]
(parser env [:c]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment