clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
plexus 2020-05-31T11:07:47.074900Z

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.

2020-06-07T13:02:06.198100Z

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

2020-06-07T13:02:30.198300Z

You might want to give Minimallist a try.

2020-06-07T13:04:06.198500Z

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

plexus 2020-06-08T10:27:59.212400Z

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?

plexus 2020-05-31T11:09:07.075700Z

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

plexus 2020-05-31T11:11:16.078Z

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

plexus 2020-05-31T11:11:59.078500Z

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?

alexmiller 2020-05-31T14:48:24.079400Z

Not easily (this is something weโ€™ve added in spec 2)

clayton 2020-05-31T15:41:33.083700Z

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 ๐Ÿ™‚

alexmiller 2020-05-31T16:48:57.084Z

most useful in dev at the repl

alexmiller 2020-05-31T16:49:07.084300Z

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

clayton 2020-05-31T16:55:49.084400Z

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 ๐Ÿƒ

seancorfield 2020-05-31T18:10:44.084600Z

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

1๐Ÿ‘
clayton 2020-05-31T18:11:17.084900Z

will check out the repo for examples - thanks!

seancorfield 2020-05-31T18:11:32.085100Z

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