Re: clojure.spec

2016-05-23 Thread Alex Miller
Yes, you can create recursive definitions by registering a spec that refers to itself via registered name (a namespaced keyword). On Monday, May 23, 2016 at 11:13:24 AM UTC-5, Andrey Grin wrote: > > Is it planned to support recursive definitions? Example from.plumatic > schema: > > > (def

clojure.spec

2016-05-23 Thread Rich Hickey
Introducing clojure.spec I'm happy to introduce today clojure.spec, a new core library and support for data and function specifications in Clojure. Better communication Clojure is a dynamic language, and thus far we have relied on documentation or external libraries to explain the use and

Re: clojure.spec

2016-05-23 Thread adrian . medina
This looks incredible and it sounds like something which could immediately be put to good use in both hobby and production projects. Excited to test it out when the alpha is available. Thank you! On Monday, May 23, 2016 at 10:12:29 AM UTC-4, Rich Hickey wrote: > > Introducing clojure.spec > >

Re: clojure.spec

2016-05-23 Thread Andrey Grin
Is it planned to support recursive definitions? Example from.plumatic schema: (def BinaryTree (maybe ;; any empty binary tree is represented by nil {:value long :left (recursive #'BinaryTree) :right (recursive #'BinaryTree)})) -- You received this message because you are

Re: clojure.spec

2016-05-23 Thread Alan Thompson
Looks great - eagerly awaiting a chance to use it. Alan On Mon, May 23, 2016 at 7:48 AM, wrote: > This looks incredible and it sounds like something which could immediately > be put to good use in both hobby and production projects. Excited to test > it out when the

[ANN] Lambda Island, weekly ClojureScript/Clojure screencast

2016-05-23 Thread Arne Brasseur
Hi Everyone, Last week I launched Lambda Island [1], a subscription based screencast series about web development with Clojure and ClojureScript. So far there are four episodes on-line, including one freebie. All episodes come with a full transcript and code samples. I will cover both

Re: clojure.spec

2016-05-23 Thread Sean Corfield
Awesome! I know one company that’s going to jump straight on 1.9.0-alpha1! ☺ Heck, we may even start today with 1.9.0-master-SNAPSHOT since clojure.spec was committed a couple of hours ago ☺ Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "If you're not annoying

Re: clojure.spec

2016-05-23 Thread Nicola Mometto
Some minor feedback while reading through `clojure.spec`: `clojure.spec/->sym` has been implemented in a significant number of libraries already (see: https://crossclj.info/clojure/var->sym.html), I propose we include this in `clojure.core` under the name of `var->sym` > On 23 May 2016, at

Re: clojure.spec

2016-05-23 Thread Ivan Reese
Is there anywhere we can read anything about the design process behind clojure.spec? I took a look at dev.clojure.org / JIRA, but I haven't yet found anything on the topic. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send

Re: clojure.spec

2016-05-23 Thread Alex Miller
clojure.spec has been developed internally for the last couple months. It combines a lot of different threads of thought. What are looking for? There will be some more usage docs coming soon. On Monday, May 23, 2016 at 3:11:30 PM UTC-5, Ivan Reese wrote: > > Is there anywhere we can read

Re: clojure.spec

2016-05-23 Thread scott stackelhouse
Could someone describe what a spec of a seq in a seq would look like? i.e. ['("a" "b" "c") '("d" "e" "f")]. I'm not quite "getting it." --Scott On Monday, May 23, 2016 at 7:12:29 AM UTC-7, Rich Hickey wrote: > > Introducing clojure.spec > > I'm happy to introduce today clojure.spec, a new

Re: clojure.spec

2016-05-23 Thread Andrey Grin
Thanks, Alex. I've taken random example from plumatic.schema wiki to quickly illustrate the question. In my actual use case I dynamically generate schemas based on hundreds of model Java classes (beans) with mutual references so I need recursion (and also some way to model inheritance, that

Re: clojure.spec

2016-05-23 Thread scott stackelhouse
Awesome, thanks! I had misunderstood where the idea of a sequence was created (the sequential context as you put it). On Monday, May 23, 2016 at 12:28:32 PM UTC-7, Alex Miller wrote: > > Yeah, nested regexes are one of the places people are most likely to be > tripped up. > > One of those

Re: clojure.spec

2016-05-23 Thread Alex Miller
I think you could apply the same idea - use a regular translation between Java class and registered name and then always refer to the registered name. There are probably multiple approaches to modeling inheritance, so hard to recommend something without knowing more. In general, attributes

Re: clojure.spec

2016-05-23 Thread Alex Miller
That schema looks weird to me as it seems to under-constrain leaf vs branch so this is not really equivalent but makes sense to me: (spec/def ::tree (spec/or :leaf ::leaf :branch ::branch)) (spec/def ::leaf integer?) (spec/def ::branch (spec/cat :left ::tree :right ::tree)) (spec/conform ::tree

[ANN] Neanderthal 0.6.0: new support for AMD, Nvidia, and Intel GPUs on Linux, Windows and OS X (fast matrix library)

2016-05-23 Thread Dragan Djuric
This is a major release of Neanderthal, a fast native & GPU matrix library: In this release, spotlight is on the new GPU engine, that: * Works on all three major hardware platforms: AMD, Nvidia, and Intel * Works on all three major operating systems: Linux, Windows, and OS X * Is even faster, so

Re: clojure.spec

2016-05-23 Thread Alex Miller
Yeah, nested regexes are one of the places people are most likely to be tripped up. One of those inner lists could be speced as: (def string-list (s/* string?)) ;; or as (s/coll-of string?) - not a strong preference in this particular case but there are tradeoffs And then the outer list is

Re: new learner question

2016-05-23 Thread JvJ
> > > > Nope, that's fine. (Although you can't nest one anonymous function inside > another as then it would be ambiguous what % refers to.) > To further clarify when anonymous functions can't be nested: #(+ % (+ % (+ % (+ % ==> totally legal #(+ % (#(* 2 %) %)) ===> totally not legal

Re: clojure.spec

2016-05-23 Thread Alex Miller
Hi Leif, thanks for the feedback! The use for regex ops is primarily expected to be syntax where greedy is typically a fine default (and where the sequence length is typically not long with exact quantification). You can use the & operator though to add arbitrary predicates around another

Re: clojure.spec

2016-05-23 Thread Leif
Feedback: The regex quantifiers seem to be greedy. I suppose that is the standard choice, but it would be nice if the docs explicitly said that. Maybe have a 'rep' macro for exact quantification? My use cases for this are short sequences that would be handled just fine by 'cat', so I don't

Re: clojure.spec

2016-05-23 Thread Andrey Grin
Thank you. Yes, it seems that for recursion I can use the same approach. As for inheritance currently I just include all parent attributes in every child schema. As for spec definition multi-spec, as I understand it, requires "defmethod" for every class which is probably a problem for my case

Re: clojure.spec

2016-05-23 Thread Rich Hickey
I did most of the design of spec in a (paper) notebook. The rationale tries to capture the salient driving forces. If there is a specific question you have I’d be happy to answer. Rich > On May 23, 2016, at 4:11 PM, Ivan Reese wrote: > > Is there anywhere we can read

Re: clojure.spec

2016-05-23 Thread Shaun Parker
Thanks to everyone who worked on it! I'm excited there's finally an idiomatic way and can't wait to use it. Is there any chance the three clojure.spec namespaces will be released as a library that could be use until 1.9.0 is released? It seems like we'd only be missing compile time macro

Re: clojure.spec

2016-05-23 Thread Ambrose Bonnaire-Sergeant
I'm observing mutually recursive regex ops taking a long time to generate test.check generators. Is this expected? (s/def ::a (s/nilable (s/cat :a ::a :b ::b :c ::c))) (s/def ::b (s/nilable (s/cat :a ::a :b ::b

Re: clojure.spec

2016-05-23 Thread Rich Hickey
Currently gens are not lazy, so entire tree is generated. This is because a) test.check isn’t lazy either and b) we want errors when asking for gen, not using it. But it is rough for recursive specs as you see. For now you can limit the recursion depth to control the branching: (binding

clojure.spec

2016-05-23 Thread Alan Moore
Your timing couldn't have been better... we have been needing something like this. Thought of building something similar which would only have been an ad hoc, informally specified, bug ridden, slow implementation of half of clojure.spec. Thank you for spending you hammock time on this

new learner question

2016-05-23 Thread Phil Virgo
I just starting to try and teach myself Clojure. Kindly let me know if there is a more appropriate place I should post simple questions. (def s '(1 1 1 4 99) (take-while #(= (first s) %) s) ; works fine: (1 1 1) (take-while #(= (first %) %) s) ; IllegalArgumentException Don't know how

Re: new learner question

2016-05-23 Thread Dan Girellini
On May 23, 2016 at 6:10:46 PM, Phil Virgo (pwvi...@gmail.com) wrote: (take-while #(= (first %) %) s) ; IllegalArgumentException Don't know how to create ISeq from: java.lang.Long clojure.lang.RT.seqFrom (RT.java:505) Your problem is that take-while will call the predicate for each item in

Re: clojure.spec

2016-05-23 Thread Sean Corfield
On 5/23/16, 3:45 PM, "Rich Hickey" wrote: >That one’s already fixed if you grab the latest. Confirmed! Thank you! Sean -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: new learner question

2016-05-23 Thread Alex Miller
On Monday, May 23, 2016 at 8:10:47 PM UTC-5, Phil Virgo wrote: > > I just starting to try and teach myself Clojure. Kindly let me know if > there is a more appropriate place I should post simple questions. > This is fine! You might also enjoy the #beginners room on the http://clojurians.net/

Re: new learner question

2016-05-23 Thread JvJ
Your use of % is syntactically correct. However, think of what is happening in the second example. Every time take-while invokes your function #(= (first %) %), % is bound to an element of the list s. So, something like this would happen when take-while is checking the first element: (=

Re: new learner question

2016-05-23 Thread Phil Virgo
Don't want to thank each of you individually - so to all who answered - Thank-you! On Monday, May 23, 2016 at 9:10:47 PM UTC-4, Phil Virgo wrote: > > I just starting to try and teach myself Clojure. Kindly let me know if > there is a more appropriate place I should post simple questions. > >

Re: clojure.spec

2016-05-23 Thread Rich Hickey
That one’s already fixed if you grab the latest. > On May 23, 2016, at 6:37 PM, Sean Corfield wrote: > > On 5/23/16, 2:29 PM, "Rich Hickey" richhic...@gmail.com> wrote: >> fdef will not add doc metadata (see rationale re: not putting

[ANN] trapperkeeper 1.4.1

2016-05-23 Thread Joe Pinsonault
Today we released puppetlabs/trapperkeeper v1.4.1 to clojars. There is a single bugfix in this release: TK-375 . TK-375 resolves startup issues for users that use a bootstrap.cfg inside their project's jar file. For more info see the CHANGELOG

Re: clojure.spec

2016-05-23 Thread Ambrose Bonnaire-Sergeant
I'm having trouble calling `s/gen`, might be some sort of AOT compilation error. (I'm guessing this line has something to do with it). I'm using the latest

Re: clojure.spec

2016-05-23 Thread Sean Corfield
On 5/23/16, 2:29 PM, "Rich Hickey" wrote: >fdef will not add doc metadata (see rationale re: not putting more stuff in >the namespaces/vars), but specs will be present when you call ‘doc’. That doc >enhancement was in a push later in

Re: clojure.spec

2016-05-23 Thread Nicola Mometto
Looks like it is, in the meanwhile this patch should fix it: http://sprunge.us/XTiA > On 23 May 2016, at 23:03, Nicola Mometto wrote: > > Possibly CLJ-1544 related? > >> On 23 May 2016, at 22:59, Ambrose Bonnaire-Sergeant >> wrote: >> >>

Re: clojure.spec

2016-05-23 Thread Rich Hickey
fdef will not add doc metadata (see rationale re: not putting more stuff in the namespaces/vars), but specs will be present when you call ‘doc’. That doc enhancement was in a push later in the afternoon. https://github.com/clojure/clojure/commit/4c8efbc42efa22ec1d08a1e9fa5dd25db99766a9 > On

Re: clojure.spec

2016-05-23 Thread Ambrose Bonnaire-Sergeant
I see, thanks. On Mon, May 23, 2016 at 5:29 PM, Rich Hickey wrote: > fdef will not add doc metadata (see rationale re: not putting more stuff > in the namespaces/vars), but specs will be present when you call ‘doc’. > That doc enhancement was in a push later in the

Re: clojure.spec

2016-05-23 Thread Ambrose Bonnaire-Sergeant
Thanks Rich+team, this is awesome. Instrumented vars via `fdef` do not seem to add :doc metadata yet (which is advertised in the docstring for `fdef`). Am I missing something? Thanks, Ambrose On Mon, May 23, 2016 at 5:20 PM, Andrey Grin wrote: > Thank you. Yes, it

Re: clojure.spec

2016-05-23 Thread Alex Miller
You can dynamically install defmethods at runtime too so you could catch this problem when it falls into the default, generate the schema, register it, then re-invoke. Theoretically. On Monday, May 23, 2016 at 4:20:38 PM UTC-5, Andrey Grin wrote: > > Thank you. Yes, it seems that for recursion

Re: clojure.spec

2016-05-23 Thread Nicola Mometto
Possibly CLJ-1544 related? > On 23 May 2016, at 22:59, Ambrose Bonnaire-Sergeant > wrote: > > I'm having trouble calling `s/gen`, might be some sort of AOT compilation > error. > (I'm guessing this line has something to do with it). > > I'm using the latest

Re: clojure.spec

2016-05-23 Thread George Singer
Rich Hickey gmail.com> writes: > > I did most of the design of spec in a (paper) notebook. > > The rationale tries to capture the salient driving forces. > > If there is a specific question you have I’d be happy to answer. > > Rich > > > On May 23, 2016, at 4:11 PM, Ivan Reese gmail.com>

Re: [ANN] New Clojure Podcast: defn

2016-05-23 Thread Terje Dahl
Loved it. Very good start. Looking forwards to your discussion on Reader. On Thursday, May 19, 2016 at 7:43:44 AM UTC+2, Vijay Kiran wrote: > > Hello Everyone, > > Just wanted to let you know that we started a new podcast about Clojure: > https://defn.audio > > We published our first episode

can clojure have es7 async await

2016-05-23 Thread Xiangtao Zhou
hi Everyone, es7 async/await makes javascript easily understandable, and avoid the callback hell. can clojure have one library like this? scala version is here https://github.com/scala/async. Thanks. Joe. -- You received this message because you are subscribed to the Google Groups

Re: can clojure have es7 async await

2016-05-23 Thread Andrey Antukh
I'm not pretty sure if this answers your question, but I have similar async/await syntax already implemented in promesa library: http://funcool.github.io/promesa/latest/#async-await-syntax Regards. Andrey On Mon, May 23, 2016 at 4:07 PM, Xiangtao Zhou wrote: > hi Everyone, >

Re: Following type annotations across call sites to eliminate reflection?

2016-05-23 Thread Phillip Lord
I macro'd this out (macro's with type-hints are surprisingly tricky). So, you end with this (with-types [val [String Double Boolean]] (C/met val) Which calls C/met with the right thing without reflection (unless you count "instance?"). The code is in tawny-owl.

Re: can clojure have es7 async await

2016-05-23 Thread Xiangtao Zhou
hi Andrey, I think, javascript basically designed with event mechnism, especially IO api. The async/await api is cps transform with promise. async makes the function return promise, await make cps transform. in clojure, these may associate with core.async, I mean use channel replace

RE: clojure.spec

2016-05-23 Thread sean
I was a bit puzzled by the :req-un / :opt-un stuff in maps. Am I right that there is a requirement here for the keys to be namespaced but the actual namespace is completely irrelevant / ignored? (defn thing [m] (+ (:a m) (:b m) (or (:c m) 1))) (s/fdef thing :args (s/cat :map (s/and

Re: clojure.spec

2016-05-23 Thread Alex Miller
On Tuesday, May 24, 2016 at 12:16:32 AM UTC-5, Sean Corfield wrote: > > I was a bit puzzled by the :req-un / :opt-un stuff in maps. Am I right > that there is a requirement here for the keys to be namespaced but the > actual namespace is completely irrelevant / ignored? > No - the :req-un /