This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-04
Channels
- # admin-announcements (1)
- # alda (2)
- # beginners (52)
- # boot (8)
- # cider (14)
- # cljs-dev (7)
- # cljsrn (5)
- # clojure (4)
- # clojure-belgium (2)
- # clojure-brasil (1)
- # clojure-dev (8)
- # clojure-greece (6)
- # clojure-russia (34)
- # clojure-spec (42)
- # clojurescript (20)
- # cursive (5)
- # funcool (1)
- # hoplon (313)
- # immutant (1)
- # lambdaisland (24)
- # mount (1)
- # om (26)
- # perun (1)
- # planck (2)
- # proton (1)
- # protorepl (6)
- # pure-frame (15)
- # re-frame (14)
- # specter (17)
- # spirituality-ethics (1)
I'd like to ship a library without requiring test.check
, and have the generators dynamically loaded as they are with clojure.spec
, but I can't figure out how to do that. Do I wrap all calls to clojure.spec.gen
functions in clojure.spec.gen/delay
?
(the library is essentially a bunch of specs, some of which require custom generators)
that is kind of interesting to think about, if you are defining custom specs with generators in your source, then test.check needs to be a regular dependency not a test scoped dependency
you likely need some combination of something like dynaload from clojure.spec.gen and the delay there and maybe clojure.core/delay
that would still have issues with any kind of tooling that loads all namespaces (in the absence of test.check)
I was thinking of stuff like lein check, but that only loads stuff from the current project
on another track…. 1st order predicate expressions and regular languages are closed under intersection — would be cool if somebody wrote an ‘intersect’ function for spec, could be useful for static analysis
@arohner: well you could just write an abstract interpreter that walks the clojure AST and instead of an environment of symbols -> values, have an environment of symbols -> specs
intersecting two predicates is just and-ing them, but you could do better for some predciates, cat, repeat, alt, etc
yeah, i have a clojure interpreter that i’ve copy/pasted and modified 4 or 5 times for code walking purposes - someday i’ll make it a library
in the mean time: https://github.com/brandonbloom/metaclj/tree/master/src/metaclj/impl
the transform namespace is an example of a code walk on that ast & you could replace that with a type check walk
here’s an interpreter: https://github.com/brandonbloom/eclj/blob/master/src/eclj/interpret/meta.eclj
I’m already walking the tools.analyzer output, so it’d be a good amount of work to swap
not suggesting that you switch to my thing 😛 just showing that it can be much less code than tools analyzer, which does all the analysis all at once
the first big question about clojure.spec that I'm going to try to dive into is how I can get functionality similar to https://github.com/gfredericks/schema-bijections
so I suspect (ha!) I'll be reading a bunch of the clojure.spec source soon
is it weird that s/tuple takes preds instead of specs?
I have a tuple '(s/def ::color (s/tuple ::byterange ::byterange ::byterange ::byterange))' that seems to work @gfredericks
as of now, I have successfully converted my project from plumatic.schema to cljs.spec!
benzap: yeah it does seem to work, but that means the docs are misleading I think: preds are specs but specs aren't preds