Re: spec for an agent

2017-11-17 Thread Didier
> > Having said which, I could have a function make-agent-state and spec > that, then the body of make-agent is just (agent (make-agent-state > ...initialisers...)) Is that what you're suggesting? Ya, sorry, I didn't meant to sound like I was questioning why you needed to do X. This is what I

Re: spec for an agent

2017-11-17 Thread Peter Hull
On Friday, 17 November 2017 16:53:57 UTC, Didier wrote: > > Why do you return an agent from a function? Can't you just return the map > it conatains instead? And spec that? I want to write a function spec (s/fdef) for a function make-agent that takes some initialisers and returns a new agent wi

Re: spec for an agent

2017-11-17 Thread Didier
Why do you return an agent from a function? Can't you just return the map it conatains instead? And spec that? -- 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 memb

Re: spec for an agent

2017-11-17 Thread Timothy Baldridge
And google doesn't like that link, copy-paste that URL including the "!" On Fri, Nov 17, 2017 at 2:00 PM, Timothy Baldridge wrote: > All clojure ref types have validators that are perfect for this use case: > https://clojuredocs.org/clojure.core/set-validator! > > On Fri, Nov 17, 2017 at 1:58 PM

Re: spec for an agent

2017-11-17 Thread Timothy Baldridge
All clojure ref types have validators that are perfect for this use case: https://clojuredocs.org/clojure.core/set-validator! On Fri, Nov 17, 2017 at 1:58 PM, Peter Hull wrote: > I am using agents whose state is a map. I have a spec for this map, > ::agent-state. What's the best way to validate

spec for an agent

2017-11-17 Thread Peter Hull
I am using agents whose state is a map. I have a spec for this map, ::agent-state. What's the best way to validate the agent? I have: (s/valid? #(s/valid? ::agent-state (deref %)) myagent) Is this there a neater way to do this? (I actually want the spec to apply to the ret value of an s/fdef)