Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

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 this issue Dec 1, 2017 · 1 comment

Comments

@kdhouser24
Copy link

kdhouser24 commented Dec 1, 2017

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants