Fork me on GitHub
#clojure-spec
<
2016-12-21
>
bsima00:12:30

gdeer81 that's cool

gdeer8100:12:39

I also used pmap to run it over a vector of 99,999 numbers, still no failures

bsima00:12:40

maybe you could use the funcool "cats" library to handle side effects, and check for right/`left` return types in the spec? idk, haven't used it much

jiangts07:12:35

using conformer, wondering how to conform a given input efficiently without conforming then unforming

dergutemoritz08:12:08

@jiangts Can you give an example or elaborate your problem some more? I don't see why you'd need to conform and unform using conformer

jiangts09:12:17

@dergutemoritz when you coerce with just conform you get a parsed version of the data, including the paths on ors or keys for example. I’d like a coerced version of the data without those key paths, which can be removed with unform

dergutemoritz09:12:11

There are multiple ways around that. For example, in case of s/or, something like this will do: (s/and (s/or ...) (s/conformer val))

dergutemoritz09:12:38

For s/cat, often if you don't care about the path labels, you are probably looking for s/tuple instead

dergutemoritz09:12:17

But perhaps you should think about whether keeping the path labels is actually the better idea!

gdeer8119:12:15

does it make sense to have a separate file for general specs and then inline specs that are specific to that namespace?

gfredericks20:12:45

@ag (gen/let [gen'd-accounts (-> :account/spec s/gen (gen/vector (count accounts)))] (map merge gen'd-accounts accounts))

Oliver George21:12:40

Has anyone written a destructuring to spec translator? Idle thought really. I was wondering about how to spec namespaces with less overhead... a convention based around arglist destructuring and using variable names which match registered specs could work. e.g.

(s/def ::base-url string?)
(s/def ::request (s/keys :req-un [::url ::params]))
(s/def ::page-limit pos-int?)
(s/def ::page-count pos-int?)

(x/defn load-options
  [{:keys [base-url]} [_ request page-limit page-count]]
  ...

Oliver George21:12:00

Also, merry xmas everyone.

Oliver George22:12:09

I guess the same could be done after the fact by referring to the fn :arglists metadata.

Oliver George22:12:08

Feel free to comment there if it's a terrible idea or I'm missing key points.

alexmiller22:12:46

for perf reasons, we would not do that in core

bsima23:12:58

is there a way to write an fdef that says "this function should take :my/spec as it's argument but only after the arg has conformed with (conform :my/spec arg)" ??

Oliver George23:12:21

@alexmiller that sounds sensible. hard to imagine it being unopinionated enough to be suitable as a core feature too. Do you think the idea has merit? I guess the real benefit is tidier code which is superficial.

Oliver George23:12:06

@alexmiller there was talk of a "dev version" of clojure with more spec integration... less performant but more errors for the developer. Is that still on the cards?

alexmiller23:12:32

@olivergeorge: seems like most cases that's not what I would want

alexmiller23:12:29

On the dev version, possibly although just not front burner right now