Fork me on GitHub
#clojure
<
2016-03-28
>
jimmy04:03:37

hi guys, is there any good way to find which function triggers current function in clojure ?

hiredman04:03:59

not really, you can get a stack trace, which contains jvm level method information, which is sort of a superset of clojure function stack, but it is all in terms of methods

hans04:03:30

nxqd: you can use a dynamic variable for that type of thing

hans04:03:53

nxqd: but if you're looking for a general solution, what hiredman says.

jimmy04:03:19

@hans: can you show me what would it be done by using dynamic variable ?

hans04:03:55

@nxqd: well, a dynamic variable is one that is bound to the stack, not to the lexical context. thus, if you bind a dynamic variable with identifying information in the caller, the callee can look at its value to determine who the caller was.

hans04:03:39

@nxqd: in general, though, using dynamic variables in clojure can be difficult if you're also using lazy sequences and/or threads, so maybe you want to look at a solution where you pass the context as parameter instead.

hans04:03:09

@nxqd: you really need to describe your problem more if you want specific help.

jimmy04:03:39

good point, I have problem regarding routing in (clojurescript), I find that my app is being routed unexpectedly, I'm trying to find which function has triggered the routing.

hans04:03:12

@nxqd: ah. then you're in the wrong channel simple_smile - maybe ask in #C03S1L9DN

hans04:03:52

@nxqd: javascript has stack introspection as well.

jimmy04:03:27

actually, I can see that the problem would be close. Since I can change printStacktrace to (.log js/console), I mean it would be the same in term of language

hans04:03:29

@nxqd: why not put a debugger statement into the handler and use the debugger to find out where you're coming from?

hans04:03:36

oops, i'm off-topic now...

jimmy04:03:53

yeah -_- ... why don't even think about it, rarely use debugger btw

jimmy04:03:31

no more off, I think I will try both debugger or send random exception to print stack trace. thanks for helping @hans @hiredman

kardan07:03:33

I have a “migrate” fn in user which I would like to fire off from a shell script. Is there a way to do something like "lein repl migrate”?

featalion07:03:21

@kardan: try something like lein run -m 'migration-namespace/migrate' production

featalion07:03:05

production is just an argument

danielcompton07:03:08

@kardan: you can also make a lein alias for @featalion's suggestion

danielcompton07:03:45

@kardan: not sure if you've looked at it, but ragtime is good for running/defining migrations

kardan07:03:05

Perfect, thanks!

kardan07:03:19

@danielcompton: I am using ragtime & agree it’s handy. I have a uncommon setup with multiple db’s per “tenant”/customers so need to do handle a lot of migrations...

danielcompton07:03:48

Huh, same use case here :)

danielcompton07:03:12

Oh wait only one db per tenant, but still...

ihercowitz10:03:59

@danielcompton im using migratus and migratus-lein on the projects I'm working... is ragtime better? if it is, why?

dominicm10:03:05

Joplin is pretty good (disclaimer, I work for Juxt)

dominicm10:03:24

It's based on Ragtime, but contains common patterns.

ihercowitz10:03:49

@dominicm joplin seems nice :) I'll take a look on it later :D

fommil10:03:04

does anybody want to fix some fundamental problems in the scala build tool for me so that I can write some clojure for fun today instead? /sigh/

niquola11:03:04

Hi, clojurians. I've got a problem with java.lang.ClassNotFoundException potemkin.LazyMapEntry elastish -> clj-http -> potemkin (clj 1.8.0)

niquola11:03:17

any hints?

dm311:03:28

@nicola - check version of potemkin that gets on your classpath. Does that version have the potemkin.LazyMapEntry defined?

dominicm11:03:39

probably worth doing a lein pedantic thingy / boot show -p to see if there are conflicts

niquola11:03:26

potemkin "0.4.1"

niquola11:03:43

same with 0.4.3

java.lang.NoClassDefFoundError: potemkin/LazyMapEntry
        at clj_http.headers.HeaderMap$fn__8770.invoke(headers.clj:90)

dm311:03:26

I can see that LazyMapEntry was last present on 0.3.12

niquola11:03:35

It looks it was deleted from 0.4

niquola11:03:14

I've updated clj-http to last version it uses potemkin 0.4.3, but got same error 😞

niwinz11:03:50

try to exclude potemkin from all posible dependencies that are using it

niwinz11:03:00

and put it explicitly on your :dependencies

niwinz11:03:10

also, clean the target directory

dominicm11:03:35

@nicola: You need to figure out what else is depending on potemkin. Leiningen has a command for this.

niwinz11:03:19

lein deps :tree

niquola11:03:40

Here is just a couple of deps - latest riemann and elastish

niquola11:03:13

lein deps :tree without conflicts

dominicm11:03:35

The resolved version of potemkin, is going to vary based on your dependencies. Adding :pedantic? :warn should tell you what is being resolved, and give you clear information on what is actually being resolved.

niquola11:03:28

@dominicm: where to add pedantic and warn?

dominicm11:03:42

@nicola: to your project.clj

niquola12:03:28

Done. No warns, no conflicts, no suggestions

niquola12:03:03

lein deps :tree | grep potemkin
 [potemkin "0.4.3"]

niquola12:03:28

lein deps :tree | grep clj-http
 [clj-http "2.1.0"]

dm312:03:23

try running mvn dependency:tree -Dverbose on the project's pom

dm312:03:07

I believe it's more complete than lein deps

dominicm12:03:28

oh wow, you've really run into an edge case here.

niquola12:03:16

~/bin/mvn/bin/mvn dependency:tree -Dverbose | grep clj-http           
[INFO] +- clj-http:clj-http:jar:2.1.0:compile
[INFO] |  +- (clj-http:clj-http:jar:2.0.0:compile - omitted for conflict with 2.1.0)
[INFO] |  +- (clj-http:clj-http:jar:1.1.2:compile - omitted for conflict with 2.1.0)
[INFO] |  |  +- (clj-http:clj-http:jar:0.9.1:compile - omitted for conflict with 2.1.0)
[INFO] |     +- (clj-http:clj-http:jar:0.9.1:compile - omitted for conflict with 2.1.0)

niquola12:03:39

last three in riemann

niquola12:03:44

second in elastish

dominicm12:03:54

Interesting.

niquola12:03:11

`2. Unhandled clojure.lang.Compiler$CompilerException                                                                                                           
   Error compiling clj_http/headers.clj at (91:10)                                                                                                             
                                                                                                                                                               
1. Caused by java.lang.ClassNotFoundException                                                                                                                  
   potemkin.LazyMapEntry     

niquola12:03:10

Unhandled clojure.lang.Compiler$CompilerException                                                                                                           
   Error compiling /root/.m2/repository/clj-http/clj-http/2.0.0/clj-http-2.0.0.jar:clj_http/headers.clj at (91:10)                                             
                                                                                                                                                               
1. Caused by java.lang.ClassNotFoundException                                                                                                                  
   potemkin.LazyMapEntry  

niquola12:03:59

I suspect potemkin/def-map-type , which is macro producing => (deftype+ ~name ~params ~'potemkin.collections/AbstractMap

dm312:03:25

problem is you have clj-http:2.0.0 on the classpath

dm312:03:35

even though dependency tree says 2.1.0

niquola12:03:50

i've downgraded to elastish version

dm312:03:08

then you need to downgrade all potemkin to 0.3.12

niquola12:03:27

so clj-http 2.0.0 uses potemkin 0.4.1

niquola12:03:45

My intuition say, that black magic with deftype is the reason

dm312:03:26

the reason is a reference to potemkin.LazyMapEntry is present when compiling clj-http.headers (91:10)

dm312:03:53

but how this happens simple_smile

dm313:03:14

it could happen if something was AOT-compiled with potemkin pre 0.4 version

dm313:03:20

and included in your classpath

dm313:03:16

assuming your classpath now only contains 0.4.1

niquola13:03:23

i've cloned riemann and executed this code inside riemann - it works 😞 Looks like problem with riemann jar.

lvh19:03:55

syntax-quote isn’t available within clojure core as regular macro, right? I’m generating some lists that want auto-gensymd stuff

lvh19:03:02

I can work around it of course simple_smile

hiredman19:03:10

there are some libraries people have written for that

7h3kk1d21:03:52

What’s the de facto coverage tool for clojure? and does it support branch coverage?

hiredman21:03:39

I don't know that there is one, they certainly exist, but I doubt usage of any of them is above any kind of reasonable threshold you might want before considering something for de facto status

danielcompton22:03:26

@7h3kk1d: there’s cloverage, which is ok, but I wouldn’t break the build over it’s coverage results

jtackett22:03:15

anyone know how to to “\"

jtackett22:03:21

a backslash string?

jtackett22:03:31

since the backslash is an escape character

cky22:03:50

”\\”

cky22:03:57

(count “\\”) => 1

hiredman22:03:42

if that doesn't work, then something sitting between you and the clojure reader is messing with you

jtackett22:03:10

ah that’s right

hiredman22:03:14

if your question is actually about regexes and not strings, the answer is you keep adding \ characters until the read stops yelling at you

jtackett22:03:16

error was in a different string

cky22:03:45

@hiredman: .oO(It’s easy to edit old messages; just press the up arrow!)

matthavener22:03:05

hiredman: hehe, writing regexs is always an exercise in typing \\\

shriphani23:03:51

hi everyone. I have a record defined in a project. I’ve required the ns in lein but I can’t seem to import the record class. Any ideas what I am doing wrong ?