Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

Support HSequential #2

Merged
merged 5 commits into from Feb 5, 2016
Merged

Support HSequential #2

merged 5 commits into from Feb 5, 2016

Conversation

dball
Copy link

@dball dball commented Feb 1, 2016

HSequential and HVec are just like HSeq except they add a predicate for sequential? and vector?, respectively. NonEmptyLazySeq uses both a predicate for instanceof LazySeq (slightly stronger than what core.typed does itself, but both appear to exclude e.g. (range) proper) and tests the first value in the seq against the type.

Donald Ball added 5 commits February 1, 2016 18:11
This treats them just like HVecs except it adds a predicate that they
satisfy sequential?

It may be worth noting that the schema for HVec allows things not allows
by the core.typed predicate, e.g. lists. Possibly it's worth revisiting
these types with stronger type predicate schemas?
This requires the seq to be an instance of clojure.lang.LazySeq (which
may be too strong, tbqh) and that it has a first value whose type checks
the seq's type.
This seems to be a straightforward predicate
'["hey" 12])))
(is (nil? (s/check (schema (t/NonEmptyLazySeq t/Int)) (map inc (range)))))
(is (nil? (s/check (schema (t/HMap :absent-keys #{:foo :bar})) {:not "foo"})))
(is (not (nil? (s/check (schema (t/HMap :absent-keys #{:foo :bar})) {:foo "foo"})))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fyi: there is some? which I always forget about because I'm a pre-1.0-or-bust person :)

takeoutweight added a commit that referenced this pull request Feb 5, 2016
@takeoutweight takeoutweight merged commit edd7037 into master Feb 5, 2016
@takeoutweight takeoutweight deleted the feature/support-hsequential branch April 19, 2016 00:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants