Skip to content

Instantly share code, notes, and snippets.

@bhb bhb/examples.clj
Created Mar 20, 2018

Embed
What would you like to do?
Expound examples
;; There is still a ton of work to do wrt to formatting, testing, and improving examples,
;; but here's a proof-of-concept of Expound printing examples.
;; 'defn' examples are adapted from "Improving Clojure's Error Messages with Grammars"
;; https://youtu.be/kt4haSH2xcs?t=10m20s
;; Changing types
(defn "foo" [] 1)
;; -- Example ------------------------
;; (<f> foo [] 1)
;; (Note that clojure.spec does not currently include the macro name in `explain-data`,
;; so Expound can only print placeholder <f>
;; (https://dev.clojure.org/jira/browse/CLJ-2271))
;; Adding a form
(defn foo)
;; -- Example ------------------------
;; (<f> foo [])
;; Wrapping forms
(defn foo (arg1 arg2))
;; -- Example ------------------------
;; (<f> foo ([arg1] arg2))
;; Changing collection type
(defn foo (arg1 arg2) arg2)
;; -- Example ------------------------
;; (<f> foo [arg1 arg2] arg2)
;; Wrapping form (again)
(defn foo a)
;; -- Example ------------------------
;; (<f> foo [a])
;; Reordering form
(defn "bad docstring" foo [arg1 arg2])
;; -- Example ------------------------
;; (<f> foo "bad docstring" [arg1 arg2])
@bhb

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.