On Wednesday, May 25, 2016 at 4:46:57 PM UTC-4, kovasb wrote:
>
>
> On Wed, May 25, 2016 at 3:01 PM, Mike Rodriguez <mjr...@gmail.com 
> <javascript:>> wrote:
>>
>> I always really liked that Prismatic Schema had a "data representation" 
>> and that seems to be the Clojure-way anyways.  I haven't dug into this too 
>> much yet, but I'm hoping that the Spec's do have some way to 
>> programmatically inspect them and utilize their structures for other 
>> purposes. 
>>
>
> Nothing precludes a system of data-described predicates. 
>
> Just implement a datatype that implements IFn, in addition to some 
> collection interface. Basically something like Records, except that (f x) 
> will invoke the predicate described by f's data rather than looking up a 
> value in the collection that f also represents. 
>
> How this would work out in practice I have no idea but it seems worth 
> trying. 
>

This is what the *spec-impl functions in clojure.spec do, essentially.  But 
the only internal field a user can get at is 'form'.  That's why I think 
the easiest way to programmatically inspect them, currently, is to call the 
's/form' function (thanks, Timothy) and parse it back into a description of 
the internal fields.  This will probably work for a lot of use cases.  
Seems a little roundabout, though.

But, if my reading of the code is correct, the generators are hidden, so 
someone wanting to write code that, e.g., 'completes' partial data 
conforming to a spec would have to--well, I don't know what, exactly, but 
some kind of trickery.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to