This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-03
Channels
- # babashka (16)
- # beginners (70)
- # biff (1)
- # calva (15)
- # clj-commons (1)
- # cljsrn (1)
- # clojure (31)
- # clojure-android (1)
- # clojure-nl (4)
- # clojure-spec (17)
- # clojurescript (6)
- # cursive (3)
- # fulcro (22)
- # holy-lambda (21)
- # honeysql (20)
- # jobs-discuss (5)
- # kaocha (1)
- # lsp (51)
- # malli (1)
- # missionary (7)
- # nrepl (1)
- # off-topic (9)
- # portal (3)
- # reitit (1)
- # shadow-cljs (4)
- # xtdb (2)
This page https://clojurians-log.clojureverse.org/test-check/2019-02-26 and this https://github.com/clojure/test.check/blob/88eebf105fbb01db17ce12a3bff207cc395270b9/src/test/clojure/clojure/test/check/test.cljc#L18 seem to imply that I should be able to use it, but I don't see how
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 š®
moreover, where is this code https://github.com/clojure/test.check/blob/master/src/test/clojure/clojure/test/check/test.cljc#L1054 getting the gen/let
?
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.
^ but yeah if you don't care about this stuff then just import test.check generators like you just posted š
awesome! Now I understand why the re-export was needed and what's the problem with re-exporting the let
macro. Thanks again @U0CLLU3QT
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 (https://github.com/clojure/spec-alpha2/wiki), and the talk where Rich talks about it https://www.youtube.com/watch?v=YR5WdGrpoug&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.