Fork me on GitHub

is clojure.spec.gen.alpha/let not available in clojurescript?


If I try require

[clojure.spec.gen.alpha :as gen :include-macros true :refer-macros [let]]
it will say that there is no macro named let


@U04V15CAJ just because of the previous link


It doesn't because let is a macro and can't be lazy loaded (I believe that's the reason anyways). You can use the non-macro version, bind which is part of clojure.spec.gen.alpha


Just to clarify, let is not available in the Clojure version of clojure.spec.gen.alpha either.


@U0CLLU3QT if the problem is the lazy loading, can I somehow preload it? Yes, I was trying to use let because it seems cleaner wrt bind and fmap which is what I'm using now. So, are the tutorials outdated? Was let removed from clojure.spec.gen.alpha at some point? I thought I used it in the past 😮


ok, I'm so dumb, I should just have imported clojure.test.check.generators where the let macro I'm interested in is actually defined :man-facepalming:. Thanks for the help!


Those examples look like just test.check, which specs gen namespace lazy load behind statically defined functions. It's a design decision in spec, that all the functions in the gen namespace can be used without loading clojure.test.check.generators until needed (for example people could define specs for use in production code but only incur loading the test.check.generators namespace in their test suite where they'll use that functionality). In ClojureScript, it's the same but there is no true lazy loading, but you only need to manually require the test.check namespaces when you need them.

🙌 1

^ but yeah if you don't care about this stuff then just import test.check generators like you just posted 😊

🙌 1

awesome! Now I understand why the re-export was needed and what's the problem with re-exporting the let macro. Thanks again @U0CLLU3QT

👍 1

I briefly used spec.alpha but didn’t end up doing much with it. I’m interested in using spec2 for message validation in a pub/sub system. Can someone point me to the current “state of the art”/example use cases/best practices/etc. for using spec2?


Currently spec 2 is a work in progres and not ready for production use, so there is not much to be found, but if you’re still interested to give it a try, there’s some info on the github’s repo wiki (, and the talk where Rich talks about it;ab_channel=ClojureTV


Spec 2 still has a lot of bugs and has gone through a lot of changes -- with a number of additional changes still planned. We have been very heavy users of Spec (1) since it first dropped -- in production code -- and for about three months we ran a branch of our code tracking Spec 2 but it just became intractable to keep tracking it and working around the bugs...


got it. I will use spec 1 then. thanks.


after a bit of research, I decided to use metosin/malli. Seems to have all the features I need and I like the data-driven orientation.