Fork me on GitHub
#clojure-spec
<
2018-06-15
>
ackerleytng06:06:34

what's the difference between gen/hash-map and just using gen/fmap (fn [a] {:a a}) ...?

bbrinck14:06:04

@ackerleytng hash-map can take multiple key-value pairs

bbrinck14:06:35

(whereas in your example, the function you pass to fmap only takes a single value)

bbrinck14:06:19

under the hood, hash-map does use fmap with zipmap to combine these into a map, which is just a more general version of your code above: https://github.com/clojure/test.check/blob/729de024f245c07011a2cd2fcaad04bcd90a223d/src/main/clojure/clojure/test/check/generators.cljc#L645-L646

ackerleytng16:06:49

i see, thanks!

kenny18:06:50

Is there a way to only check the keys explicitly written in a Spec? i.e. No implicit validation of keys. I have a case where I need to validate partial pieces of a larger map.

noisesmith18:06:49

@kenny when would spec implicitly validate your key?

kenny18:06:18

Any map implicitly validates all keys against existing specs.

noisesmith18:06:31

select-keys before validating?

kenny18:06:44

Could totally do that but then I need to write the set of keys twice.