This isn't a schema issue. Without invoking Schema:
user> (do (defrecord Foo []) Foo)
user.Foo
user> (clojure.pprint/pprint (do (defrecord Foo2 []) Foo2))
CompilerException java.lang.RuntimeException: Unable to resolve symbol: Foo2 in
this context,
compiling:(/private/var/folders/_g/_nhxhpvn249c7ylfjwftblvr0000gp/T/form-init2087833310089175503.clj:1:24)
Clojure compiles each top-level form as a unit, with a special case
exception for do (which it breaks into separate compilation units). When
you wrap multiple forms in a pprint, the whole thing is treated as a single
unit, and the class defined by defrecord is not visible in subsequent forms
within the unit.
Hope this helps. Maybe someone with Babel experience can provide some
guidance about how to work around this issue.
Best,
Jason
On Friday, December 25, 2015 at 10:28:59 PM UTC+1, Rui Yang wrote:
>
> Hi,
>
> I tried to use org babel to document my learning of clojure. Trying the
> following codes in org babel.
> #+begin_src clojure :results pp
> (require '[schema.core :as s])
> (s/defrecord MyDomainModel
> [date :- Long
> ])
>
> (s/validate MyDomainModel (map-> MyDomainModel{:date 123}))
> #+end_src
>
> The above source codes were expanded to:
>
> (clojure.pprint/pprint (do (require '[schema.core :as s])
> (s/defrecord MyDomainModel
> [date :- Long])
> (s/validate MyDomainModel
> (map->MyDomainModel{:date 123}))))
>
> Tried the above codes in repl and it gave the following error:
> Unable to resolve symbol:
> MyDomainModel in this context
>
> I have [prismatic/schema "1.0.4"] in dependencies list.
>
> As a newbie, I am interested to know how to debug such issues. The
> expanded codes seem fine. Anyone could help to point me what is wrong with
> that expanded codes?
>
> Thanks.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.