Fork me on GitHub
#clojure-spec
<
2020-05-31
>
plexus11:05:47

I'm trying to figure out how to prevent my recursive spec-based generators from StackOverflowing. From what I can tell the checks that are built in based on *recursion-limit* are moot as soon as you use with-gen.

Vincent Cantin13:06:06

That’s really a coincidence, because I am currently working days and days on overcoming this problem.

Vincent Cantin13:06:30

You might want to give Minimallist a try.

Vincent Cantin13:06:06

@U07FP7QJ0 let me know if you want to try the pre-release repo.

plexus10:06:59

what's your sales pitch? why should I consider Minimalist over Malli (my preferred solution nowadays), and does it solve the problem I linked to?

plexus11:05:07

I currently have two places where I'm using with-gen that cause recursion, https://github.com/lambdaisland/regal/blob/master/src/lambdaisland/regal/spec_alpha.cljc#L44-L47

plexus11:05:16

The second one I could get away without the custom generator, it'll just do some extra work until it finds a valid value, but the first one is annoying. The spec boils down to (s/and (s/cat ...) vector?), but (s/cat ...) never generates vectors so when generating this tries 100 times and gives up

plexus11:05:59

maybe there's a better way to write that? can I use regex specs but still convey that I really only want to match/generate vectors?

alexmiller14:05:24

Not easily (this is something we’ve added in spec 2)

clayton15:05:33

Hello! I've recently done some reading on clojure spec and have added it to some side projects of mine, but I'm a little lost on how/when to use instrumentation (or orchestra). I've spec'd multiple functions in my project, but realize those are useless (aside from readability) without running some sort of instrumentation. Are there any resources explaining how to integrate instrumentation in a clojure project? I don't want to permanently leave a call to instrument inside my clojure files, and only want them to really be run during development phase. Aside from just running instrumentation in the REPL during the dev process, are there any best practices for instrumenting in my project? Thanks 🙂

alexmiller16:05:57

most useful in dev at the repl

alexmiller16:05:07

but could also be useful to turn on/off in a fixture around tests

clayton16:05:49

Thanks! I've only ever used instrumentation in tests or the repl, but was thinking I was missing something. Back to the specs I go 🏃

seancorfield18:05:44

@UB4EZH42F In the tests for seancorfield/next-jdbc I turn on instrumentation as part of test setup in several of the test namespaces.

👍 1
clayton18:05:17

will check out the repo for examples - thanks!

seancorfield18:05:32

I talk about how we use Spec at work in https://corfield.org/blog/2019/09/13/using-spec/ if that helps.