This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-08
Channels
- # adventofcode (49)
- # babashka (21)
- # babashka-sci-dev (12)
- # beginners (250)
- # calva (23)
- # cider (6)
- # clj-kondo (11)
- # cljsrn (8)
- # clojure (129)
- # clojure-europe (50)
- # clojure-france (8)
- # clojure-italy (6)
- # clojure-nl (14)
- # clojure-romania (7)
- # clojure-spec (21)
- # clojure-uk (3)
- # clojurescript (17)
- # conjure (1)
- # core-async (40)
- # core-logic (24)
- # core-typed (7)
- # datavis (2)
- # datomic (2)
- # emacs (29)
- # fulcro (10)
- # graalvm (6)
- # graphql (24)
- # gratitude (6)
- # jobs (1)
- # lsp (9)
- # malli (6)
- # missionary (1)
- # nextjournal (46)
- # off-topic (2)
- # other-languages (3)
- # pathom (5)
- # portal (2)
- # re-frame (37)
- # remote-jobs (1)
- # shadow-cljs (15)
- # spacemacs (9)
- # testing (6)
- # tools-deps (13)
- # vim (32)
- # xtdb (16)
> For this we have exercise
, which returns pairs of generated and conformed values for a spec
What if we just want the generated values?
i can fish them out, but i'm guessing there is a convention rather then threading with calls to first.
you can call gen/sample if you just want generated values https://clojure.github.io/spec.alpha/clojure.spec.gen.alpha-api.html#clojure.spec.gen.alpha/sample
sorry, https://clojure.github.io/test.check/clojure.test.check.generators.html#var-sample is the docstring for that
thanks alex. ill read that shortly!
that likely does what i need. it would be nice if i had away to easily jump from one doc to another. that fns args are are just & args and the doc string is that its a lazy version of another fn. not much to go off! i guess i should just jump to the code?
well, im guessing that would be very educational
(lazy-combinators hash-map list map not-empty set vector vector-distinct fmap elements
bind choose one-of such-that tuple sample return
large-integer* double* frequency shuffle)
but not very direct 🙂
I'm working on better clojure.spec support for babashka. I'm testing expound with instrumentation. How do people generally get to see expound's output when running with instrumented functions? What do you have to configure, besides the explain printer? It seems you have to catch the ExceptionInfo and push the ex-data through s/explain-out yourself?
Besides that question: what are some libraries that leverage clojure.spec that I should test.
reitit with spec based coercions
https://github.com/nedap/speced.def perhaps, we've wanted to use it for bb scripting sometimes (@UHJH8MG6S)
We have a library that provides and conforms against specs for incoming complex values. Within the values can be maps and s/keys
will, as the doc string says:
> In addition, the values of all namespace-qualified keys will be validated (and possibly destructured) by any registered specs.
If the caller puts their own namespaced keys in the map (which is fine) and they have defined specs for these, those specs will be validated (and conformed) when we validate or conform the larger structure.
This creates problems in providing good error messages since, when we conform, we don't know if the caller has violated our spec or their own spec. There's no way to conform only our parts of the spec first to validate the shape of their input without also conforming and failing on their values. This leads to a very confusing error message that we can't help to resolve.
Is there a sane work around for this? I'd really like an s/keys
option or similar that doesn't validate keys beyond those expressed.
a) you could narrow the data before conforming b) hopefully you can differentiate by key namespace either for narrowing or for error gen?
(a) doesn't work since we actually want the data preserved in the conformed result.
I'll look at (b) but would love to mention that having local specs (similar to local Clojure hierarchies) is really what I think I want as a user. You can have the global spec (just like global-hierarchy
) but also provide a local subset or curated spec for a particular context.
yeah, that's not in line with the spec rationale https://clojure.org/about/spec#_global_namespaced_names_are_more_important
Oh, I love namespaced names and the general global usage is fine but, as Stu and Rich have noted, a la carte features are valuable for application domain use cases not just programming domain use cases. I'd love to have spec for application domain use cases which is exactly what hierarchies allows for. Global for programming domain, a la carte for application domain. Often the specs overlap so you want to be able to re-use them between the two.