Thanks Alex, I was experimenting along similar lines. It might work since
the lazy seq is not realized at this point and :f might not have been
called. Otherwise the last clause would always hold true or never be called
(due to earlier ArityException). It covers more of a test for map itself
(h
I think map is a good example where the different arities have very
different semantics, and maybe it would be practical to specify a separate
spec for each arity.
In the unified spec, both :args and :ret have to resort to (more or less
explicit) unions in order to express the sum of the separa
I was suggesting that you could do something like this (although I'm pretty
sure this doesn't work right now):
(s/fdef map
:args (s/cat :f (s/fspec :args (s/+ ::s/any))
:colls (s/* seqable?))
:ret (s/or :seq seqable? :transducer ifn?)
:fn #(if (zero? (count (-> % :args :colls
could be better because the user has to
>>>>> infer how identity was called within map.
>>>>>
>>>>> So what we'd want is a codependent spec where we can say if you give N
>>>>> sequences you have to give a fnN. Is this possible with the current ops?
>>
ible with the current ops?
>>>>
>>>
>>> Yes, with fspec - you could have a :fn spec on map that checked that the
>>> arity of the fn passed to map matched the number of colls you were passed.
>>>
> On Jun 12, 2016, at 10:45 AM, Alex Miller wrote:
>
> Still much to be determined about this but I expect that specs for core will
> be provided and maintained by us, because while there are a lot of obvious
> specs in core, there are also a lot of far more subtle ones.
I think this is the ri
owler wrote:
>>>>
>>>> Is there an effort to write specs for Clojure's core namespaces? Apologies
>>>> if this has already been addressed.
>>>>
>>>> I've been tinkering with trivial (and probably wrong) fdefs on
>>>> clojure.core/map and clojure.core/identity. It seems
;> clojure.core/map and clojure.core/identity. It seems that the spec
>>> exception messages are way better than what we have now.
>>>
>>> Code is here:
>>> https://gist.github.com/ryfow/69a64e966d48258dfa9dcb5aa74005eb
>>> <https://www.google.com/url?q=https%3A%2F%2Fgist.github.com%2Fryfo
eems that the spec
>> exception messages are way better than what we have now.
>>
>> Code is here:
>> https://gist.github.com/ryfow/69a64e966d48258dfa9dcb5aa74005eb
>> <https://www.google.com/url?q=https%3A%2F%2Fgist.github.com%2Fryfow%2F69a64e966d48258dfa9dcb5aa7
.github.com/ryfow/69a64e966d48258dfa9dcb5aa74005eb
>
>
> =====
> Before instrumenting clojure.core/map
> =
> Form: (into [] (map nil [1 2 3] [1 2 3]))
> Exception
Yeah, I've been working on parts of this and there will be more to say in the
future.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - pleas
e have now.
Code is here: https://gist.github.com/ryfow/69a64e966d48258dfa9dcb5aa74005eb
=====
Before instrumenting clojure.core/map
=
Form: (into [] (map nil [1 2 3] [1 2 3]))
12 matches
Mail list logo