The same question was asked on
https://clojurians-log.clojureverse.org/clojure-spec/2018-01-19
but I did not find an answer.
An example, where defrecord works fine but deftype fails:
(do
(require '[clojure.spec.alpha :as s])
(defprotocol Foo (foo [this]))
(defrecord Bar [bar] Foo (foo [this
So is it best practice to implement map in the deftype to make it
spec-able? Are there examples somewhere that show how to do this in a
canonical way?
On Wednesday, July 4, 2018 at 12:51:29 PM UTC+2, Leon Grapenthin wrote:
>
> Spec doesn't check object fields. The defrecord case works because
>
So is it best practice to implement map in the deftype to make it
spec-able? Are there examples somewhere that show how to do this in a
canonical way?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googl
Just in case someone stumbles over this post, I found a simple solution
which works for me:
(do
(require '[clojure.spec.alpha :as s])
(import '(clojure.lang ISeq))
(defprotocol Foo (foo [this]))
(defrecord Bar [bar] Foo (foo [this] (.bar this)))
(deftype Baz [bar]
Foo (foo [this]
Consider the following cloure.spec-alpha2 example:
(def v [0])
(s/def ::thevec vector?)
(s/def ::data (s/coll-of number? :kind ::thevec))
(s/valid? ::data v) ;;=> returns false, my expectation is that it should
return true
(s/explain ::data v) ;;=> prints "Success!", which inconsistent to s/va
PM UTC+2, Alex Miller wrote:
>
>
>
> On Thursday, September 26, 2019 at 7:41:20 AM UTC-5, Markus Agwin wrote:
>>
>> Consider the following cloure.spec-alpha2 example:
>>
>> (def v [0])
>> (s/def ::thevec vector?)
>> (s/def ::data (s/coll-of numb