Fork me on GitHub
#clojure
<
2019-05-20
>
Ivan Koz03:05:18

How to set *print-namespaced-maps* to false via project.clj for nrepl 6.0 :init doesn't work

carkh03:05:09

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 ?

ahungry05:05:26

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

Alesya Huzik05:05:12

@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

ahungry05:05:57

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

Alesya Huzik05:05:06

: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

didibus05:05:59

You can check in Messages buffer to see the command Cider ran to start nRepl

didibus05:05:17

You should see it using your deps.edn

didibus05:05:53

If not, it could be an issue there, where Cider is not starting nRepl in the context of your deps.edn

Bravi09:05:56

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

Adrian10:05:14

Hey! I might be asking in the wrong channel but here it is:

Adrian10:05:37

I am looking for a library to create gists on github

Adrian10:05:22

a clojars search for github yielded decade old libs

Adrian10:05:34

d you have a recommendation?

valtteri10:05:01

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

valtteri10:05:09

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

Adrian10:05:18

I'm inclined towards clj-http

valtteri10:05:49

Hmmm this is not maintained but it might just work https://github.com/Raynes/tentacles

leonoel11:05:02

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}

borkdude11:05:17

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

markx11:05:08

What could possibly result in exceptions disappear silently?

markx11:05:49

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.

leonoel11:05:52

looking at asynchronous constructs such as futures, agents or go blocks is usually a good start

markx13:05:35

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?

leonoel13:05:40

yes, a future that is never derefed is a code smell. you may consider using a plain j.u.c.Executor instead

markx13:05:40

That’s pathetic… Why don’t we have a simple thread in the core?

Noah Bogart13:05:47

"pathetic" seems harsh

leonoel13:05:30

probably because the core is already big enough and java interop works well for this kind of stuff

leonoel13:05:25

BTW clojure functions implement java.lang.Runnable so spawning a thread manually from clojure is a one-liner

markx13:05:35

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?

Ho0man13:05:33

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?

Alex13:05:53

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.

Ho0man18:05:00

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

Ho0man18:05:21

I greatly appreciate your help

Alex18:05:30

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.

Alex18:05:24

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.

Alex18:05:37

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.

Alex18:05:51

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.

Alex19:05:49

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.

Alex19:05:47

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.

Ho0man04:05:26

Yep that’s it

Ho0man04:05:29

Thanks alot, Alex

Ho0man04:05:18

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?

Alex13:05:16

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

borkdude14:05:07

what are some repo’s that use reader conditionals + :cljr ?

sogaiu14:05:52

@borkdude there is this branch: https://github.com/sogaiu/specter/tree/clr-support - is that the sort of thing you are looking for?

sogaiu14:05:29

there is also this: https://github.com/sogaiu/compliment/tree/clr-support - in both cases the work is incomplete, fwiw

borkdude14:05:17

yeah, I would rather test with established libraries, but it seems they are rare

sogaiu15:05:57

@borkdude yes, iiuc, @jeaye recently added clr support

👍 4
jeaye16:05:04

Tims did all the work, for use with Arcadia: https://github.com/jeaye/orchestra/pull/37

metal 4
sogaiu17:05:41

ah, i see, thanks for the clarification

pyr17:05:03

@adicirstei this is what I ended up using for https://github.com/exoscale/pullq and it does the job well

Adrian11:05:32

Thanks! I'll take a look.

hlolli21:05:45

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

hiredman21:05:40

how are you aot compiling and how are you trying to run your aot compiled code

hiredman21:05:56

it sounds like you are not including the clojure runtime with your aot compiled code

hlolli21:05:43

I'm using badigeon via tools.deps, yes that's most likely the reason, it's a new api, so wasn't sure if this was the code or the build tool.

hlolli21:05:12

well wasn't sure with that var as well, since I'm trying to prevent reflection on mikera's namespace tool