This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-20
Channels
- # announcements (27)
- # aws (1)
- # beginners (62)
- # boot (5)
- # calva (56)
- # clj-kondo (6)
- # cljdoc (3)
- # cljsrn (4)
- # clojure (65)
- # clojure-dev (17)
- # clojure-europe (2)
- # clojure-italy (17)
- # clojure-nl (24)
- # clojure-spec (30)
- # clojure-uk (14)
- # clojurescript (35)
- # clr (7)
- # cursive (8)
- # data-science (3)
- # datascript (38)
- # datomic (15)
- # emacs (16)
- # fulcro (34)
- # hyperfiddle (1)
- # immutant (1)
- # luminus (7)
- # nrepl (1)
- # off-topic (38)
- # pedestal (2)
- # planck (10)
- # re-frame (7)
- # reagent (7)
- # reitit (9)
- # shadow-cljs (36)
- # sql (19)
- # tools-deps (11)
- # vim (64)
- # xtdb (18)
How to set *print-namespaced-maps*
to false
via project.clj
for nrepl 6.0 :init
doesn't work
Is there a library that would parse edn (as edn not text), kind of like spec but maybe with more of a focus on speed ?
Could someone tell me (or link me) the way in which I can define the "entrypoint" for a project using clj? as if I were to type clj -m my-package.core
? I assume some setting in deps.edn? But main-opts at the top level doesn't seem to do the trick so May have missed something
@m131 just define a -main
function in the namespace my-package.core and make sure you have :paths ["src"]
in your deps.edn, so clojure can find your namespace definition
thank you - will the paths ["src"] setting assist with tools like Cider finding / auto-loading the file(s) on repl start? I notice in lein projects that happened automatically for me, but with the deps.edn set up, I have to manually load each file
:paths
sets the classpath, where clojure searches for classes/namespaces. If currently (require 'your.namespace)
doesn't just work and you have to load files manually, then you are missing :paths
definition in your deps.edn
If not, it could be an issue there, where Cider is not starting nRepl in the context of your deps.edn
hi everyone. where do you usually deploy your clojure apps? I've tested a few - heroku, digitalocean, aws. heroku seems to be the most straight forward, easy and super quick one. it took me more than an hour on the other two. so was wondering if there are any other services out there
Github API looks very straightforward. I’d personally approach this by generating the required HTTP-request(s) with clj-http
or something similar. https://developer.github.com/v3/gists/#create-a-gist
Another option could be using one of the Java libraries via interop, for example https://github.com/eclipse/egit-github/tree/master/org.eclipse.egit.github.core
Hmmm this is not maintained but it might just work https://github.com/Raynes/tentacles
tricks I keep on forgetting :
• when you need a function that ignores its argument and returns nil, you can use {}
• when you need a function that ignores its first argument and returns its second argument, you can use {}
(update {:a 1 :b 2} :a {})
#_=> {:a nil, :b 2}
(update {:a 1 :b 2} :b {} 3)
#_=> {:a 1, :b 3}
I think the “new” :skip-whitespace
option should default to true
in data.xml because upgrading from 0.0.8 to 0.2.0-alpha6 broke our code
Here and there I found some functions in my code failing silently, where I expect them to throw exceptions and break the loop. I don’t understand why.
looking at asynchronous constructs such as futures, agents or go blocks is usually a good start
maybe this is related https://stuartsierra.com/2015/05/27/clojure-uncaught-exceptions
However, Thread/setDefaultUncaughtExceptionHandler
doesn’t seem to fix it for future
in my case. I use future
to run a loop and never deref the future.
Does that mean I should get rid of future
and use something else instead?
yes, a future that is never derefed is a code smell. you may consider using a plain j.u.c.Executor instead
"pathetic" seems harsh
probably because the core is already big enough and java interop works well for this kind of stuff
BTW clojure functions implement java.lang.Runnable so spawning a thread manually from clojure is a one-liner
However, Thread/setDefaultUncaughtExceptionHandler
doesn’t seem to fix it for future
in my case. I use future
to run a loop and never deref the future.
Does that mean I should get rid of future
and use something else instead?
Hi, everyone I had a question about state and persistence : The thing is I have an atom as the main state of some module ... and the persistence (into db) is handled by adding a watch on that atom that translates the diff of two subsequent states into a transaction (put new state + put the transition) However due to asynchronous behavior of watches (and fast state updates) ... I get foreign key errors, since the previous state is not inserted (transition has a foreign key constraint to state) My questions : - what is the best way to handle it? - and is such a scheme for state managment rational, at all?
I think part of your problem is that you're using one identity (an atom) to try and control a huge grid of identities (each column of each row of a table, assuming that you're only trying to sync your atom to one table). It's worth calling out first because it's essential to what you are trying to do, and you cannot change that aspect of your plan without changing your plan.
Thanks Alex, I didn’t quite got that. But I could reaally use help. I have an async component whose entire state is kept inside an atom and each value of the state has a version (i.e. every swap! will increment it) Upon changing its value the watch will be called which then translates the changes into multiple inserts to multiple tables. The thing is watches invocations aren’t always in order. So the watch will try to persist sth that depends on a version that itself is not yet written into db
So, we have three concerns we need to juggle: - Identity: a place where we hold a successions of states - State: a single coherent value "of the world" - Persistence/Durability: Storing things between processes so that there's a long term record of something of value.
An atom takes care of two of these things, State and Identity, and one Atom allows you to work with one Identity with one State at a time.
You want to take this one Atom and map it down onto a SQL database. Most SQL databases give you strong durability through a table semantic. One table is an NxM matrix of identities, each row/column pair is one thing that can get updated of the other columns in that row and the other rows in that table. If your one atom sprawls over multiple tables, you have an LxNxM matrix of identities you want to stuff into one identity.
So your problems are: - You are trying to map a 3 dimensional LxNxM matrix of identities into one identity, an atom. - The tool around atoms you're trying to use to do this, add-watch, does not guarntee each successive state will be handed to the watch in order.
If you want ordering guarantees, then you could maybe look at replacing the atom with an agent. With the agent, you can't synchronously write; you dispatch a write and it completes when every other write previously queued before it completes. You can still use add-watch.
But I think you'll still have a lot of problems by trying to hide your DB away behind an atom, or an agent, or any other in memory identity in Clojure, and encourage you to not do that.
Am I right to think that by the last comment you mean to push all state into db and not to hold any in identity in memory then?
You're already holding state in the DB; the only question is what interface you put over it. If you give yourself good tools for reading information out of the DB that you can reason with, then you'll have a program that's easier to reason about as a whole. As a start, you could pull maps, or vectors of maps out of the DB as a discrete read operation, and likewise have discrete writes. And there's a lot of tools already built to support you doing this, e.g. honeysql, hugsql
@borkdude there is this branch: https://github.com/sogaiu/specter/tree/clr-support - is that the sort of thing you are looking for?
there is also this: https://github.com/sogaiu/compliment/tree/clr-support - in both cases the work is incomplete, fwiw
it seems orchestra is compatible with cljr: https://github.com/jeaye/orchestra/blob/master/src/clj/orchestra/spec/test.cljc
Tims did all the work, for use with Arcadia: https://github.com/jeaye/orchestra/pull/37
@adicirstei irresponsible seems to take care of tentacles: https://clojars.org/search?q=irresponsible%2Ftentacles
@adicirstei this is what I ended up using for https://github.com/exoscale/pullq and it does the job well
how does one AOT a clojure var, I'm using isBound on clojure.lang.Var
both ^clojure.lang.Var var
and (:import [clojure.lang Var]) .... ^Var var)
result in
java.lang.NoClassDefFoundError: clojure/lang/Var
it sounds like you are not including the clojure runtime with your aot compiled code