Skip to content

Commit

Permalink
Strengthen return types for a bunch of seq/seqable fns (#219)
Browse files Browse the repository at this point in the history
rest, map, filter etc. can't return nil.
They should also conform to seq?, not the broader seqable?
  • Loading branch information
bonega authored and borkdude committed Jan 7, 2019
1 parent 4af9e11 commit fcadece
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
24 changes: 7 additions & 17 deletions src/speculative/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
;; 57
(s/fdef clojure.core/next
:args (s/cat :coll ::ss/seqable)
:ret ::ss/seqable)
:ret (s/nilable ::ss/seq))

;; 66
(s/fdef clojure.core/rest
:args (s/cat :coll ::ss/seqable)
:ret ::ss/seqable)
:ret ::ss/seq)

;; 75
(s/fdef clojure.core/conj
Expand Down Expand Up @@ -216,9 +216,7 @@
(s/fdef clojure.core/map
:args (s/alt :transducer (s/cat :xf ::ss/transducer)
:seqable (s/cat :f ::ss/ifn :colls (s/+ ::ss/seqable)))
:ret ::ss/seqable-or-transducer
:fn (fn [{:keys [args ret]}]
(= (key args) (key ret))))
:ret ::ss/seq-or-transducer)

;; 2793
(s/def ::filter-fn-args
Expand All @@ -227,16 +225,12 @@

(s/fdef clojure.core/filter
:args ::filter-fn-args
:ret ::ss/seqable-or-transducer
:fn (fn [{:keys [args ret]}]
(= (key args) (key ret))))
:ret ::ss/seq-or-transducer)

;; 2826
(s/fdef clojure.core/remove
:args ::filter-fn-args
:ret ::ss/seqable-or-transducer
:fn (fn [{:keys [args ret]}]
(= (key args) (key ret))))
:ret ::ss/seq-or-transducer)

;; 3019
(s/fdef clojure.core/range
Expand Down Expand Up @@ -322,9 +316,7 @@
(s/fdef clojure.core/interpose
:args (s/alt :transducer (s/cat :sep ::ss/any)
:seqable (s/cat :sep ::ss/any :coll ::ss/seqable))
:ret ::ss/seqable-or-transducer
:fn (fn [{:keys [args ret]}]
(= (key args) (key ret))))
:ret ::ss/seq-or-transducer)

(s/def ::get-in-args
(s/cat :map (s/nilable ::ss/associative)
Expand Down Expand Up @@ -381,9 +373,7 @@
;; 7313
(s/fdef clojure.core/keep
:args ::filter-fn-args
:ret ::ss/seqable-or-transducer
:fn (fn [{:keys [args ret]}]
(= (key args) (key ret))))
:ret ::ss/seq-or-transducer)

;;;; Scratch

Expand Down
4 changes: 2 additions & 2 deletions src/speculative/specs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
(fn []
(gen/return (map identity)))))

(s/def ::seqable-or-transducer
(s/or :seqable ::seqable
(s/def ::seq-or-transducer
(s/or :seq ::seq
:transducer ::transducer))

(s/def ::atom
Expand Down

0 comments on commit fcadece

Please sign in to comment.