I tried to read official docs for several times, but it still confuses me how to solve my real-world problems in Specs. I’m using assert
to very some of my arguments in my projects and definitely I need something more powerful.
I had the same confusion when I first saw specs. Then I practised parsing a lot data structures with clojure.spec/conform
and suddenly things get clearer
Do you write blogs when you practice?
Sorry, I didn’t think about that. But that’s a good idea!
Hi,
Maybe you’ll find these interesting:
- Tiny toy project using spec as a parser combinator: https://feierabendprojekte.wordpress.com/2017/02/14/spec-is-almost-a-parser-combinator/ (code on github)
- Spec and dependent types on github
- Interesting for learning what conform does: https://feierabendprojekte.wordpress.com/2016/09/11/generating-ui-for-arbitrarily-nested-data-structures/ (code on github)
- and finally a slightly more advanced meta-use of spec: conforming conformed data: https://feierabendprojekte.wordpress.com/2017/06/12/conforming-conformed-data/
Cheers
tried to read official docs for several times
I doubted if there are others things I need to learn first. I don’t have much experience on testing or backend being a front-end developer.
Oh, sorry, when you said docs I thought you meant https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html#clojure.spec.alpha
I have not found a lot of good tutorials appart from the official guide yet, since its all pretty new.
Fogus’ blog posts look promising:
- http://blog.fogus.me/2017/01/10/clojure-spec-introduction/
- http://blog.fogus.me/2017/02/10/clojure-spec-data-design-01-sketching-a-struct/
If only there were more posts in this series :).
Why it has to be namespaced keywords in Clojure Spec?
Just like immutability is enforced in Clojure so people don’t shoot themselves on the foot, only namespaced keywords are allowed for good reason: no name collision in the long run