How to spec a plain map with exclusive groups of :req keys?

2016-06-15 Thread Den Semenenko
Can`t grok how to deffine exclusive groups of :req keys with spec/keys. For а doc sample (s/keys :req [(or ::secret (and ::user ::pwd))]) I expected, that valid combination is a ::secret *either* ::user and ::pwd. But a map with all of these keys is still valid... Any tips how to spec a plain

How to spec a plain map with exclusive groups of :req keys?

2016-06-15 Thread Alex Miller
Because spec embraces the idea of open maps, there is no provided support for checking that keys don't exist. To get this behavior you will need to use a custom predicate (probably s/and with s/keys to get its other checks). -- You received this message because you are subscribed to the Google

spec.gen for uri?

2016-06-15 Thread Alex Miller
My own hammock time on this led me to believe that in most cases where users care about what uris they are testing, a custom generator will be required. There are very few applications that actually expect a wide variety of uri forms, so I saw no point in spending a lot of effort in producing th

Re: How to spec a plain map with exclusive groups of :req keys?

2016-06-15 Thread Walter van der Laan
You can wrap s/keys in s/and to add additional predicates, eg; (s/and (s/keys) #(or (::secret %) (and (::user %) (::pwd % You can also match the map with a predicate instead of s/keys, eg; #(and (map? %) (or (::secret %) (and (::user %) (::pwd % The the first option, with s/keys, will c

Re: why is it so annoying to run clojure code

2016-06-15 Thread James Gatannah
It was (thoughtfully and politely) pointed out that I came across as smug here. I'm very sorry about that. I plead exhaustion. I use python for most of my day job. I was trying to convey how much more painful its workflow is for me, now that I've embraced "the lisp way" for my personal projects

Re: why is it so annoying to run clojure code

2016-06-15 Thread Kenneth Tilton
On Wed, Jun 15, 2016 at 10:54 AM, James Gatannah wrote: > It was (thoughtfully and politely) pointed out that I came across as smug > here. > > I'm very sorry about that. I plead exhaustion. > Heh-heh, well, as the late, great Erik Naggum once said to me, you meant well and that is all that matt

Re: How to spec a plain map with exclusive groups of :req keys?

2016-06-15 Thread Den Semenenko
Alex, Walter, your tips are great for "validation". But I'm afraid this solution will lead to the custom generator... Anyway, thanks a lot. -- 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

Exercises and projects for my on-site training course

2016-06-15 Thread Daniel Higginbotham
Hi all, I've begun offering on-site Clojure training (loving it so far!) and wanted to share the examples, exercises, and projects that we work through. I've tried to include plenty of comments and documentation

Re: clojure.spec regression bug for 1.9.0-alpha6

2016-06-15 Thread webber
Maybe, the following is the same reason. ``` (defn ranged-rand ;; BROKEN! "Returns random integer in range start <= rand < end" [start end] (+ start (rand-int (- start end (s/fdef ranged-rand :args (s/and (s/cat :start integer? :end integer?) #(< (:start %) (:end %)))

Re: clojure.spec regression bug for 1.9.0-alpha6

2016-06-15 Thread Alex Miller
I'm in the process of updating that part of the guide right now, should be done by end of day. On Wednesday, June 15, 2016 at 12:30:55 PM UTC-5, webber wrote: > > Maybe, the following is the same reason. > > ``` > (defn ranged-rand ;; BROKEN! > "Returns random integer in range start <= rand <

In what sense does "coll-of" not flow conformed values?

2016-06-15 Thread Oded Badt
>From https://clojure.org/guides/spec#_collections: *One important aspect of coll-of and map-of is that they both sample their inputs, checking only a subset of the values for performance reasons. Due to this, conform of these specs does not flow conformed values (because they are not all confor

Re: In what sense does "coll-of" not flow conformed values?

2016-06-15 Thread Alex Miller
On Wednesday, June 15, 2016 at 1:36:54 PM UTC-5, Oded Badt wrote: > > From https://clojure.org/guides/spec#_collections: > *One important aspect of coll-of and map-of is that they both sample their > inputs, checking only a subset of the values for performance reasons. Due > to this, conform of

[ANN] Clojure 1.9.0-alpha7

2016-06-15 Thread Alex Miller
Clojure 1.9.0-alpha7 is now available. Try it via - Download: https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha7 - Leiningen: [org.clojure/clojure "1.9.0-alpha7"] 1.9.0-alpha7 includes the following changes since 1.9.0-alpha6 (all BREAKING vs alpha5/6): clojure.core: - long? => in

Re: clojure.spec regression bug for 1.9.0-alpha6

2016-06-15 Thread Sean Corfield
Given that we now have to use clojure.spec.test to get :ret / :fn tested, we lose the “nice” exceptions explaining the conformance failure: Alpha 5: ;;=> ExceptionInfo Call to #'spec-example.core/ranged-rand did not conform to spec: ;;=> At: [:fn] val: {:args {:start 8, :end 10}, :ret 7}

Reagent template routing

2016-06-15 Thread Joakim Mohn
The reagent template uses compojure server sider routing and secretary/accountant on the client (cljs). https://github.com/reagent-project/reagent-template/blob/master/resources/leiningen/new/reagent/src/clj/reagent/handler.clj As you can see on line 38 the the server routes correspond to the cl

ANN Ogre 3.0.0.0-beta1 and future plans for Ogre

2016-06-15 Thread Michael Klishin
Ogre [1] is a Clojure dialect of Gremlin, a DSL for querying and otherwise working with Apache TinkerPop [2] graphs. Over the last 6 months or so Ogre maintainers have moved it to target TinkerPop 3.x. Since TinkerPop itself has changed quite a bit and is now an Apache incubator project, Ogre API

ANN metrics-clojure 2.7.0 is released

2016-06-15 Thread Michael Klishin
metrics-clojure [1] is a Clojure interface to the Metrics library [2], originally by Steve Losh [3]. Release notes: http://blog.clojurewerkz.org/blog/2016/06/02/metrics-clojure-2-dot-7-0-is-released/ If you're new to metrics and not sure why collecting them is a good idea, take a moment to watch

Re: [ANN] Clojure 1.9.0-alpha6

2016-06-15 Thread adrian . medina
I was wondering if you could shed some light on why instrument was changed to not automatically check the :ret and :fn specs. I miss that feature already, hehe, although I understand that these are alpha versions and things evolve. :) I just want to understand the context behind this decision.

Re: [ANN] Clojure 1.9.0-alpha6

2016-06-15 Thread Alex Miller
Check out the thread at https://groups.google.com/forum/m/#!topic/clojure/RLQBFJ0vGG4 > On Jun 15, 2016, at 5:22 PM, adrian.med...@mail.yu.edu wrote: > > I was wondering if you could shed some light on why instrument was changed to > not automatically check the :ret and :fn specs. I miss that f

Re: [ANN] Clojure 1.9.0-alpha6

2016-06-15 Thread Sean Corfield
Hopefully you can also provide an answer around my question (in that thread) about losing the “nice” exceptions and instead getting “just” a data structure from things like check-var? Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "If you're not annoying somebody

Re: [ANN] Clojure 1.9.0-alpha6

2016-06-15 Thread adrian . medina
Thanks for the link Alex. I understand what changed, but I still don't understand why. Could you elaborate on the thought that went into this? Thank you. On Wednesday, June 15, 2016 at 7:37:52 PM UTC-4, Alex Miller wrote: > > Check out the thread at > https://groups.google.com/forum/m/#!topic/

Added truss to validation-benchmark

2016-06-15 Thread Atamert Ölçgen
Hi, Peter Taoussanis was kind enough to contribute truss implementation to validation-benchmark. I have run it (with a few upgrades