down votefavorite 
<https://stackoverflow.com/questions/46592767/how-do-i-make-custom-clojure-spec-generator#>

I'm trying to spec the following data structure called Connection:

{:id "some string" :channel "instance of org.httpkit.server.AsyncChannel" }

Here is my spec:


(defn make-channel []
  (proxy [AsyncChannel] [nil nil]
    (toString [] "mock AsyncChannel")))
(defn channel-gen
  []
  (->> (s/gen (s/int-in 0 1))
       (gen/fmap (fn [_] (make-channel)))))
(s/def ::channel (s/spec (::channel-type)
                         :gen channel-gen))
(s/def ::id string?)
(s/def ::connection (s/keys :req-un [::channel ::id]))
(s/fdef make-connection
        :args ::channel
        :ret ::connection)


I'm getting the following error and I have no clue what is wrong here:

clojure.lang.ExceptionInfo: Unable to construct gen at: [] for: 
gameserve.ws$make_connection@788ffa19
clojure.lang.Compiler$CompilerException: clojure.lang.ExceptionInfo: Unable to 
construct gen at: [] for: gameserve.ws$make_connection@788ffa19 
#:clojure.spec.alpha{:path [], :form #object[gameserve.ws$make_connection 
0x788ffa19 "gameserve.ws$make_connection@788ffa19"], :failure :no-gen}

-- 
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 - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to