jasongilman / proto-repl

A Clojure Development Environment package for the Atom editor
https://atom.io/packages/proto-repl
MIT License
563 stars 50 forks source link

edn/read of a tagged-literal in *data-readers* resolves to unbound function error in proto-repl but not lein repl #285

Open kdhouser24 opened 6 years ago

kdhouser24 commented 6 years ago

The following code works in lein repl from namespace dev=>

(with-in-str (-> "resources/data.edn" slurp)
  (while-let [e (edn/read {:eof nil :readers *data-readers*} *in*)]
  (println ";=> " e)))
;=>  [:add {:uuid #uuid "96b06c80-d6a2-11e7-9f74-9c4a018d7c89", :start-time #joda/inst "2017-07-15T16:00:00.000Z", :stop-time #joda/inst "2017-07-15T17:29:00.000Z", :taskee vSwitch1, :tasker ajurka}]
nil

But in proto-repl it throws exception

IllegalStateException Attempting to call unbound fn: #'taskmaster.util/->joda-inst  clojure.lang.Var$Unbound.throwArity (Var.java:43)

But the qualified function in the exception does resolve at proto-repl

(-> "2017-07-15T17:29:00.000Z" taskmaster.util/->joda-inst type)
org.joda.time.DateTime

resources/data_readers.clj defines the reader function

{joda/inst taskmaster.util/->joda-inst}

src/tagmaster/util.clj contains

(ns taskmaster.util
  (:import org.joda.time.DateTime))

(defmacro while-let
 "Makes it easy to continue processing an expression as long as it is true"
  [binding & forms]
  `(loop []
     (when-let ~binding
       ~@forms
       (recur))))

;; Configure the printer
(defmethod print-method org.joda.time.DateTime
 [dt out]
 (.write out (str "#joda/inst \"" (.toString dt) "\"")))
(defmethod print-dup org.joda.time.DateTime
 [dt out]
 (.write out (str "#joda/inst \"" (.toString dt) "\"")))

;; Utility function for the reader
(defn ->joda-inst [time-str]
 (org.joda.time.DateTime/parse time-str))
Astronought commented 4 years ago

I know this is an old issue, but I'm experiencing the same problem. Any ideas?