Re: Got NullpointerException when using loop/recur/let together

2017-10-24 Thread Justin Smith
you wrap a call to Thread/sleep in parens, in clojure this means you want to call it, Thread/sleep returns nil and calling nil gives a NullpointerException Parens are not for grouping or sequencing things in clojure, and you don't need them here - fn has an implicit do block already, in other cont

Got NullpointerException when using loop/recur/let together

2017-10-24 Thread yihao yang
Hi, all I want to do sth. like query until timeout. So I write a function below. (defn wait-ls-ready [] (let [pair-fn (fn [] ( (Thread/sleep 1000) (let [ret (try (c/exec :ls)

Re: Minor bug in clojure.zip/path

2017-10-24 Thread adrian . medina
clojure.core/seq? ([x]) Return true if x implements ISeq (seq? []) => false because... (instance? clojure.lang.ISeq []) => false Vectors do not implement ISeq. That's all the seq? predicate cares about. But vectors are `seqable?`: clojure.core/seqable? ([x]) Return true if the seq functio

[ANN] lacinia-pedestal/0.4.0

2017-10-24 Thread Howard Lewis Ship
lacinia-pedestal provides the Pedestal support to expose web endpoints backed by Lacinia's GraphQL. The GitHub repository is https://github.com/walmartlabs/lacinia-pedestal Documentation: http://lacinia-pedestal.readthedocs.io/en/latest/ Featured changes in 0.4.0: - The compiled schema may, ins

Minor bug in clojure.zip/path

2017-10-24 Thread Maxim Bazhenov
Hi, the documentation for clojure.zip/path states that it *"Returns a seq of nodes leading to this loc". *But the following test will fail (seq? returns false): (require '[clojure.zip :as z]) (def v [[1]]) (def vz (z/vector-zip v)) (seq? (z/path (z/down (z/down vz The path actually retur

[ANN] com.walmartlabs/lacinia 0.22.0

2017-10-24 Thread Howard Lewis Ship
Lacinia is an open-source implementation of Facebook's GraphQL specification, in Clojure. GraphQL is an outstanding approach to getting diverse clients and servers exchanging data cleanly and efficiently. The GitHub repository is https://github.com/walmartlabs/lacinia Documentation: http://lacin

Re: How to spec meta?

2017-10-24 Thread Alex Miller
Yes, you would need to actually create a spec implementation to improve the error message in this case. We haven't ever talked about spec'ing meta. In one sense I'd say the general philosophy in Clojure is that meta is *not* part of the data (as in how equality ignores meta), and thus it's not the

Re: How to spec meta?

2017-10-24 Thread Vitalie Spinu
Thanks Alex. But then (s/assert ::o {}) gives failed: (valid? ::meta-spec (meta %)) which is not quite satisfactory. Is my understanding correct that for a more integrated approach one would need a custom Spec implementation? And if so, shouldn't it be part of the core then? >> On Tue

Re: How to spec meta?

2017-10-24 Thread Alex Miller
(s/def ::o #(s/valid? ::meta-spec (meta %))) should work. On Saturday, October 21, 2017 at 3:57:20 PM UTC-5, Vitalie Spinu wrote: > > > Hi, > > If my meta spec looks like > > (s/def ::meta-spec (s/keys :req [::xyz])) > > > how do I define a spec for objects whose meta conforms to `::meta-spec

Re: Don't Laugh - How to Get the Name of an Anonymous Function

2017-10-24 Thread Alex Miller
Just to chime in and second what others have said, functions do not encode their name in an accessible way. The best option right now is to use clojure.repl/demunge on the class name. This is a best-effort function as the transformation from Clojure function name to Java class class name is no

Re: Don't Laugh - How to Get the Name of an Anonymous Function

2017-10-24 Thread Sean Corfield
No need to import the compiler. Use clojure.repl/demunge Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) _ From: Ravindra Jaju mailto:ravindra.j.

Re: Don't Laugh - How to Get the Name of an Anonymous Function

2017-10-24 Thread Ravindra Jaju
It's a good start. You could next import clojure.lang.Compiler and call the static method demunge like so on the output "cool_func_BANG_" (Compiler/demunge "cool_func_BANG_") ; => "cool-func!" On Tue, Oct 24, 2017 at 11:27 AM, Shantanu Kumar wrote: > Not sure whether you can deterministically r

Re: Don't Laugh - How to Get the Name of an Anonymous Function

2017-10-24 Thread Beau Fabry
If I had to guess I'd say the name of the function isn't stored with it nil boot.user=> (clojure.reflect/reflect (fn foo [] nil)) {:bases #{clojure.lang.AFunction}, :flags #{:public :final}, :members #{#clojure.reflect.Constructor{:name boot.user$eval1530$foo__1531, :declaring-class boot.user$ev