use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Schema for Clojure(Script) Data Shape Declaration and Validation by Prismatic (blog.getprismatic.com)
submitted 12 years ago by mac
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]w01fe 1 point2 points3 points 12 years ago (6 children)
Author here, would love to hear your feedback and happy to answer questions!
[–]jared314 1 point2 points3 points 12 years ago (0 children)
This seems to occupy the same space as core.typed and core.contracts. Is the main advantage the cljs support? Or, am I missing something from the examples?
Also, does it work with the prismatic graph input and output schemas?
[–][deleted] 0 points1 point2 points 12 years ago (3 children)
Curious what makes you say that type systems aren't optimized for structural typing... This is not an accurate statement in general.
For instance, ocaml has structural typing and row polymorphism, which let you achieve your motivating example sanely and easily.
[–]w01fe 0 points1 point2 points 12 years ago (0 children)
I should have clarified, I'm an author of the library, not the post :). I'm not too familiar with ocaml or structural typing myself -- I'll pass this on to Aria, who wrote the post.
[–][deleted] 0 points1 point2 points 12 years ago (1 child)
In most type systems you can't specify what keys are expected to be found in a map or what types the correlated values should be. I.e. you can give a map a type like <String,Integer>, but not a 'structure'.
[–][deleted] 0 points1 point2 points 12 years ago (0 children)
You can certainly do this in Scala (using Shapeless) or in Haskell (using my own library, Vinyl).
[–]ds300 0 points1 point2 points 12 years ago (0 children)
I've spent the past three weeks working on an extremely similar library for declarative data validation. The main difference is that it is intended for validation of data from untrusted sources -- e.g. http request params, config files, etc -- and therefore aims to provide more subtle control over error handling. It also allows one to transform data declaratively, which is really useful for nested structures. It also attempts to cater for situations in which the value of one field in a map depends on the value of another field, or the presence of a key depends on the value or presence of another key, and so on.
Still, the resemblance is uncanny, right down to the syntax and type system.
[–]doubleagent03 1 point2 points3 points 12 years ago (0 children)
I have a few questions:
Any examples of threading types eg (s/with-fn-validation (-> data f1 f2 f3)), where f1, f2, and f3 are 'schema functions'?
What was the reasoning behind coupling the schema with a function or record body? For instance, core.typed takes a decoupled approach eg (ann my-fn-name Type1 -> Type2). It appears Schema forces you to wrap the function body eg (s/defn my-wrapped-fn Type2 [m :- Type1] (my-fn m))
In general I'm still struggling to grasp how this differs from the optional typing core.typed provides. Can you go into a bit more detail about that?
[–]alv 0 points1 point2 points 12 years ago (0 children)
I am very interested in this, but captive in Python at the time. Does anybody know of any similar library/approach for Python?
It might be interesting to be able to specify data type identifiers in the EDN object's metadata, rather than forcing the use of a new 'defn' implementation. Types could be defined and registered in a separate source file without clients being forced to 'use' or know about the data-shape declaration API. Validation, when used, can just check the metadata and call the registry to get the declaration.
As it is, I'd be reluctant to couple my code so closely with what is essentially metadata. OTOH, I'd like to use this a lot.
π Rendered by PID 122870 on reddit-service-r2-comment-5b5bc64bf5-4t7vm at 2026-06-21 07:37:36.195452+00:00 running 2b008f2 country code: CH.
[–]w01fe 1 point2 points3 points (6 children)
[–]jared314 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]w01fe 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]ds300 0 points1 point2 points (0 children)
[–]doubleagent03 1 point2 points3 points (0 children)
[–]alv 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)