Fork me on GitHub
#clojure-spec
<
2021-10-03
>
Carlo17:10:11

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

Carlo17:10:29

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

Carlo18:10:05

@U04V15CAJ just because of the previous link

colinkahn18:10:02

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

colinkahn18:10:30

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

Carlo19:10:18

@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 šŸ˜®

Carlo21:10:22

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!

colinkahn21:10:21

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
colinkahn21:10:55

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

šŸ™Œ 1
Carlo21:10:18

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
mafcocinco17:10:42

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?

bortexz17:10:29

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 (https://github.com/clojure/spec-alpha2/wiki), and the talk where Rich talks about it https://www.youtube.com/watch?v=YR5WdGrpoug&amp;ab_channel=ClojureTV

seancorfield22:10:35

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...

mafcocinco03:10:07

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

mafcocinco01:10:46

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.