This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-17
Channels
- # aws (10)
- # beginners (64)
- # boot (3)
- # cider (20)
- # cljs-dev (32)
- # cljsrn (6)
- # clojure (126)
- # clojure-dusseldorf (3)
- # clojure-finland (1)
- # clojure-greece (1)
- # clojure-italy (7)
- # clojure-poland (3)
- # clojure-spec (46)
- # clojure-uk (100)
- # clojurescript (37)
- # cursive (11)
- # datomic (6)
- # defnpodcast (2)
- # emacs (1)
- # events (3)
- # figwheel (2)
- # fulcro (20)
- # immutant (2)
- # jobs (1)
- # jobs-discuss (9)
- # keechma (3)
- # lein-figwheel (1)
- # luminus (2)
- # lumo (3)
- # mount (2)
- # off-topic (19)
- # om (3)
- # om-next (2)
- # onyx (20)
- # other-languages (55)
- # parinfer (11)
- # pedestal (8)
- # portkey (3)
- # protorepl (3)
- # re-frame (22)
- # ring (9)
- # rum (1)
- # shadow-cljs (82)
- # spacemacs (28)
- # sql (15)
- # test-check (15)
- # testing (2)
- # tools-deps (102)
- # vim (26)
the tooling figwheel depends on (clojure.tools.namepsace, I think) has decided you have a circular dependency in your namespaces, which clojure doesn't allow either, but clojure isn't as good at detecting it
I haven't noticed it in my :requires, can you help me find it from the files in question? it's just 3 files
repl
(ns voke.repl
(:use voke.handler
figwheel-sidecar.repl-api
ring.server.standalone
[ring.middleware file-info file]))
(ns voke.middleware
(:require [ring.middleware.defaults :refer [site-defaults wrap-defaults api-defaults]]
[prone.middleware :refer [wrap-exceptions]]
[ring.middleware.params :refer [wrap-params]]
[ring.middleware.reload :refer [wrap-reload]]
[ring.middleware.json :refer [wrap-json-body wrap-json-response wrap-json-params]]
[ring.middleware.keyword-params :refer [wrap-keyword-params]]
[clojure.string :as string]
[clojure.pprint :as pprint]))
middlewarehandler
(ns voke.handler
(:require [compojure.core :refer [GET defroutes routes POST context]]
[ring.util.response :refer [response]]
[compojure.route :refer [not-found resources]]
[hiccup.page :refer [include-js include-css html5]]
[voke.middleware :refer [wrap-api wrap-site]]
[config.core :refer [env]]
[voke.api.v1.utils :refer [defresponse]]))
it looks like it scans the entire src/ directory by default, so if you have any other files in there, even unused, they could trigger this
is this a known bug in clojure 1.9.0? it seems if :clojure.spec.alpha/invalid
is within the body of certain clojure macros, everything blows up...
for example, using clojure.test/is
:
(is (= ::s/invalid (s/conform string? "1")))
=>
Call to clojure.core/let did not conform to spec: In: [0 3] val:
:clojure.spec.alpha/invalid fails spec: :clojure.core.specs.alpha/bindings
at: [:args :bindings :init-expr] predicate: any?
when placed within a fn:
(let [conformed? #(not= ::s/invalid? %)]
(is (conformeded? (s/conform string? "1"))))
=> false
the idea was to take some java pojo and call (pull-keys obj [:id [:name :getName]])
and produce the map {:id (.id obj) :name (.getName obj)}
then I had to deal with some vavr Options so I figured I could provide a function to be called for everything extracted
have you looked at bean
?
it does something similar to this
Im consuming classes produced from https://immutables.github.io/
good fortune inded
looks like that lib can produce different code styles - stuff like name()
is not the “standard java bean” style and won’t be picked up by bean
, but the getName()
style should be
not sure if you can ensure you’re using that style
so .name()
and the immutables library make working with that data on the java side fairly pleasant
but at the same time, when I get the opportunity to work on something by myself, its hard to use clojure because I have to undo that strict typing to get idiomatic maps
not to mention stuff like Option
and Try
which are in there, which make for some clunky code on the clojure end
well, not trying to talk you out of it :)
it’s fun to get stuff like this working too
I wonder if there's a way to tie the immutables library into the clojure protocols to make it play nicer
or would it even be worth it? It's been a while since i've done java interop stuff, let alone tying into clojure's core protocls
immutables seems like a generator, seems like you could generate the Clojure implementation of the interface and that would be ideal
a defrecord that implemented the interface and also exposed data as keyword accessors for example
My instinct would be to add some code that just straight up converts the immutable into a clojure map
unfortunately that would mean writing a good amount of java code in an area of java I dont really understand
generating the clojure code is also an option, but I would probably end up writing a completely separate code generator that just reads the annotations
Hi, I was looking for a thread-safe version of with-redefs
, it seems to be working for me in a toy example when I use with-local-vars
, are there any caveats here?
Original
(defn ten [] 10)
(def x (doall (pmap (fn [_] (with-redefs [ten (constantly nil)]
(ten))) (range 20 100))))
(ten) ;; gives nil
With local vars:
(defn ten [] 10)
(def x (doall
(pmap
(fn [_] (with-local-vars [ten (constantly nil)]
(ten)))
(range 20 100))))
(ten) ;; returns 10
Hi! What is the best way in Clojure to “transform a deep data structure from leaf to root”? e.g. apply some function to the leaves, then one level up, and so on
@hmaurer isn't that what postwalk does? (clojure.walk/postwalk-demo {1 {2 {3 4} 5 6} 7 8})
@pesterhazy yep, it is!
does anybody know what's happened with http://planet.clojure.in and their fb group?
I’m going to try to run some Clojure on it, if anyone else tries it out please share your results 🙂
Hi, i have a map like this {:type :type1 :children [{:type :type2 :children [..] ..]}
, and i want to write a spec for it . there is 4 types and an item with a certain type can only exists inside a specific type too (like :country :city :street ), how do you suggest i can achieve that ?
s/multi-spec
@schmee Are you gonna be writing a Clojure frontend for it?
awesome 😄 I tried a simple frontend with Graal sometime back, found this: http://epub.jku.at/obvulihs/content/structure/501665
but didn’t see any source code for it anywhere
If you’re giving it a shot then I’m up for it too 😄 Had been following Graal for sometime
> Are you working on a Java application? Do you want a faster runtime? Enhance your code with JavaScript! Either this is bad wording or I want some proves. Since when does javascript speed up Java applications?
@sveri lol what's that from?
@tbaldridge from the graalvm intro page: http://www.graalvm.org/ Under "Get Started"
I assume they speak of the native image capability, but how that relates to javascript, it still doesnt make sense 😄
>since when does javascript speed up Java applications? since graal can optimize js code faster than javac+hotspot can optimzie java code :)
I just wanted to give it a try, but no open source prebuilt binary is available for windows. A pity. Maybe someone else wants to do some comparisons.
I’m curious about the “Enterprise edition”, seems to boast “Improved performance and smaller footprint”
I’m not sure if that is technically possible since SVM has a lot of restrictions around reflection and dynamic class loading
Yeah you wouldn't want to build a Clojure/JVM on SubstrateVM. You'd want a "clojure native" on SVM. Something with good C interop, and all the good/bad that comes with that
you could build a Java bytecode interpreter in Truffle and use that for interop like they’ve already done with LLVM bytecode
That's also possible. Someone did that with PyPy, they wrote a Prolog interpreter in RPython and then integrated it into a PyPy build. So you could have Python and Prolog talking to eachother, but each with their own VM semantics.
PyPy does that as well with regexs (they have their own JIT/runtime)
@alexmiller I believe the reason for my confusion about liberal use of placement for type hints (other than fn arg lists) is this from the book "Programming Clojure" :
Clojure supports adding type hints to function parameters, let bindings, variable names, and expressions.
So this suggested that using it for locals (as suggested yesterday to avoid) was reasonable in tight loops. Also the word "expressions" seems rather vague, which suggests you could use them everywhere.so something like this makes no sense (loop [^long somelocal foo] ... )
and should be (loop [somelocal (long foo)]
does the type hint persist on different iterations of the loop? perhaps type hints have no meaning outside the context of a function arg?
the compiler detects primitive long locals and tries to retain them in a loop
generally yes
since functions are data in clojure, can i send a function in a network request? does anyone have an example?
unless you send it as code then eval it on the other side
https://github.com/technomancy/serializable-fn is a thing some people use for this
@drawls sending code over the wire raises a lot of security questions and you should think twice before doing that. Or three, four times maybe.
Is there a better way to interactively redefine proxy functions from a repl than this?
(defn make-proxy []
(proxy [Parent] []
(function1 [])
(function2 [])))
(defonce p (make-proxy))
(update-proxy p (proxy-mappings (make-proxy)))
The only alternative I can think of is to make each proxy function call out to an actual clojure function of the same name. Then I can easily redefine that clojure function at runtime. That doesn't feel very clean though.
have you tried https://github.com/clojure/tools.namespace? I’m not sure if that refreshes proxy bindings, but it handles most other things so I assume it will
Huh, I didn't think about that. It's been a while since I've used it. I've always been more in favor of manually evaluating things from Emacs. It's worth a shot though.
@alexmiller I believe the reason for my confusion about liberal use of placement for type hints (other than fn arg lists) is this from the book "Programming Clojure" :
Clojure supports adding type hints to function parameters, let bindings, variable names, and expressions.
So this suggested that using it for locals (as suggested yesterday to avoid) was reasonable in tight loops. Also the word "expressions" seems rather vague, which suggests you could use them everywhere.