Fork me on GitHub
#clojure
<
2015-10-17
>
dvcrn01:10:18

mini newbie question: I have a quoted vector that is getting passed to a function as a argument. I want to look inside that vector and pick some stuff out, but all I get is (clojure.core/unquote myVector). Can I somehow get the initial representation back?

fitzoh01:10:55

Can you give us an example maybe?

fitzoh01:10:07

Can’t figure out what the issues is

fitzoh01:10:12

user=> (= [1 2 3] (quote [1 2 3])) true

dvcrn01:10:18

seems like this was an issue with the framework I used. Somehow all I got was a literal (clojure.core/unquote myVector)

dvcrn01:10:30

changed the code a bit up and now it's working the way you described

dvcrn01:10:35

strange. Thanks!

tom02:10:44

@nberger: the project.clj contains no profiles info. I can make the jar fine locally and on the Jenkins server via ssh. But when Jenkins runs it it fails.

nberger03:10:28

@tom: I don't know what it might be... you could try moving the ring configuration from profiles.clj to project.clj and see if it picks it up from there. Btw, do you have a link to the source code of lein-jenkins or how is it called?

mo-love05:10:37

i'm having a problem importing a java library. i'm importing it with (:import (uk.ac.abdn.simplenlg.lexicon)) which works fine, but when I try to use it with (. Lexicon getDefaultLexicon) I get an error saying couldn't resolve symbol

mo-love05:10:06

anyone have an idea what i'm doing wrong?

aengelberg06:10:19

@mo-love: Your code doesn't say anywhere that you want to import a class called Lexicon. You would need to do (:import (uk.ac.abdn.simplenlg.lexicon Lexicon)) or (:import uk.ac.abdn.simplenlg.lexicon.Lexicon) (I'm just guessing at the full path to the class.) Unfortunately Clojure has no simile to Java's import my.package.*; that imports all the classes in a package (they must be enumerated individually).

mo-love07:10:41

@aengelberg: got it working with (:import (simplenlg.lexicon Lexicon))

aengelberg07:10:50

Cool, no problem @mo-love

jaen10:10:55

What's the go-to solution when a namespace A depends on a namespace B and vice versa, when refactoring is not an option (not too keen on refactoring Clojurescript compiler)?

bensu10:10:43

@jaen what are those namespaces in the compiler? It sounds weird because as far as I know, such circular dependencies are not allowed in Clojure

jaen11:10:32

@bensu: since there's none right now. My code for module preprocessing needs functions from both from cljs.js-deps as well as cljs.closure and needs to be available for cljs.js-deps. This causes a circular dependency. I see no obvious way how to structure it on my side to get around that.

bensu11:10:52

@jaen: then there is no way without extracting the common parts to a third namespace

bensu11:10:11

(that I am aware of)

bensu11:10:48

are the functions in cljs.closure main functions or "mostly utilitites"?

jaen11:10:37

@bensu: last time I spiked it, there were some bigger functions, but in my last try I only see report-errors which is a utility, but it's less full featured than the spike right now

jaen11:10:16

So there might yet be more

dnolen11:10:16

@jaen you will need to lift things into a common ns

mo-love13:10:36

What would be a killer Clojure program or lib that doesn't exist yet? I have too much time on my hands.

zenleaf13:10:08

Something like Bret Victor's Dynamic Drawing Tool

malch13:10:10

@mo-love: reactive om.next (Relay, Falcor)

malch13:10:38

with websockets

thheller13:10:41

@jaen I'm curious .. what are you trying to do with cljs.closure?

jprudent13:10:16

Hi! whats the most idiomatic way to get the first non nil value from a seq ? I'm currently stuck with this : (is (= false (first (filter (complement nil?) [nil false true]))))

tyler13:10:50

(first (drop-while nil? coll))

bensu13:10:27

a more obvious one would be (some some? colll) (which after reading @magnars looks wrong simple_smile )

jprudent13:10:33

@tyler thanks, thats better simple_smile

magnars13:10:36

(some identity coll)

jprudent13:10:06

@bensu: @magnars this won't pass the test unfortunatly

meikemertsch13:10:21

What's the test?

jprudent13:10:39

(is (= false (your-fn [nil false true]))))

meikemertsch13:10:14

Oh. Should've read that more closely, sorry

jprudent13:10:27

no problem simple_smile

meikemertsch13:10:07

I was immediately thinking of tyler's solution...

bensu13:10:08

ahh right, solutions using some will fail when there are false values

magnars13:10:25

I'm surprised (some some? coll) doesn't pass.

jprudent13:10:37

(some some? [nil false true]) => true

magnars13:10:07

Ah, some tricks me again - returning the result of calling the fun

jprudent13:10:28

yes, some is tricky !

jprudent13:10:43

thank you everyone

magnars13:10:17

Clojure lacks a proper "first" since it missed that nice name when dropping "car"

magnars13:10:16

Maybe first could take an optional predicate

meikemertsch13:10:36

Obviously you can also write (some #(not (nil? %)) coll) if that speaks more to you

magnars13:10:17

@meikemertsch: that falls into the same some trap, it needs to be (some #(when (some? %) %) coll)

magnars13:10:08

(first some? coll) would have been nice

jprudent13:10:31

some returns the first "truthy" value

jprudent13:10:29

we won't get anything from some for this one simple_smile

magnars13:10:43

wow, I've never wanted (first some? coll) more than after this revelation

meikemertsch13:10:41

Haha, I only make it worse by throwing in (first (map #(not (nil? %)) coll))

jaen14:10:25

@dnolen: I'm dreading that - I do not trust dynamic languages to refactor well and my understanding of the cljs compiler is really rudimentary (Cursive helps, but it's still quite complex to me). This will also make the surface of the patch bigger. But if I'll have to then well, I'll have to bite the bullet and do that, hopefully it won't hurt too mcuh. @thheller: basically taking what Maria Neise/Geller did (JS module conversion to GClosure modules), moving that from where it is right now to the dependency resolution stage and extending that to full libraries instead of single files. So basically - plumbing, but you have to fit into the existing piping, which I seem to have some problems with, not being fluent enough in the codebase.

thheller14:10:56

should make things a lot easier

thheller14:10:08

if you are interested I can give you some pointers on how to get started

jaen14:10:24

I'm not sure how it would help

thheller14:10:25

custom build steps was one of its goals 😉

jaen14:10:49

If Clojurescript compiler does not understand CommonJS modules as they are.

jaen14:10:15

Unless you mean one could plug babel.js as a custom build step and let cljs compiler take it from there?

thheller14:10:16

well, those don't need to go into the clojurescript compiler do they?

thheller14:10:27

yep exactly that

thheller14:10:45

documentation sucks

thheller14:10:07

but it does what you need in a much more accessible way than cljs.closure would

jaen14:10:40

Oh, interesting. Though I see it's lein-based and I kind of don't miss how messy is (or at least was) getting a nice clsj workflow with lein since I tried boot.

thheller14:10:42

the commonjs/es6 stuff is on my todo list

thheller14:10:05

if boot can call clojure, you don't need lein

jaen14:10:30

Hmmm, that's quite interesting if this could be done without patching the compiler (I mean, I guess it could be done, since my first spike didn't even touch compiler and it worked), but that would mean I've sunk quite a bit of time into something that's ultimately not really all that needed ; e

thheller14:10:11

@jaen do you have an example of a commonjs lib that should work?

thheller14:10:30

can probably import that pretty quickly

jaen14:10:01

I'll take a look at this sometime, though even then there might be some value for compiler to understand that anyway (though that depends on what other people though think).

thheller14:10:24

the compiler doesn't really need to understand any of it since the compiler is for compiling cljs

thheller14:10:51

you just need to teach it about the new kind of dependency

thheller14:10:05

since they basically do not have a "goog.provide"

jaen14:10:18

@thheller: my most complex example included React + material-ui + ReactMotion and all their dependencies. The less complex one was just React with modified reagent that could use it.

thheller14:10:47

are you sure that Closure can handle react without breaking it?

thheller14:10:12

last time I checked they have a pretty complex build setup

jaen14:10:14

If you mean advanced optimisations by that then no, I didn't get that far.

jaen14:10:19

Without opts it works no problem for the simple tests I did so far.

jaen14:10:49

Though I imagine it would have to be repackaged somewhat anyway.

thheller14:10:56

well advanced is what its all about 😉

jaen14:10:20

Yeah, I know, I wanted to get it working right first, then see what happens when I filp the advanced switch.

jaen14:10:12

@thheller: well, cljs compiler understands GClosure modules. Maria's work was about getting CJS/UJS/AMD translated to GClosure, so the compiler could understand them natively and that they could participate in GClosure optimisations and whatnot.

jaen14:10:32

So it's a bit different from what you propose if I understand that correctly.

jaen14:10:44

Though that's probably not the right channel to discuss the specifics of that besides the circular dependency problem, since that's the only thing strictly Clojure-related.

thheller14:10:35

you are too fixated on the cljs compiler

thheller14:10:57

you don't need any of that since you are not compiling cljs->js

thheller14:10:31

cljs.closure is about packaging things together so you can actually run things

thheller14:10:46

shadow-build is an alternate implementation to that

thheller14:10:59

to make things like you are trying easier

jaen14:10:47

Hmph, quite possibly. But then I could just use browserify and webpack as a build step called from boot, shove the results into :foreign-libs and call it a day. I tend to be prone to overengineering '

thheller14:10:30

well the real goal is advanced compilation

thheller14:10:37

and also the real challenge

thheller14:10:29

I really want to try to get react through that but I have very little hope

thheller14:10:00

do you maybe have an easier commonjs/es6 file to start with? simple_smile

thheller14:10:16

I haven't used any non-closure js/cljs in ages

jaen14:10:11

Hah, not really, no. This all started with me trying to get material-ui to work without an intermediate build step. And that needs React for better or worse.

thheller15:10:14

hehe the javascript generated by the conversion process is scary .. if that works at all I'd be amazed simple_smile

orther15:10:31

human-readable usually doesn't imply it is for consumption by an end user

orther15:10:04

whoops scrolled back in time

orther15:10:09

nm me 😄

bensu16:10:54

If I have a symbol foo.bar/sym and I want to get its name as a symbol, sym. Is there such a function, or must I use (symbol (name 'foo.bar/sym))?

wei17:10:23

any tips for restarting a jar if it exits? I usually use upstart, but upstart doesn’t properly detect when this app has exited (using expect fork)

nberger19:10:49

@wei : AFAIK the way to go is to use jsvc

edvorg20:10:10

Hi, guys, I wrote a demo project which might help newcomers understand, what’s going on in clojure web applications. It’s simple multiplayer starcraft clone using reagent, http-kit, core.async, chord, compojure and secretary. Check it out http://github.com/edvorg/yet-another-craft

wei20:10:21

@nberger thanks for the suggestion. also looking into capsule (lein-capsule) and wonder if anyone is using it

nberger20:10:47

Np. I don't know about capsule

tord21:10:39

Does anybody know how to express div.foo { display: flex; display: -webkit-flex; } with Garden? The straightforward translation [:div.foo {:display "flex" :display "-webkit-flex"}] obviously fails because of the duplicated map key.

tord21:10:52

I tried the super ugly workaround [:div.foo {:display "flex" "display" "-webkit-flex"}], getting rid of the duplicate key by using a string instead of a keyword the second time, but it still doesn't work, as the first key/value pair simply disappears in the output.

crucialrhyme23:10:24

I'm randomly generating instances of functions that have fixed parameters (a matrix, a vector, and a scalar). I'd like people to be able to call them like normal Clojure functions, but also look up the values of the parameters if necessary. Is having a record implement IFn like this https://gist.github.com/currymj/f26441cc01a8f3650e5f a terrible way to do it? Bad practice in general?