Fork me on GitHub
#clojure
<
2018-09-18
>
awb9901:09:51

I am trying to compile my clojurescript project on my testing server, which runs debian jessie,

awb9901:09:12

and I think figwheel/sidecar brings u p some strange error.

awb9901:09:33

Is there any type of dependency ?

awb9901:09:53

On my dev machine I have arch with obviously the latest versions....

awb9902:09:26

I just fixed it. Java 1.8 solved the issue. What is strange, is that I read that 1.6 should work also.

hiredman02:09:12

it depends on which version of clojure you are using, but if you are using a java library and it is compiled with a newer java version, then you will have to use that version

hiredman02:09:53

that error is from the jvm trying to load a class file that was generated by a newer version of javac

awb9903:09:58

Thanks @hiredman. So the clojure dependency that leiningen gets is not linked to the java version installed then?

seancorfield04:09:32

@hoertlehner No, Leiningen will use whatever your default version of Java is (although you can tell Leiningen to use a specific version of Java). It's up to you to ensure that you have the right version of Java installed (and tell Leiningen to use it, if it isn't your default).

seancorfield04:09:16

See https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L282 :java-cmd for how to tell Leiningen which Java command to use (and hence which version).

octahedrion09:09:37

is there a way to do machine-specific local overrides with deps.edn ? I want to provide a deps.edn for the repo that has some dependencies overridden for locally developed dependencies on a particular machine so I don't want those paths in the repo -- using ~/path/to/local/project doesn't work in deps.edn

rustam.gilaztdinov09:09:10

Hello! I'm always using libs for working with states in my projects and have this options in project.clj:

:profiles {:repl {:dependencies [[org.clojure/tools.namespace "0.2.11"]]
                    :repl-options {:init-ns }
                    :injections [(require 'clojure.tools.namespace.repl)
                                 (require ')]}}
How can I do the same with deps?

dominicm09:09:40

@octo221 ~ doesn't work in deps.edn, try /home/blahblah

octahedrion09:09:24

yeh that's what I'm doing

octahedrion09:09:58

but the problem with that is you have a machine-specific path in your deps.edn which is why I'm asking how to do it without that

dominicm09:09:05

@octo221 I put these into my ~/.clojure/deps.edn file, and then do clj -A:user/krei:user/pack:dev

octahedrion09:09:35

ahah i guess you could add project-specific overrides in there yes

dominicm09:09:24

(krei and pack are libs I develop)

kwladyka12:09:32

deps.edn

{:aliases {:test {:extra-deps {olical/cljs-test-runner {:mvn/version "2.1.0"}}
                  :extra-paths ["test"]}
           :test-once {:main-opts ["-m" "cljs-test-runner.main"]}
           :test-watch {:main-opts ["-m" "cljs-test-runner.main" "-w" "src"]}}}
Is it possible to include :test in :test-once and :test-watch? I would like to run commands as clj -A:test-once instead clj -A:test:test-once.

kwladyka12:09:18

I guess there is no option for that, but ask anyway 🙂

dominicm12:09:14

There is no option for that.

kwladyka12:09:41

So what I am thinking is how to provide for developers all commands which they can use during developing. Documentation is not the best solution. Code should describe it. So how to tell developers they can use clj -A:test:test-once and clj -A:test:test-watch with project? We can easy imagine there is 15 commands like this in project.

kwladyka12:09:51

What is your solution?

dominicm12:09:25

@kwladyka I've been using namespaces to suggest hierarchy. Similarly to you, but replace - with /

kwladyka12:09:06

> but replace - with / What do you mean?

dominicm12:09:27

:test/once instead of :test-once

dominicm12:09:21

Given that it's just data, you could use a tool to automatically update aliases based on a convention?

dominicm12:09:44

Read in the edn, merge :test with all aliases starting with :test/ and spit it out (with pprint)

kwladyka12:09:24

But the question on the end is how to show developers (also new guys in team) which commands they can use during developing. Imagine we can use 15 commands. Reading :aliases will be a mess. I feel it should be something more. I read one article about use make foo (old good linux command make) instead as knowledge base of all commands in project. First I thought it doesn’t make sense, but I see value of it.

Alex Miller (Clojure team)14:09:15

I think an enhancement to list available aliases in clj would be interesting

Alex Miller (Clojure team)14:09:35

but probably would not go as far as you want

kwladyka16:09:55

I am thinking about something which let also add commands to compile third party code which is in different language, but library in cljs use this code. Run extra services for developing like fake servers. So it is not only about aliases. Well this commands could be set in deps.edn maybe, but there is no way to determine which commands make sens for developers. Like -A:test:test-once make sense but not -A:test-once:test-watch. -A:compile-solidity:build make sene, but -A:compile-solidity:foo not. It needs to be something which developers can set manually. On the end it has to be out of the box. So it should be possible to use it in docker-compose run or whatever.

kwladyka16:09:58

Just I would like to use something better than documentations. There are always secret commands. I would like to describe developing process on local machine by code, not documentation.

kwladyka16:09:09

But in very clear way, without extra lines which are not really developing process, but project configuration

kwladyka16:09:49

like developer can open project and see, he can do actions: - test-once - test-watch - compile-solidity - ganache-cli - ipfs etc. the best with short description and call foo test-once, foo compile-solidity etc. things to run commands not only with clj tools, but third party app, compilers etc.

kwladyka16:09:56

make in theory should satisfy this, but I feel it is not right tool for this job. I mean it is not purpose of this tool.

kwladyka16:09:48

with make developer can type make te[TAB] to see commands

kwladyka16:09:58

It is good direction, but still I feel it is not right tool by intention of this tool

Alex Miller (Clojure team)16:09:33

we’re not interested in adding this kind of capability within clj, but these are fine things to add as external programs and in fact, some of them have already been done - https://github.com/clojure/tools.deps.alpha/wiki/Tools

kwladyka16:09:06

Sure. It is more question to developers and share experience, than suggestion to implement in clj.

kwladyka16:09:13

But clj -A:te[TAB] will be great 🙂

Alex Miller (Clojure team)18:09:25

well that’s possible with a completion script and would be cool

dominicm12:09:14

Why is documentation bad here?

kwladyka12:09:24

because it is always not up to date

kwladyka12:09:36

there is always some secret knowledge

dominicm12:09:11

@kwladyka what is your ideal here?

kwladyka12:09:15

First I wanted to try :aliases as knowledge base of commands. But I realise it is too complex, and there are things like clj -A:test:test-once or clj -A:test:test-watch with different combinations. Too much thinking about it. It is not clear. So I am not sure…. Maybe make test-once, make test-watch etc. Thinking about make like about knowledge base for project.

kwladyka12:09:37

But I would like to not use make probably. Not sure why. But I don’t have better idea.

dominicm12:09:50

make isn't really a task runner, it's for making things. Feels like a bad fit here.

kwladyka12:09:33

The question is what fit better?

dominicm12:09:24

If you're only trying to list aliases which have a :main-opts, and use a naming convention to know about it's dependencies you could: - read deps.edn - get the aliases - filter to those with main-opts - automatically add the conventional other aliases.

kwladyka12:09:09

no, I am talking about all commands. Also things to compile code in different language which is dependency for project etc.

kwladyka12:09:01

to run developing tools, for example fake servers

kwladyka12:09:04

I would like to make new developers coming to project comfortable, make things clear

kwladyka12:09:17

also current ones 🙂

dominicm12:09:25

@kwladyka if you're also merging in information from outside deps.edn, you'll need to factor that into any designs you consider.

kwladyka12:09:35

Even myself after back 1 year after to project 🙂

kwladyka12:09:29

yes and the question is what is the best practice about it. Documentation is far away from perfect.

kwladyka12:09:27

But maybe there is nothing better

gleisonsilva12:09:11

Hello, guys! May you help me... I'm starting to use https://github.com/lancepantz/clj-yaml... and, different from the examples was showing, what I get after doing a "parse-string" is a #ordered/map, instead of a "plain" clojure map. Am I doing something wrong?

benzap12:09:38

@kwladyka I like the concept of the makefile. It's well-known and would allow more flexibility as a wrapper around the clj tool. Exposing the uses of the tool could be done typically in the README.md file, and maybe a helpful command in the makefile like make help

benzap12:09:40

New developers know about makefiles as well, and the only takeaway of not really being windows-compatible is already an issue with clj anyways

mpenet12:09:06

@gleisonsilva there are more up to date forks fyi

mpenet12:09:22

if you *really* have to use yaml

gleisonsilva12:09:16

in fact, i'm using circleci/clj-yaml

gleisonsilva12:09:26

that is a fork of that one

mpenet12:09:28

that said ordered map behaves like a normal map, it's just ordered, it should be an impl detail for you

gleisonsilva12:09:43

is kind a inconvenient

mpenet12:09:13

you could overwrite it's print-method I guess

gleisonsilva12:09:03

in this code, there is a norma-coll function that is very handy

kwladyka13:09:07

@benzap yes, I would like to have one place with all commands like run ganache-cli, compile Solidity, run tests, run ipfs and all stuff in one place. But I have never seen somebody to do it in makefile 🙂 I am not sure it is good idea or bad. makefile / doc / ?. I don’t have better idea how to do it at that moment.

benzap13:09:17

Yeah that is a problem, hmm

benzap13:09:39

An alternative approach would be to create components (or mounts) as services to start as part of the development cycle. These could then be stowed away as a separate set of libraries that could be included in the projects

benzap13:09:03

it would support the reloaded cycle

benzap13:09:17

and each service could be managed within clojure(script) itself

benzap13:09:10

You would have one point of entry, you would have a standard dev workflow that would need to be configured, but if need be, it can be changed by providing your own custom set of mounts

kwladyka13:09:23

That is the thing which I would like to avoid. REPL should’t assume there is solidity compiler installed on machine. What if not? Then it will crash.

kwladyka13:09:14

or maybe project tools during developing will be run as docker-compose up to run ganache-cli, ipfs etc. I believe this things shouldn’t be implemented in clj

benzap13:09:41

those things would need to be worked out in the mount component, and it would only be exposed as a dev dependency

benzap13:09:52

yeah, that poses the problem of not making it very docker friendly

benzap13:09:41

An interesting method I saw was the use of an elisp script included with the project for opening each process as a separate buffer, but then people would be forced to use emacs for development

kwladyka13:09:25

I use Intellij, no way 😛

benzap13:09:50

someone will need to make you a convert 😉

kwladyka13:09:04

Many people were trying before 😉

kwladyka13:09:11

Even myself 🙂

Daniel13:09:35

For my research project of my computer science studies I am currently developing a new static code analyzer for #clojure . The tool is to detect issues (bugs and code smells) of the program code and warn the developer before run time. Participate in my short survey to co-determine the upcoming features of the tool! https://goo.gl/forms/I1xne7cpIx7NuMT43

bronsa14:09:23

is the work in progress open source?

Daniel15:09:59

Not at the moment, but it will be open source in the future.

bronsa15:09:48

cool! ill be interested to see what you do :) have you checked out tools.analyzer?

waffletower18:09:45

I took the survey, thanks for posting

👍 4
dottedmag14:09:42

Daniel Compton says in the latest REPL "Make sure you're not drinking anything when you read Just JUXT #34. I won't spoil it for you here." – I read it and it seems to be a straightforward solution for 4Clojure problem. Am I missing something?

manutter5114:09:35

I was just thinking the same. Cool solution, but no drinking problems.

dottedmag14:09:12

Maybe there was a draft blog post replaced by the real one ¯\(ツ)

dangercoder17:09:42

To me it seems wrong to have UI (Cljs) and Back-end (CLJ) in the same leiningen project. But without it I get problems with the session. Is it possible to run them on the same port even if its two different projects? - using leiningen.

noisesmith17:09:36

how would two servers serve requests from the same port?

noisesmith17:09:08

also why would they need to share a port? wouldn't the back end just serve up the html generated by the cljs project?

noisesmith17:09:38

(plus the js generated of course)

dangercoder17:09:43

Im getting problem with Session and Ring

noisesmith17:09:24

What kind of session store are you using? If you have endpoints that are defined wrong it's easy to overwrite the session with empty data. I find it's easiest to debug this by using an atom as an in-memory session store and an add-watch to show changes to the contents

dangercoder17:09:16

using immutants session store atm. It works fine from Insomnia, gonna try the atom in-memory session store and see if I find anything.

noisesmith17:09:20

the default session store impl is an atom, you might have to override and provide your own atom to access it directly

dangercoder17:09:31

yeah its still an atom* i think

dangercoder17:09:23

Figwheel runs on 3349 and my api on 3000 hmm. Might be some chrome issue I guess

souenzzo17:09:00

I want to share a (ephemeral) atom across instances, like faraday-atom, but it has a "huge" (larger then 400kb) payload. Are there other options?

hiredman17:09:18

there was a project, long ago in the before time, that made an atom like type stored in zookeeper, called avout

hiredman17:09:02

I think caspaxos would be great, for that, but I don't know of a library for it

souenzzo17:09:30

there is atoms@zookeeper for clojure too, but not sure if is good to store "huge" data on it. as we dont have postgres, I'm planning to make a new database on datomic and store it with no-history (maybe delete/recreate the database sometimes)

john17:09:11

I don't think avout structures are persistent, IIRC

jrychter18:09:59

I sometimes wonder if it is intentional that sorted-set does not take a collection like set does. I fall into this whenever I try to use sorted sets: you have to use apply.

andy.fingerhut18:09:20

I think sorted-set is more like hash-set in this regard. vec and vector are different from each other in a similar way.

andy.fingerhut18:09:04

Not sure if this is a great mnemonic, but the shorter names take collections: set vec. The longer names take varargs.

👍 8
Alex Miller (Clojure team)19:09:08

Yes, that is a good mnemonic

andy.fingerhut18:09:30

I don't claim to know all the rhymes and reasons, but I've found that the more I look, there are very few if any accidents in the clojure.core API design.

jaawerth18:09:53

that would make sense if (apply sorted-set col) produced the same result as (set col) or if there were an equivalent short-hand for sorted-set, but...

jaawerth18:09:21

the only way I know of to get a sorted set from a collection without apply is into. unless I'm missing something (very possible)

noisesmith18:09:00

see also PersistentQueue which can only be constructed via interop and doesn't print readably

noisesmith18:09:13

(but it's a very useful datatype)

hmaurer22:09:23

Hello 🙂 I could use someone’s brain on a little problem I have. I can’t quite figure out how to say it in English so I’ll start by giving an example. I want to write a function which has the following behaviour:

; Input:
#{(range 0 6), (range 3 8), (range 4 11)}

; Output:
#{[(range 0 3), #{(range 0 6)}], [[3], #{(range 0 6) (range 3 8)}], [(range 4 8), #{(range 3 8), (range 4 11)}], [(range 8 11), #{(range 4 11)}]}

hmaurer22:09:07

Basically, I want to write a function which takes a bunch fo ranges and returns all the n-ary intersections of ranges, together with a list of the ranges overlapping that intersection

hmaurer22:09:29

I could of course write this is a few “dumb” ways, but I am looking for an elegant solution

hmaurer22:09:35

purely functional also

hiredman22:09:45

a lazy seq (what range returns) isn't a great starting point

hmaurer23:09:34

ah thanks! that seems interesting

andy.fingerhut22:09:59

So if there are N ranges in the input, and all of them have non-empty intersections, the output should have 2^N-1 items in it, since every one of the 2^N possible subsets of the N ranges have an overlap?

andy.fingerhut22:09:20

(well, all except the empty subset with no ranges, hence the -1)

andy.fingerhut22:09:30

Although I would guess that if you want them all, then you are probably expecting that your inputs will typically not have that much overlap between them.

hmaurer22:09:50

@hiredman oh thanks, but my problem won’t actually use range; I just used it to try to get a simple example to explain the problem

hmaurer22:09:58

@andy.fingerhut correct. To give you some context, my input will be a collection of date ranges (think of “bookings” on an airbnb-like application)

hmaurer23:09:18

but regardless of the computational complexity, I am wondering if there is a neat way to formulate a solution to this problem functionally.

andy.fingerhut23:09:20

One nice short bit of code would be (filter non-empty-intersection (all-subsets my-ranges)), where non-empty-intersection is a function you would write to take a set of ranges, and return true if they have a non-empty intersection, or false if their intersection is empty. all-subsets takes your N ranges and returns all 2^N subsets of the input collection. The all-subsets function is called subsets in its implementation in the math.combinatorics Clojure library here: https://github.com/clojure/math.combinatorics

andy.fingerhut23:09:12

Such an implementation would be straightforward to write, I think, but would always take 2^N time, even if the number of non-empty subsets was much smaller, because it would call non-empty-intersection on all 2^N subsets.

andy.fingerhut23:09:33

A potentially huge optimization on that would be a different version of all-subsets that, whenever non-empty-intersection returned false for a set of ranges, would skip generating any sets of ranges that included those ranges as a subset. I don't know of a version of subsets that does that off the shelf.