I'm curious is there a way to make a String type that has a max length?
Maybe? Try (t/I t/Str (t/CountRange 0 10)) for strings of 10 chars or less.
There might be a few missing pieces but some of the building blocks are there.
I'm not sure if (<= (count s) 10) will infer this type (might need some tweaks to the checker). I don't know if t/pred supports t/CountRange but generating a predicate from the type might be useful.
Yeah this should work.
(defalias String<=10 (t/I t/Str (t/CountRange 0 10)))
(def string<=10? (t/pred String<=10))That works thanks!
Note that CountRange max is inclusive.
Ok turns out I wasn't actually hitting that code. When I test it more in depth that pred only returns false for everything.
I tested it with your exact example
thanks I'll take a look.
found the problem
https://github.com/typedclojure/typedclojure/commit/96e71a850bb1291f3e898839130657ca8a673753
also pushed some perf/memory improvements in the compiled preds.