This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-09
Channels
- # announcements (5)
- # beginners (53)
- # clj-kondo (4)
- # cljdoc (3)
- # cljs-dev (11)
- # cljsjs (1)
- # clojure (59)
- # clojure-europe (15)
- # clojure-italy (6)
- # clojure-nl (9)
- # clojure-spec (22)
- # clojure-uk (26)
- # clojurescript (16)
- # clojutre (6)
- # cursive (27)
- # datomic (34)
- # duct (1)
- # figwheel-main (2)
- # fulcro (12)
- # graphql (14)
- # jackdaw (9)
- # jobs (1)
- # kaocha (4)
- # luminus (1)
- # off-topic (11)
- # pathom (1)
- # pedestal (2)
- # re-frame (6)
- # reagent (10)
- # ring-swagger (34)
- # shadow-cljs (47)
- # spacemacs (21)
- # sql (3)
- # tools-deps (37)
- # uncomplicate (11)
- # vim (17)
may have been discussed before, but is there a way to install a custom randomness source into spec/gen?
gen rides on test.check
test.check does have pluggable randomness, although there are some caveats about it as it's designed to be repeatable
prob best to hit up @gfredericks for the details
from spec side, the big thing is that stest/check reports the seed it used and accepts a seed as an option to pass along
t.c isn't wired up for that, but the protocol is in place, so currently you could pull it off by monkeypatching random/make-random
right. i traced it down to the relevant files, and quickly realized that there are a number of features about the existing random interface that id want to keep in almost every case
What's the motivation?
using the current spec-alpha2.gen
whats the best way to create a generator that basically calls a function and returns the value? looking for something like gen/return
that evaluates x
in each generation
it may sound weird, but im aiming for a generator that produces a fixed number of CSR bytes
Sounds like something better addressed at the generator or spec level, if I'm understanding you
Or is this some kind of security thing where you want High Quality Randomness?
yeah, it definitely is. i was mistaken to think that it would be interesting to aim at the test.check
level
gen/fmap is the normal trick for making a generator from an impure function, with all the usual caveats
i do want a certain quality of randomness, but more generally im looking for something that would let me (gen/let [x (some-fn-producing-x)] x)
, but gen/let
isnt exposed in spec-alpha2.gen
. im using fmap
now, but didn’t know if that was the right way:tm:. appreciate the input!
There is no right way, because it circumvents determinism, growth, and shrinking; but spec has generally made theses things a lot murkier
makes total sense. thats what i quickly realized when i was digging into the test.check
randomness. those are some really neat files, way above what im trying to do
fmap is a generator combinator, and partial is a function combinator; the result is also a generator combinator I suppose