Specs are for checking the shape of data. "deferreds" are not data, they are opaque objects. So in short the answer is "you can't" or more correctly: you may be able to, but shouldn't.
One of the problems with even trying to spec something like IDeref is that the very act of observing it may have a side effect. For example: (delay (launch-missiles)). The only way you can see if that conforms to some spec is by calling `deref` on it which would have the side effect of launching some missiles. This sort of thing follows the same advice Clojure has had for some time...put data inside IDerefs don't put IDerefs inside data. On Sat, Oct 29, 2016 at 10:38 AM, Mohammad Sadeq Khoeini <[email protected] > wrote: > > I'm trying to write a wrapper for telegram api[1]. Responses from the api > are either successful, > which would then have a `{"ok": true, result: ...}` shape, or error with > the shape of `{"ok": false, description: "..."}`. > Also, I'm using aleph to call the api. So, the responses are deferreds [2]. > > Now, I want to write spec for my functions like get-messages, etc. But the > problem is I have no clue how I can model something like this. > It appears to me that I want to model something like generics of other > languages. i.e. IDeref<Message>. But I can't see any straight forward way > to do so using clojure.spec. > > What would you say be the idiomatic approach to model this. > > > [1]: https://core.telegram.org/bots/api > [2]: http://aleph.io/manifold/deferreds.html > > BR. > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
