[ANN] Clojure 1.9.0-alpha11

2016-08-19 Thread Alex Miller
Clojure 1.9.0-alpha11 is now available. Try it via - Download: https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha11 - Leiningen: [org.clojure/clojure "1.9.0-alpha11"] 1.9.0-alpha11 includes the following changes since 1.9.0-alpha10: Clojure now has specs for the following clojure.co

Re: [ANN] Clojure 1.9.0-alpha11

2016-08-19 Thread Alex Miller
was used instead of the symbol. On Friday, August 19, 2016 at 1:15:06 PM UTC-5, Alex Miller wrote: > > Clojure 1.9.0-alpha11 is now available. > > Try it via > > - Download: > https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha11 > - Leiningen: [org.clojur

Re: Multiple key-value pairs in assoc-in (old issue)

2016-08-19 Thread Alex Miller
I'm not convinced this is even a good idea (but Rich is the ultimate judge). None of the -in fns repeat paths like that so this makes assoc and assoc-in similar but makes assoc-in / update-in etc inconsistent. On Friday, August 19, 2016 at 1:50:41 PM UTC-5, Łukasz Kożuchowski wrote: > > On 08/

Re: [ANN] Clojure 1.9.0-alpha11

2016-08-19 Thread Alex Miller
string] [fs.core :as fs]) (import java.io.File java.net.URLDecoder)) > > > at clojure.spec$macroexpand_check.invokeStatic(spec.clj:627) > > at clojure.spec$macroexpand_check.invoke(spec.clj:616) > > at clojure.lang.AFn.applyToHelper(AFn.java:156) > > at clojure.lang.AFn.apply

Re: [ANN] Clojure 1.9.0-alpha11

2016-08-19 Thread Alex Miller
I've not done my deep-dive homework on that form (yet) and how it > works... I know those two libraries do a bit of namespace manipulation to > deal with reloading repls and whatnot so it very well could be something > they are doing that is beyond my current understanding and pay

Re: [ANN] Clojure 1.9.0-alpha11

2016-08-19 Thread Alex Miller
eviously compiled library, like system, pulled from >> clojars uses "(require" be subject to the spec conformance? How much of the >> ns-form is resolved at compile time and how much happens at runtime? >> >> Clearly I've not done my deep-dive homework on

Re: [ANN] Clojure 1.9.0-alpha11

2016-08-20 Thread Alex Miller
On Saturday, August 20, 2016 at 2:32:29 AM UTC-5, Colin Fleming wrote: > > (ns ... (require ...) (import ...) ) instead of (ns ... (:require ...) >> (:import ...) ) > > > Is this not intended to be allowed? The docstring implies no but it has > always worked fine - I wouldn't call the code brok

Re: [ANN] Clojure 1.9.0-alpha11

2016-08-20 Thread Alex Miller
alias is not included and I have yet to find code using it in the wild. That said, it exists in the gray area as well. If it becomes an issue and/or Rich thinks it should be added, that could be done. I suspect that if we have any changes related to aliasing non-existing namespaces (for qualifi

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-20 Thread Alex Miller
On Saturday, August 20, 2016 at 5:17:59 AM UTC-5, Brian Marick wrote: > > Yesterday, a bug was filed against Suchwow under 1.9alpha11. It turns out > to have been a use of `ns …(require…` instead of `(ns …(:require`. Not in > Suchwow, but in Midje. Unfortunately, the Suchwow file the bug report

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-20 Thread Alex Miller
On Saturday, August 20, 2016 at 9:40:21 AM UTC-5, Brian Marick wrote: > > > On Aug 20, 2016, at 9:03 AM, Alex Miller wrote: > > You left out this next important line too since it points you to exactly > the file and line where the error occurs: > > , compiling

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-20 Thread Alex Miller
On Saturday, August 20, 2016 at 9:58:14 AM UTC-5, Brian Marick wrote: > > > On Aug 20, 2016, at 9:03 AM, Alex Miller wrote: > > We discussed this before releasing the specs and decided to start on the > strict side. That said, this is still an alpha and there is plenty of tim

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-21 Thread Alex Miller
The documentation now includes the spec, which would explicilly mention the symbol, so this would not be tacitly hidden as you suggest. David is already working on porting these specs to ClojureScript so that issue is one we will imminently face. So again I will state: while the current spec do

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-21 Thread Alex Miller
On Sunday, August 21, 2016 at 5:25:03 PM UTC-5, Brian Marick wrote: > > As an update. I’ve fixed the `ns` oopsie in Suchwow (one file), and the > coincident `ns` oopsie in Midje (one file). But this happens when running > Midje’s self-tests against Clojure 1.9alpha11: > > > Exception in thread

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-21 Thread Alex Miller
On Sunday, August 21, 2016 at 5:28:57 PM UTC-5, lvh ‌ wrote: > > FYI, while I disagree with your conclusion (I think we should go fix > libraries instead), I ran into the same issue just now for roughly the same > reason, except the thing that pulled in an old version of core.unify was > core.ty

Re: Add :examples option to s/fdef for documentation and testing?

2016-08-21 Thread Alex Miller
Hi Peter, thanks for the idea, but I don't expect that we'll add this. On Sunday, August 21, 2016 at 8:26:24 AM UTC-5, Peter Marklund wrote: > > Did you consider having examples (input-output mappings) be part of the > spec for a function, i.e. add an :examples option to the fdef macro in > addi

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-22 Thread Alex Miller
I've added library related fixes related to core specs to an info page at: http://dev.clojure.org/display/design/Errors+found+with+core+specs On Sunday, August 21, 2016 at 8:24:20 PM UTC-5, Alex Miller wrote: > > On Sunday, August 21, 2016 at 5:28:57 PM UTC-5, lvh ‌ wrote: >>

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-22 Thread Alex Miller
I've already mentioned most of this above, but I'll try again. In short, I'd say yes (that's why we are still in alphas), but in adherence with the general goals we have of capturing and returning comprehensive data about the error and building those error messages generically. - Getting the er

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-22 Thread Alex Miller
On Monday, August 22, 2016 at 6:45:16 PM UTC-5, Oliver George wrote: > > > I'm interested to see any discussion regarding this point. No doubt > translating spec data into more friendly formats has been discussed. > > Getting the data right is clojure's problem. That's the concrete > foundati

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-22 Thread Alex Miller
On Monday, August 22, 2016 at 7:43:53 PM UTC-5, Colin Fleming wrote: > > I agree that the ability to get a machine-readable parse failure is very > important for tooling. However I feel very strongly that the error messages > that are printed by default on macro validation failures should be eas

Re: [ANN] data.avl 0.0.14 – BUGFIX to splits, faster map/set reductions

2016-08-22 Thread Alex Miller
Nice work! Esp on the reduce stuff - great to see that. Any reason you didn't go the IReduce path in Clojure too instead of CollReduce? Generally, I'd say that's preferred when you control the data structure. On Monday, August 22, 2016 at 7:43:51 PM UTC-5, Michał Marczyk wrote: > > Hi, > > I am

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-22 Thread Alex Miller
tilize after a month > or so in Clojure. > > It seems that improving the error messages we can calculate from specs > data is something that more people should think about and improve for 1.9. > I'd be willing to invest time if needed / input is welcome. Alternatively a > way to i

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-23 Thread Alex Miller
t; places in the user's code. > > It isn't always available, e.g. keyword cannot have metadata, but symbols, > lists, vectors, and maps can. > > Andy > > > On Mon, Aug 22, 2016 at 6:27 PM, Alex Miller wrote: > >> Sorry, I missed this one in the thread some

Re: [ANN] data.avl 0.0.14 – BUGFIX to splits, faster map/set reductions

2016-08-23 Thread Alex Miller
IReduce is a Java interface that can be used to allow a data structure to directly indicate participation in being self-reducible. In cases where you control the type (ie you are making the data structure), implementing IReduce (or really IReduceInit) is usually better as it is checked first. C

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-23 Thread Alex Miller
of Clojure need from error messages for her CS education classes and the answer there is just different from what an experienced user needs. That's ok. We care more about the latter. On Tuesday, August 23, 2016 at 8:49:38 AM UTC-5, Brian Marick wrote: > > > On Aug 22, 2016, at 7:

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-23 Thread Alex Miller
:problems] :opt [::args])) On Tuesday, August 23, 2016 at 2:33:34 PM UTC-5, puzzler wrote: > > On Tue, Aug 23, 2016 at 7:45 AM, Alex Miller wrote: > >> We expect Clojure users to become familiar with spec and its output as it >> is (now) an essential part of the language. You

Re: Job Opportunity | Application Developer (General)-Expert| St Louis, MO 6 months

2016-08-24 Thread Alex Miller
Hi Revanth, You might want to join and post on the St. Louis Clojure meetup discussion group too to reach a more targeted audience. http://www.meetup.com/stl-clojure/ Alex On Wednesday, August 24, 2016 at 8:21:00 AM UTC-5, Revanth Kumar wrote: > > *Application Developer* > > > > Location: St

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-25 Thread Alex Miller
Brian, your concerns have been heard. Please keep in mind this is a work in progress and that there is ongoing work that is not yet visible. While I don't expect that the final endpoint of this work will be exactly what you would design (or what you might see in other languages as our goals and

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-25 Thread Alex Miller
On Thursday, August 25, 2016 at 10:46:14 AM UTC-5, adrian.med...@mail.yu.edu wrote: > > I really don't understand how you expect anyone to take your criticism > seriously if you keep implying you're happily abandoning the language for > greener pastures. > > Why would anyone developing Clojure

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-25 Thread Alex Miller
On Thursday, August 25, 2016 at 8:00:37 PM UTC-5, Rick Moynihan wrote: > > I think one obvious area that specs error messages could be improved is > with some basic formatting and cosmetic changes. If spec presented errors > not as a wall of text and syntax but with some simple formatting it wo

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-26 Thread Alex Miller
On Thursday, August 25, 2016 at 9:11:39 PM UTC-5, Colin Fleming wrote: > > > One thing that I think would help a lot would be if it were possible to > show the actual text from the failing expression rather than pretty > printing a seq representation of it. This would mean modifying the reader >

Should the specs defined in clojure.core.specs be used by in other projects?

2016-08-28 Thread Alex Miller
Yes, you can and should leverage the clojure.core.specs. They may change indiscriminately during alphas but we will start to lock those down more when we move towards final release. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gro

Re: Spec of conform of spec

2016-08-31 Thread Alex Miller
I don't understand the question. What are you trying to do? On Wednesday, August 31, 2016 at 4:08:00 PM UTC-5, l0st3d wrote: > > So how would you conform something to nil or false? For example: > > (s/conform (s/conformer read-string) "nil") > > ? > > -- You received this message because you are

Re: Spec of conform of spec

2016-08-31 Thread Alex Miller
mer. Optionally takes a second fn that does unform of result of first Conformers are expected return either a value or ::s/invalid if invalid. On Wednesday, August 31, 2016 at 6:29:23 PM UTC-5, Alex Miller wrote: > > I don't understand the question. What are you trying to do? &g

Re: Spec of conform of spec

2016-09-01 Thread Alex Miller
I think you may be confusing the return value of a predicate value (acting as a spec) with the return value of the function passed to conformer. In the former case a predicate function's return value is a logically truthy value and a return of nil or false indicates the value is invalid. The fu

[ANN] Clojure 1.9.0-alpha12

2016-09-07 Thread Alex Miller
Clojure 1.9.0-alpha12 is now available. Try it via - Download: https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha12 - Leiningen: [org.clojure/clojure "1.9.0-alpha12"] 1.9.0-alpha12 includes the following changes since 1.9.0-alpha11: - spec performance has been improved for many use

Re: [ANN] Clojure 1.9.0-alpha12

2016-09-08 Thread Alex Miller
I've commented on this in multiple other places but for the sake of completeness... Datascript is extending some defrecords to the IHashEq protocol to add custom hash caching. In particular, this extension is adding custom fields __hash and __hasheq, which happen to be the (obvious) names of th

map/filter/remove etc. change underlying structure

2016-09-09 Thread Alex Miller
Here's some background that might help give this some context: http://clojure.org/guides/faq#seqs_vs_colls http://insideclojure.org/2015/01/02/sequences/ http://insideclojure.org/2016/03/16/collections/ Alex -- You received this message because you are subscribed to the Google Groups "Clojure"

[ANN] Clojure 1.9.0-alpha12

2016-09-09 Thread Alex Miller
Regarding performance, the validation benchmark project has been updated with alpha12: http://muhuk.github.io/validation-benchmark -- 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 tha

Re: Clojure spec for domain model

2016-09-09 Thread Alex Miller
You seem to be working pretty hard here. Why don't you just do: (s/def :User/id string?) (s/def :Credit/id number?) The keyword qualifier does not have to map to a loaded namespace. (It does if you want to use namespace aliases, but that doesn't seem necessary here.) On Friday, September 9, 20

Re: map/filter/remove etc. change underlying structure

2016-09-09 Thread Alex Miller
On Friday, September 9, 2016 at 11:36:22 AM UTC-5, Alan Thompson wrote: > > Hi Colin, > > I too have been bitten by this type of inconsistency in clojure.core > functions. > I disagree that the problem here is consistency. The core functions are very consistent, but I think it's easy to build

Re: [ANN] Clojure 1.9.0-alpha12

2016-09-09 Thread Alex Miller
492cf2d3d19471 > > Rangel > >> On Wednesday, September 7, 2016 at 2:15:25 PM UTC-7, Alex Miller wrote: >> Clojure 1.9.0-alpha12 is now available. >> >> Try it via >> >> - Download: https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha12 >

Re: [ANN] Clojure 1.9.0-alpha12

2016-09-09 Thread Alex Miller
September 9, 2016 at 6:22:15 PM UTC-7, Alex Miller wrote: >> >> The keys of an :or destructuring map should be symbols, not keywords. >> >> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

alpha11 clojure.spec validation for fdef

2016-09-13 Thread Alex Miller
instrument only checks the :args spec of the function. The higher order function is in the :ret spec so isn't checked. You can use the check function to generate tests that verify the :ret and :fn specs. -- You received this message because you are subscribed to the Google Groups "Clojure" gro

Re: clojure.spec - Using :pre conditions (or not)?

2016-09-14 Thread Alex Miller
Another option that has been added since the guide was written is s/assert which seems closer to what you're suggesting. (defn name [user] {:pre [(s/assert :common/user user)]} (-> user :user/name)) ;; need to enable assertion checking - this can also be enabled globally with system propert

Re: Make core.spec value printing more customisable.

2016-09-14 Thread Alex Miller
I've looked at this a bit too. As you mention you can use *print-length* and *print-level* to affect this and that does work. I looked into setting these inside spec to some fixed value but that would take away control from the user. I didn't look at creating new dyn vars specifically for this,

Re: In clojure.spec, how to declare all valid keys in a map

2016-09-20 Thread Alex Miller
For stuff like this s/merge is probably preferable to s/and (when combining map specs) - the difference being that merge does not flow conformed results, will combine all failures, and that gen can work better in some cases. (s/def ::a int?) (s/def ::b string?) ;; changed for this example (s/e

Re: Is there a way to alpha 11 or higher, but disable a single spec?

2016-09-23 Thread Alex Miller
I believe that was a bug in ClojureScript itself which is fixed in releases for about the last month. -- 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 m

Re: clojure.spec question

2016-09-24 Thread Alex Miller
#{{"id" 1 "name" "john"}} is a valid spec for that On Saturday, September 24, 2016 at 9:46:55 AM UTC-5, Philos Kim wrote: > > How can I define the following spec? > > {"id" 1 "name" "john"} > > 1) The keys of a map must be the string type, not the keyword type. > > 2) The values must be fixed. Nam

Re: parallel sequence side-effect processor

2016-09-24 Thread Alex Miller
Just a general note of caution. range is a highly specialized (and optimized) impl for both reducing and seq traversal. Also note that seqs on vecs are about the next-most optimized seq (because they also don't allocate or cache - rather they just pull from the vector nodes as the backing store

Re: parallel sequence side-effect processor

2016-09-24 Thread Alex Miller
sequence taps into the underlying TransfomerIterator which applies a transducer while iterating across multiple iterators at the same time. sequence wraps that into a chunked sequence, but you could tap directly into TransformerIterator/createMulti without using the outer sequence. Nothing in

Re: Don't Call Yourself A Programmer, And Other Career Advice

2016-09-26 Thread Alex Miller
here instead as a periodic reminder of this (sorry, not trying to pick on you Alan!). There are many alternative places to post something like this for discussion. Thanks, Alex Miller alex.mil...@cognitect.com On Monday, September 26, 2016 at 11:51:41 AM UTC-5, Alan Thompson wrote: > >

[ANN] Clojure 1.9.0-alpha13

2016-09-26 Thread Alex Miller
Clojure 1.9.0-alpha13 is now available. Try it via - Download: https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha13 - Leiningen: [org.clojure/clojure "1.9.0-alpha13"] 1.9.0-alpha13 includes the following changes since 1.9.0-alpha12: - s/conform of nilable was always returning the pa

Re: Idiom question

2016-09-28 Thread Alex Miller
Hi Paul, there is a rich history of people extending the thread macros. For things in core, check out some of the other threading operators: as->, cond->, some-> etc as they handle more of your cases below. This is a good overview of what they do: http://clojure.org/guides/threading_macros Add

Re: [ANN] Clojure 1.9.0-alpha13

2016-09-29 Thread Alex Miller
I think the problem is not on the :or but on the :keys which is being passed a set rather than a sequential? -- 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 member

clojure.spec to match string

2016-09-29 Thread Alex Miller
You can make a predicate using re-matches - there is an email example in http://clojure.org/guides/spec -- 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

Re: Recursive clojure.spec doesn't work

2016-10-06 Thread Alex Miller
Can you share a specific case? -- 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

Re: clojure.spec, conform and returned value

2016-10-11 Thread Alex Miller
On Tuesday, October 11, 2016 at 1:30:18 PM UTC-5, plamen.use...@gmail.com wrote: > > Hello, > > I have a problem which is probably not in the spirit of clojure.spec as > being a library for "only" checking/generating valid values, but of > substantial practical value for my use case: > > Let s

Re: Diffing clojure data structures faster

2016-10-13 Thread Alex Miller
On Thursday, October 13, 2016 at 12:23:21 PM UTC-5, Dan wrote: > > Hi > > I would like to be able to take advantage of the tree structures > underneath e.g. hash-maps for a faster diff. > > I wrote a gist to do this in clojurescript > https://gist.github.com/danjohansson/add5515b2067b3036044d45

Re: core.async top use cases

2016-10-13 Thread Alex Miller
The other other special feature of agents is that the stm knows about them so it's a safe way to have a side effect occur in an stm transaction (all agent sends are delayed till the txn succeeds). I've found that to be pretty handy in advanced usage. -- You received this message because you ar

Re: Help with using spec

2016-10-17 Thread Alex Miller
I would back way up to the beginning and reconsider your ::board spec. Generally for any data where the structures are homogenous, you're probably better off using one of the collection specs like coll-of (or map-of, every, every-kv) rather than a regex, which should primarily be used when you

Re: Guidelines/Recommendations for namespaces and qualified keywords

2016-10-18 Thread Alex Miller
On Saturday, October 15, 2016 at 10:17:15 PM UTC-5, Josh Tilles wrote: > > I’ve got a couple questions for Alex Miller and/or the other Cognitect > folks. > >1. *Are single-segment namespaces still “bad” when it comes to >registering specs under qualified keywords?* &

Re: clojure.spec: Relationships Between Specs

2016-10-19 Thread Alex Miller
s/and will flow the conformed result to the next predicate so something like this should work: (s/def ::xrange (s/and (s/keys ::req [::x0 ::x1]) (fn [{:keys [::x0 ::x1]}] (< x0 x1 On Wednesday, October 19, 2016 at 12:27:04 PM UTC-5, Mark Bastian wrote: > > Is it possible to

Re: clojure.spec: Relationships Between Specs

2016-10-19 Thread Alex Miller
0 2, :x1 97} #:user{:x0 1, :x1 90}) On Wednesday, October 19, 2016 at 1:49:03 PM UTC-5, Alex Miller wrote: > > s/and will flow the conformed result to the next predicate so something > like this should work: > > (s/def ::xrange > (s/and (s/keys ::req [::x0 ::x1]) >

Re: protocols and namespaces confusion (with an example from core.matrix)

2016-10-19 Thread Alex Miller
On Wednesday, October 19, 2016 at 7:23:21 AM UTC-5, Paul Gowder wrote: > > Hi folks, > > I have a kinda basic question (I think?) that I should really know the > answer to after writing Clojure for like 8 months, but don't. It's about > requiring namespaces with protocol definitions in them b

Re: Java like static typing for Clojure?

2016-10-21 Thread Alex Miller
Just as a counter-anecdote, I have worked on large Clojure codebases (both ones I developed and ones I was unfamiliar with), including ones that interfaced with existing Java codebases, and have not experienced this problem to the degree you describe Colin. So while I believe these problems exi

Re: conditional support for spec in libraries

2016-10-23 Thread Alex Miller
We do not plan to add a :spec feature expression (also, feature expressions are not actually a thing - the final version of reader conditionals only supports platform tags). On Sunday, October 23, 2016 at 10:49:33 AM UTC-5, Cal Loomis wrote: > > The only discussion I’ve seen about providing cond

Re: need help on `pprint/write` code with better readability

2016-10-23 Thread Alex Miller
Try something like this: (require '[clojure.pprint :as pprint]) (defn print-code [o] (binding [pprint/*print-right-margin* 100 pprint/*print-miser-width* 60] (pprint/with-pprint-dispatch pprint/code-dispatch (pprint/pprint o Or one of the "pretty printer" libraries lik

Re: "Dynamic" and Spezialised Specs (clojure.spec)

2016-10-26 Thread Alex Miller
On Wednesday, October 26, 2016 at 2:59:19 PM UTC-5, Yannick Scherer wrote: > > Sometimes, there are relationships between different parts of data that > need to be included in the spec. > This can surely be done using "s/and" > s/and is precisely a way to add an additional constraint on an exi

Clojure/conj 2016 program

2016-10-28 Thread Alex Miller
loway - clojure.spec - Wed (4 hrs), $150 - taught by me (Alex Miller) - How to Run a ClojureBridge Workshop - Wed (3 hrs), free - taught by Nola Stowe Hope to see you there! Alex -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

[ANN] Clojure 1.9.0-alpha14

2016-10-28 Thread Alex Miller
Clojure 1.9.0-alpha14 is now available. Try it via - Download: https://repo1.maven.org/maven2/org/clojure/clojure/1.9.0-alpha14 - Leiningen: [org.clojure/clojure "1.9.0-alpha14"] 1.9.0-alpha14 includes the following changes since 1.9.0-alpha13: - NEW `into` now has a 0-arity (returns []) and 1-

Re: Can clojure.spec be used to identify/pinpoint broken invariants on dynamic data?

2016-10-31 Thread Alex Miller
imho, you're asking spec to do more than it should here - it's not a magic wand to wave at all validation problems. -- 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

Re: Can clojure.spec be used to identify/pinpoint broken invariants on dynamic data?

2016-10-31 Thread Alex Miller
On Monday, October 31, 2016 at 10:41:36 AM UTC-5, Yannick Scherer wrote: > > imho, you're asking spec to do more than it should here - it's not a magic >> wand to wave at all validation problems. >> > > That's good to know. Note that, in regard to the problem stated above, > clojure.spec does n

Re: Can clojure.spec be used to identify/pinpoint broken invariants on dynamic data?

2016-10-31 Thread Alex Miller
Getting a bit more concrete, I think this would be a better approach to the variable name spec: (defmacro make-name-spec [var-names] `(s/and :lang-name ~var-names)) which can be called in the process of verifying the ast to dynamically create a static spec, which can then be used for valid

Re: Deriving a protocol from a protocol...

2016-10-31 Thread Alex Miller
You can create instances that implement multiple Java interfaces using `reify` or by declaring them inline of a `defrecord` or a `deftype`. (See http://clojure.org/reference/datatypes for more.) Clojure does *not* encourage or support concrete inheritance (other than of the limited degree provi

Re: Deriving a protocol from a protocol...

2016-10-31 Thread Alex Miller
You can of course have one concrete instance implement many protocols. Another clever thing you can do is to extend a protocol to Object, then inside the Object extension check if the instance satisfies? another protocol and if so, extend its type at runtime to the original protocol. Rich sugge

Re: Spec & test.check generators for complex data structures

2016-11-01 Thread Alex Miller
The general approach to this is to first create a "model" of your domain, which might be some random seed info and then generate one or more entities that are consistent with the model. Stu does a simple example of this in http://blog.cognitect.com/blog/2016/8/10/clojure-spec-screencast-customi

Re: Parsing Java with Instaparse

2016-11-03 Thread Alex Miller
While writing a parser for Java with instaparse would probably be a fun exercise, there are certainly several available Java parsers you could just use immediately rather than writing one. One easily findable example: https://github.com/javaparser/javaparser On Thursday, November 3, 2016 at 8:

Re: clojure.spec - relationship between :args

2016-11-03 Thread Alex Miller
On Thursday, November 3, 2016 at 1:12:39 PM UTC-5, Jim foo.bar wrote: > > Hi everyone, > > I'm starting to get familiar with clojure.spec, and in my very first spec > I needed to specify relationship between the args themselves (similar to > how :fn specs allow for specifying some relationship

Re: When to halt-when?

2016-11-03 Thread Alex Miller
halt-when does require some knowledge about the transducible context where it is used, particularly because it will be exposed to the completed result of the computation. I think it's really primarily applicable for something like transduce (and not as much for into, sequence, eduction, or chan

Re: clojure.spec gen-testing VS NaN

2016-11-07 Thread Alex Miller
Please also take a look at s/double-in, which allows you to exclude NaN (and Infinity/-Infinity) as valid values. (I realize this does not address the any? question, but that seems like a rarer issue to me than cases where I'm explicitly spec'ing a double but don't want to allow NaN.) On Monda

Re: clojure.spec predicate generator question

2016-11-07 Thread Alex Miller
On Sunday, November 6, 2016 at 5:01:23 AM UTC-6, Jim foo.bar wrote: > > Hi all, > > Without having looked at the test.check internals, I'm trying to figure > out roughly what kind of generator function, the following spec will give: > > (s/def ::predicate (s/fspec :args (s/cat :x any?) >

Re: code from spec with clojure.spec?

2016-11-07 Thread Alex Miller
On Monday, October 17, 2016 at 5:51:42 PM UTC-5, Joe Corneli wrote: > > As a running example related to the ideas in > http://clojure.org/guides/spec#_spec_ing_functions, please consider the > following function: > > (defn mapper [x y] > {:tacos (vec (range x)) >:burritos (vec (range y))})

Re: Strange behavior Clojure and Null

2016-11-07 Thread Alex Miller
The problem here is that you're not giving the Clojure type inferencing enough info to work with and it's using reflection to find the correct method. When it finds multiple potential matching methods by arity, it calls an arbitrary one (not my favorite behavior). So, not a feature and maybe a

Re: clojure.spec gen-testing VS NaN

2016-11-07 Thread Alex Miller
My workaround is actually working > nicely for me, and i can certainly live without NaNs in the tests, but it > still feels a bit hacky. > > Thanks, > > Dimitris > > On 07/11/16 18:14, Alex Miller wrote: > > Please also take a look at s/double-in, which allows you to e

Re: Clarification on # as valid symbol character

2016-11-07 Thread Alex Miller
On Monday, November 7, 2016 at 6:33:49 PM UTC-6, Steven Yi wrote: > > Hi All, > > I wanted to understand whether '#' may be treated as a valid character > for symbols. The Clojure site [1] has: > > "Symbols begin with a non-numeric character and can contain > alphanumeric characters and *, +,

Re: any? in clojure 1.9.0 alpha

2016-11-08 Thread Alex Miller
On Tuesday, November 8, 2016 at 1:23:29 AM UTC-6, Devin Walters (devn) wrote: > > Perhaps there'll be some liberties taken in 2.0? > Highly unlikely. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googl

Re: any? in clojure 1.9.0 alpha

2016-11-08 Thread Alex Miller
On Tuesday, November 8, 2016 at 2:28:54 AM UTC-6, Colin Yates wrote: > > The ship has indeed sailed. However, it is exactly these moments when > software starts to degrade - there are many examples of crufty > software crippled by legacy decisions. > I completely disagree with this idea, partic

Re: clojure.spec - seeking a working example of stest/instrument with the :replace option

2016-11-08 Thread Alex Miller
The issue is in the call to instrument: (stest/instrument `ranged-rand {:replace {`ranged-rand ::ranged-const}}) The :replace map is "a map from var-name symbols to replacement fns". Here, you are passing a spec name, rather than a function. So you want something like this instead: (stest/in

Voting

2016-11-08 Thread Alex Miller
In the spirit of the US election today, I thought I would mention voting on Clojure tickets. Clojure manages bugs and enhancement requests in JIRA . Anyone can create a JIRA account and vote on open

Re: any? in clojure 1.9.0 alpha

2016-11-08 Thread Alex Miller
On Tuesday, November 8, 2016 at 9:34:53 AM UTC-6, Colin Yates wrote: > > you mean Java with the 'billion dollar mistake' known as null? Yep, that one, which millions of programmers use every day. > The Java which has just completed changed its Date and Time API _for the > better_? They d

Re: Voting

2016-11-09 Thread Alex Miller
Let's keep the focus on Clojure here, please. -- 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 un

Clojure Repos - Some Dependencies are Not In Clojars

2016-11-09 Thread Alex Miller
We are not going to publish the Clojure contrib libraries to Clojars, sorry. -- 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 patie

s/valid? vs. s/explain

2016-11-13 Thread Alex Miller
Any case where valid? returns false and explain-data returns nil is a bug. -- 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

Re: Help me understand what part of this code is slow, and how to make it faster?

2016-11-16 Thread Alex Miller
On Wednesday, November 16, 2016 at 8:10:27 AM UTC-6, Jason Felice wrote: > > I'll bet the atom accesses dominate the computation. They are a part of > Clojures software transactional memory (STM) and have a cost. > Atoms don't use the STM and if used in a single-threaded context like this, th

Re: Spec validation cache?

2016-11-16 Thread Alex Miller
Maybe you don't need to instrument *all* functions in development? Alternatively, you could instrument and provide simpler replacement specs to improve speed. For example, an fspec arg could be replaced with ifn?. On Tuesday, November 15, 2016 at 10:29:34 PM UTC-6, Gal Dolber wrote: > > I'm ha

Re: Help me understand what part of this code is slow, and how to make it faster?

2016-11-16 Thread Alex Miller
In general, any benchmark code using math should be aware of boxing (old post here: http://insideclojure.org/2014/12/15/warn-on-boxed/). I would recommend doing the work to leverage primitive longs and unchecked math. Generally this makes numeric code like this about 2 orders of magnitude faste

Re: How to check type of generic parameter with spec?

2016-11-16 Thread Alex Miller
On Tuesday, November 15, 2016 at 10:11:34 PM UTC-6, Eunmin Kim wrote: > > Hi! I had a question while reading Functional Programming in Scala book. > > The following code is Exercise 2: > > // Exercise 2: Implement a polymorphic function to check whether > // an `Array[A]` is sorted > > def isSort

Re: Validate different maps that have the same keys in the same namespace

2016-11-17 Thread Alex Miller
(s/def :a/type #{"a" "b" "c"}) (s/def :a/ref string?) (s/fdef get-product-from-catalog-a :args (s/keys :req-un [:a/type :a/ref]) :ret any?) ;; --- (s/def :b/type #{:x :y :z}) (s/def :b/ref number?) (s/fdef get-product-from-catalog-b :args (s/keys :req-un [:b/type :b/ref]) :ret any?)

Re: Is there any way to pass clojure spec conform value to next spec?

2016-11-18 Thread Alex Miller
You need to use s/and, not and. On Friday, November 18, 2016 at 10:13:50 AM UTC-6, Mamun wrote: > > HI All > > Take an example in bellow > > (defn x-int? [x] > (cond > (integer? x) x > (string? x) (try > (Integer/parseInt x) > (catch Exception e >

Re: Validate different maps that have the same keys in the same namespace

2016-11-18 Thread Alex Miller
On Friday, November 18, 2016 at 7:55:31 AM UTC-6, damien.rago...@gmail.com wrote: > > Got it. > > Thanks for the answers. > > I still feel that the global registry for specs is weird. It seems so easy > to have namespaced keyword conflicts coming from various namespaces, > specially in big pro

<    1   2   3   4   5   6   7   8   9   10   >