This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; 1. Current version -- note the use of `when-valid`... it is essentially duplicating the work the | |
| ;; syntax-validation-m monad should be able to handle, so I've been attempting to | |
| ;; clean it up / refactor it to use only the monad | |
| (defmacro expect | |
| "Run the call form, check that all the mocks defined in the fakes | |
| (probably with 'fake') have been satisfied, and check that the actual | |
| results are as expected. If the expected results are a function, it | |
| will be called with the actual result as its single argument. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (doseq [[sym the-var] (ns-publics 'clojure.core) | |
| :when (.startsWith (name sym) "*")] | |
| (println (str (name sym) ":\n" (:doc (meta the-var)) "\n"))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn nested-sort [x] | |
| (cond (sequential? x) | |
| (if (instance? java.lang.Comparable (first x)) | |
| (sort (map nested-sort x)) | |
| (map nested-sort x)) | |
| (map? x) | |
| (if (and (not= {} x) | |
| (instance? java.lang.Comparable (key (first x)))) | |
| (into (sorted-map) (map-values nested-sort x)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns groupon.joda-instant-reader | |
| (:require [clojure.instant :as i]) | |
| (:import org.joda.time.DateTime)) | |
| (defmethod print-method org.joda.time.DateTime | |
| [^org.joda.time.DateTime d ^java.io.Writer w] | |
| (#'i/print-date (java.util.Date. (.getMillis d)) w)) | |
| (defmethod print-dup org.joda.time.DateTime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user> (defn foo [_ _ s] | |
| `(println ~s)) | |
| #'user/foo | |
| user> (foo nil nil 5) | |
| (clojure.core/println 5) | |
| user> (alter-meta! #'foo assoc :macro true) | |
| {:arglists ([_ _ s]), :ns #<Namespace user>, :name foo, :macro true, :line 1, :file "NO_SOURCE_FILE"} | |
| user> (foo 5) | |
| 5 | |
| nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (deftype JsonErrorReporter | |
| ;; Hook for clj-schema.validation/validation-errors, to format the errors | |
| ;; for consumption on the JS side | |
| [] | |
| val/ErrorReporter | |
| (non-map-error [_ {:keys [parent-path map-under-validation]}] | |
| {:type :non-map}) | |
| (extraneous-path-error [_ {:keys [map-under-validation]} extra-path] | |
| {:type :extraneous-path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (deftype JsonErrorReporter | |
| ;; Hook for clj-schema.validation/validation-errors, to format the errors | |
| ;; for consumption on the JS side | |
| [] | |
| val/ErrorReporter | |
| (non-map-error [_ {:keys [parent-path map-under-validation]}] | |
| {:type :non-map}) | |
| (extraneous-path-error [_ {:keys [map-under-validation]} extra-path] | |
| {:type :extraneous-path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn- get-holidays [^HolidayManager holiday-manager ^Interval interval] | |
| (.getHolidays holiday-manager interval (into-array String []))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Example: | |
| ;; (doseq-indexed idx [name names] | |
| ;; (println (str idx ". " name) | |
| (defmacro doseq-indexed [index-sym [item-sym coll] & body] | |
| `(let [idx-atom# (atom 0)] | |
| (doseq [~item-sym ~coll] | |
| (let [~index-sym (deref idx-atom#)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns millega.foo | |
| (:require [clojure.core.typed :as t])) | |
| (t/ann f1 [t/AnyInteger -> t/AnyInteger]) | |
| (defn f1 [n] | |
| (* 2 n)) | |
| (defmacro defn2 [name _colon_dash result-type-ann args+anns & body] | |
| (let [args (vec (take-nth 3 args+anns)) |