Fork me on GitHub

Silly might be wrong, but tedious maybe?


what I’d like to be able to state is “I only care about the first argument and it should be a grid ”


@slipset That's what you're stating with that spec, though, isn't it? 😄 If you feel it's too noisy and/or you're going to use it in many places, you could define a macro that hides that noise.


apart from that, it seems like spec is giving me exactly what I want: the possibility to sprinkle “types” over my program when it’s “done”.


Namespace myproj/myns.clj contains a function, which requires specs defined in myproj/specs.clj. I have the function fdef'd and it currently sits next to the function itself in myns. However, I'd like to move the function spec away from the function itself. So myns depends on specs, but the fdef'd function depends on knowing about the function itself in myns, so I can't move it to specs. Circular dependency. Where are you putting your spec'd functions (or in general, any of your specs) in your project?


the specced namespace IMHO should not require the specs


it was explicit design of clojure.spec that you can spec things you don't own


(s/fdef myns/my-fn ...)
without explicitly importing myns in specs, @joshjones


misha: is that missing a colon?


no, its a fully qualified fn name, like clojure.string/blank?


misha: so you have to require that ns in your spec file? or otherwise define it there? that seems odd, but i'm a relative noob at spec.


no, requireing needed. afair, spec just uses fn symbol to register spec, and does not call actual fn, so the actual require'ing is not needed


many thanks to you both -- @ghadi , by "the specced namespace" you mean myns or specs in my example above?


yourproj.specs should depend on yourproj.myns, not the other way around, like @misha 's example


yeah, myns might not need specs imported unless it uses one for explicit validation as a workflow step


it does -- (s/assert ::specs/myspec some-data)


Many examples of using valid?, conform, etc also


then either keep fdef's closer to functions, or use fully qualified fn names in fdefs w/o explicit imports


you only need to require if you want to use an alias, is that correct?


mobileink: I'd say: only if you need to call something from that ns, or import for side effects. alias works w/o explicit import (at least it worked for me just now)


hmm, need to experiment more. i could swear i've used without require or import, but theres a goid chance i misunderstood what i was doing. ;)


2 types of specs: for data – keyword (:foo/bar), for functions – symbol (foo/baz)


i didn't think you could alias an ns without "making" it whether by require or sth else. i.e. just a symbol won't work. but i'm away from my machine, will try later.


aha, my bad - have not yet worked my way up to fn specs. sorry!


I am trying now, and I see no spec ns import required either: I can define specs for functions in foo.specs w/o importing foo.fns, and can use specs for assertions in foo.fns w/o importing foo.specs


time for me to take another sip from the firehose. not so easy when your lips have already been ripped off!


two namespaces, neither imports the other. instrumentation and validation work, because specs get registered in global registry


i think i assumed reg keys are always kws. bad programmer!


I have spec guide open at all times while doing spec development, for quick reference


me too - just haven't needed to deal with fns yet. it's hard enough to figure out how to do what i need with maps!


the only require use case I can think of now – is google closure compiler advanced optimization, where specs might get dead-code-eliminated. Haven't tried that yet though


fwiw i just got my clj map specs working in cljs, using cljc code. works like a charm - but haven't done advanced opt yet. shivers


thanks @misha, very helpful