#clojure log - Jun 23 2015

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

3:29 yeahnoob: clojurebot: (/ 16 8)

3:29 clojurebot: Excuse me?

3:29 namra: .(/ 16 8)

3:30 ,(/ 16 8)

3:30 clojurebot: 2

3:30 yeahnoob: clojurebot: ,(/ 16 8)

3:30 clojurebot: excusez-moi

3:30 yeahnoob: ...

3:30 ,(/ 22 11)

3:30 clojurebot: 2

3:30 yeahnoob: ,(/ 16 08)

3:30 clojurebot: #<NumberFormatException java.lang.NumberFormatException: Invalid number: 08>

3:31 yeahnoob: "08" cannot be accepted...

3:31 oddcully: ,(/ 14 07)

3:31 clojurebot: 2

3:32 yeahnoob: ,(24 06)

3:32 clojurebot: #error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval119 invoke "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval119 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler eval "Compiler.java" 6792]\n [clojure.lang.Compiler eval "Compiler.java" 6755]\n ...

3:32 yeahnoob: ,(/ 24 06)

3:32 clojurebot: 4

3:32 yeahnoob: ,(/ 16 08)

3:32 clojurebot: #<NumberFormatException java.lang.NumberFormatException: Invalid number: 08>

3:32 oddcully: ,0666

3:32 clojurebot: 438

3:34 yeahnoob: ,01234567

3:34 clojurebot: 342391

4:51 zot: i've got hundreds of generated tests, which all have IDs (for reproduceability) — in clojure.test, i can use the testing macro with a string version of the ID, and trivially reproduce a single broken instance. anybody know of a way to get this same thing in midje?

4:51 (the clojure.test + cider image of what i love: http://imgur.com/aV5SEaG )

5:03 strika: Hello. Is there anyone visiting EuroClojure tomorrow? Is there an official meetup on Wednesday?

5:06 Glenjamin: i've not seen anything official for wednesday

6:04 luxbock: is there some way to tell leiningen to run a command without using my profiles.clj?

6:07 `with-profile system` seems to work

7:35 justin_smith: zot: why use midje?

7:35 zot: justin_smith: not my choice, in this instance :)

7:35 i've used this as an example for considering clojure.test as the default, but am still curious if the same can be achieved w/ midje

8:41 ambrosebs: ,(bigint "3")

8:41 clojurebot: 3N

9:30 TimMc: zot: I'm a little unclear -- you're looking to run just specific tests in your test base?

9:31 zot: no, i have that already w/ the midje mode in emacs. i have a generator, creating a sequence of >1k tests, each having a fingerprint. w/ clojure.test, i just use the fingerprint in the (testing …) macro, and then when one fails, I see the fingerprint, and use the generator function to manually test that single failing instance in the repl. w/ midje, i haven't figured out how to dynamically bind the fingerprint to the testing metadata such tha

9:32 if you look at the img I attached, you see the '2 3 2' associated w/ a failure — that's teh fingerprint. w/ midje, i get no such thing (so far).

9:40 TimMc: zot: First message cut off at "testing metadata such tha"

9:40 zot: TimMc: w/ midje, i haven't figured out how to dynamically bind the fingerprint to the testing metadata such that the reported error (on screen) shows the fingerprint.

9:41 TimMc: You can generate (facts "foo" a => 1) forms and have "foo" print out, right?

9:42 zot: that's pretty much what I tried, thinking it would work: FAIL "random-filter-equivalence - label" at (form-init5066430655470145035.clj:11)

9:43 label doesn't get treated as a local variable, but the macro just uses it as a string

9:43 maybe there's some other magic to get it handled differently

9:43 TimMc: What does your macro look like?

9:44 zot: (let [label (str "test #" x y z)] (fact label …do-stuff…))

9:45 TimMc: Oh I see... you're not building fact forms using a macro. This is a fn.

9:45 zot: correct.

9:45 TimMc: I didn't realize clojure.test/testing accepted non-literals.

9:45 zot: me neither. but it was a pleasant surprise :)

9:46 TimMc: I think you'd have to switch to a macro. Not the worst use for one, even though it would be nice to not have to.

9:46 Alternatively, there might be some midje internal you can rebind... :-P

9:46 zot: yeah, i'm reading the midje code now, and see where it's happening.

9:46 for the time being, i just switch back to the clojure.test form when needed.

9:55 mucking w/ :midje/name may be above my clojure-fu — since midje executes tests at eval time, i don't see how i can modify the metadata before it actually gets executed.

9:57 TimMc: zot: There's nothing you can use binding on?

9:59 zot: perhaps i just need to understand metadata better - never really had to muck w/ it. i found only with-meta.

9:59 correction, found vary-meta. i'll try.

10:00 TimMc: There's this *fact-context* thing... eh, it's not always going to be applicable.

10:01 I'd just go with a macro if you want to use midje. The internals are going to change out from under you.

10:03 zot: yeah, that's what i figured. plus the vary thing doesn't just work, as i guessed. but that just might be me.

10:03 bingo: https://github.com/marick/Midje/wiki/Metadata {:midje/name label} works.

10:04 TimMc: thanks for the co-think :)

10:05 TimMc: Oh neat, so it does support non-literals?

10:08 zot: yeah, check that link — all this talk of metadata just made me google midje metadata, and bam! there it is. stick in whatever you want.

10:13 ambrosebs: ,(Math/pow 1.1)

10:14 clojurebot: #error {\n :cause "No matching method: pow"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: No matching method: pow, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.IllegalArgumentException\n :message "No matching method: pow"\n :at [clojure.lang.Compiler$StaticMethod...

10:14 ambrosebs: ,(let [^double a 1.1] (Math/pow a))

10:14 clojurebot: #error {\n :cause "Can't type hint a local with a primitive initializer"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.UnsupportedOperationException: Can't type hint a local with a primitive initializer, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.UnsupportedOperationException\n :message "...

10:14 ambrosebs: ,(let [^Double a 1.1] (Math/pow a))

10:14 clojurebot: #error {\n :cause "Can't type hint a local with a primitive initializer"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.UnsupportedOperationException: Can't type hint a local with a primitive initializer, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.UnsupportedOperationException\n :message "...

10:22 justin_smith: ,(Math/pow 2.0 42.0)

10:22 clojurebot: 4.398046511104E12

10:22 zot: (inc TimMc)

10:22 justin_smith: ambrosebs: was the hinting about trying to make that method work, or was I interpreting it wrong?

10:25 ambrosebs: justin_smith: just playing around with something, don't mind me :) thanks tho

10:25 I wanted to know if Clojure automatically coerced ints to doubles when the method calls for it

10:25 of course I then I realised that 1.1 is a double.

10:26 justin_smith: ah, hha

10:26 iirc even longs are coerced to ints as apropriate

10:26 ,(Math/pow 2 42) ; coercion?

10:27 clojurebot: 4.398046511104E12

10:27 justin_smith: yeah, that just implicitly turned long / long into double / double

10:28 ambrosebs: huh

10:28 is there reflection here?

10:28 justin_smith: no idea! but as you can see here, pow is only defined for double/double http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html

10:29 ambrosebs: ,(set! *warn-on-reflection* true)

10:29 clojurebot: #error {\n :cause "Can't change/establish root binding of: *warn-on-reflection* with set"\n :via\n [{:type java.lang.IllegalStateException\n :message "Can't change/establish root binding of: *warn-on-reflection* with set"\n :at [clojure.lang.Var set "Var.java" 221]}]\n :trace\n [[clojure.lang.Var set "Var.java" 221]\n [sandbox$eval49 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval ...

10:29 ambrosebs: huh wow no reflection.

10:30 yea I need to reevaluate how I type java methods in core.typed.

10:30 Glenjamin: is it a java thing?

10:30 justin_smith: yeah, I just saw that in my own repl, fascinating

10:30 Glenjamin: does Math.pow(1, 2); work in java?

10:30 ambrosebs: I doubt it.

10:30 justin_smith: Glenjamin: oh, good question - maybe the vm implicitly converts?

10:30 ambrosebs: but great question :)

10:30 puredanger: it does

10:30 justin_smith: maybe puredanger has some insight?

10:31 ambrosebs: puredanger: thanks

10:31 * justin_smith is just *this* slow.

10:31 justin_smith: (inc puredanger)

10:31 shantipants: Math.pow is only defined for (double, double)

10:31 puredanger: look up numeric promotion in the JLS

10:31 https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.6

10:32 shantipants: closest thing to what you want is biginteger

10:33 justin_smith: shantipants: we were exploring some questions about type coercion

10:34 puredanger: in general, you should expect widening primitive promotions to occur automatically

10:35 ambrosebs: and I guess the Clojure Reflector knows all about this.

10:35 puredanger: in some very specific cases, narrowing primitive coercions are allowed too

10:35 ambrosebs: for resolving methods.

10:35 puredanger: I'd have to read some code to answer that fully :)

10:36 I think it probably leans on methods in the Java reflection API like isAssignableFrom()

10:39 ambrosebs: mm (Math/pow 2 3) doesn't type check in core.typed.

10:40 puredanger: look at stuff like Reflector.paramArgTypeMatch()

10:40 ambrosebs: it's unclear whether to extend the subtyping algorithm so Long and Double are freely exchangable, or just assign java methods more permissive types.

10:40 puredanger: thx

10:44 kwladyka: https://www.refheap.com/104388 - to what can i need "this" in defprotocol?

10:46 justin_smith: kwladyka: for example, you may call a method inside your method, you need this in order to do that

10:47 kwladyka: something like (this another-protocol-method ...)?

10:48 justin_smith: kwladyka: (another-method this other args)

10:48 or (.nativeMethod this)

10:48 kwladyka: yes, my mistake

10:48 justin_smith: kwladyka: also, I think your line 12 is wrong

10:48 kwladyka: I run the same code, and as expected, on line 12, it returns the reified object, not 1

10:49 kwladyka: yes, it is example from doc modified by me

10:49 i didn't change comments

10:49 sorry for misrepresentation

10:50 justin_smith: np, I was just confused for a moment (feared I forgot how reify works)

10:54 kwladyka: https://www.refheap.com/104390 - what if wrong with that? why this error?

10:54 justin_smith: kwladyka: same mistake you did before - the function is create-user

10:55 cahnge line 8 to (create-user user-db {...})

10:55 kwladyka: ech... :)

10:56 justin_smith: kwladyka: clojure is topsy-turvy compared to normal OO - we literally put methods before objects :P

10:57 kwladyka: [this {:keys [email password]}] - this have to be always the same in protocol and in reify? if yes so what is the point to repeat that?

11:00 justin_smith: kwladyka: because it is always an arg, but sometimes there is reason to give it a different name

11:00 kwladyka: ok thx

11:00 justin_smith: like "_" to emphasize you are not using it, or "component" if using stuartsierra/component and it is used as a hash-map to carry your data dependencies

11:03 kwladyka: https://www.refheap.com/104391 - why am i getting so many warnings?

11:05 the way which i try to do is good way to do http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html ? i am asking about code exactly

11:05 and idea of using this code

11:07 justin_smith: kwladyka: something must be wrong with your setup, I can run that code in cljs without any errors or warnings

11:09 kwladyka: it's weird that you have destructuring in your UserDb definition

11:09 (in the protocols that is)

11:09 you can't enforce that those keys are present or used at the protocol level, so even if it compiles it's totally misleading

11:10 kwladyka: justin_smith, so i should use :keys?

11:10 *shouldnt

11:11 justin_smith: no, not in the protocol definition - just use a normal arg, no destructuring

11:13 kwladyka: if i change this idea and code is good? or i should use it in another way?

11:13 justin_smith: kwladyka: your code had a different issue for me (no warnings, but calling the methods on the reified object did not return the expected value, just nil)

11:13 kwladyka: changing the protocol definition to not contain destructuring fixed this issue

11:14 kwladyka: huh... after 3 months i am on this stage :)

11:18 justin_smith: $mail mindbender1 with the latest cljs (ns ... (:import (goog History))) works


11:40 kawzeg: Hey, does anyone have a recommendation for a podcast on Clojure?

11:47 puredanger: The Cognicast often has Clojure topics. http://blog.cognitect.com/cognicast/

11:48 seangrove: ,float?

11:48 clojurebot: #object[clojure.core$float_QMARK_ 0x52655fa7 "clojure.core$float_QMARK_@52655fa7"]

12:30 sm0ke: hate slow clojure aot compilation much? please upvote http://dev.clojure.org/jira/browse/CLJ-322

12:32 Bronsa: sm0ke: that's not really about compilation speed

12:33 sm0ke: yea right, but its the major cause of aot builds taking too much time

12:34 would love to see it in 1.7 RC

12:34 Bronsa: not gonna happen

12:34 sm0ke: WHAT :(

12:34 puredanger: no, not gonna happen

12:34 sm0ke: sad

12:34 Bronsa: sm0ke: read the last few comments

12:34 puredanger: 1.7 is effectively done barring something urgent

12:35 CLJ-322 does not have a consensus approach for a solution so is not ready to go in anyways

12:36 but I would like to find that for the next release

12:36 sm0ke: hurmm 1.8 would its own seet time

12:36 would take8

12:38 anyways voting would give it some importance i guess, afterall core devs look into what people are most interested in too

12:39 so is the new cljc support would be baked in clojure core itself? build tools like lein and boot dont need any changes?

12:40 TimMc: sm0ke: I think someone said something about 1.8 being planned as a smaller release. I don't know if that increases or decreases the chances of CLJ-322 getting fixed soon.

12:41 sm0ke: thats good news if true

12:42 but next release has quite a few things going as well http://dev.clojure.org/display/design/Release.Next+Planning

12:42 not sure if its going to be quicker

12:43 Bronsa: sm0ke: that's not really reflective of what's going to be in 1.8

12:43 sm0ke: lean runtime sound ambitious in a small timeframe, given the diligience with which patches are pulled

12:43 Bronsa: sm0ke: i.e. lean runtme has been in release.next since 1.3. that's just a list of what will probably be considered for a next release IUC

12:44 puredanger might correct me if I'm wrong

12:44 sm0ke: would there be chances of a 1.7.x release pulling it?

12:45 or the last x is only for bug fixes

12:46 puredanger: that page is indicative of things to be considered for 1.8

12:46 there has not yet been a discussion about what will or will not be in it

12:46 or timeframe

12:47 I certainly have my own thoughts and preferences but obviously Rich's inputs are the deciding factor

12:48 the idea of a 1.7.x is an option but I think it would be highly unlikely that (for example) CLJ-322 would be included in a .x release rather than a .0.

12:50 sm0ke: cljc support is in clojure and clojurescript now. tools are in the process of being updated and are mostly there already.

12:51 sm0ke: nice! have not really tried cljx either, but its a welcome change in the core

13:02 Pupeno: I'm trying to use environ to get the database-url but ragtime requires it to be configured in project.clj and if I try to do (require [environ.core :refer [env]]) in project.clj, I get the error: Caused by: java.lang.ClassNotFoundException: environ.core. What's the right way to approach this?

13:03 TimMc: Chicken and egg, there. I wouldn't expect the project.clj file to have access to the libraries it specifies.

13:04 * Pupeno groans.

13:05 Pupeno: Does it mean that every project out there using ragtime has custom code and/or production credentials in their repo?

13:05 justin_smith: also, this must mean that ragtime can't run from an uberjar, it can only be run under lein?

13:05 hiredman: Pupeno: that is not how require works

13:05 ,(doc require)

13:05 clojurebot: "([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents...

13:05 justin_smith: Pupeno: if so, that sounds like a design failure in ragtime

13:05 Pupeno: justin_smith: that's way more than I know, but I haven't witness it running in any other way.

13:05 hiredman: it is a function, its arguments are evaluated

13:06 Pupeno: justin_smith: there's two components to ragtime, one is ragtime itself and the other one is the lein plugin.

13:07 justin_smith: Pupeno: so perhaps the more resilient option is to build code that invokes ragtime, that checks for and conditionally runs migrations at startup of the app, using the app's db config?

13:07 Pupeno: hiredman: I'm sorry, I'm new to Clojure, I took that require line out of the environ documentation, what am I doing wrong?

13:07 hiredman: Pupeno: I would read the documentation agian

13:07 again

13:07 Pupeno: justin_smith: not sure about running automatically at start, but other than that I would tend to agree. I'm surprised in that it seems I'm the first one to run into it.

13:08 hiredman: https://github.com/weavejester/environ#example-usage

13:08 binjured: Pupeno: yeah, what justin_smith said. you can use ragtime w/o lein but you'll need to call the functions yourself during app startup. which feels dangerous since database migration is not generally something you want to happen automatically in the background

13:08 hiredman: the line there is clearly different form the one you pasted

13:08 justin_smith: binjured: of course the alternative is to have an optional command line arg that invokes migration behvaior

13:08 binjured: sure

13:09 justin_smith: but tying a migration tool to lein sucks, because that forces all your environments to accomodate lein

13:10 and many of us don't want lein to be part of staging or production environments, only using it as a build tool

13:10 Pupeno: hiredman: a quote was lost in the copying and pasting. odd. still doesn't work though.

13:10 Are any of the other migration tools any better?

13:11 binjured: justin_smith: well, you don't need lein in those environments, you just need lein in an environment that has DB-level access to them.

13:11 justin_smith: binjured: sure, that's fair

13:11 Pupeno: The error with the proper line is Caused by: clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could not locate environ/core__init.class or environ/core.clj on classpath: , compiling:(/Users/pupeno/Temporary/foobar/project.clj:1:1)

13:12 justin_smith: I'm actually guilty of working on a migration tool that had a 100% lein based workflow

13:12 and I would not do it that way the next time

13:12 binjured: the general sentiment of "X should not depend on lein" seems sound to me :)

13:13 justin_smith: glad I'm not alone

13:14 Pupeno: I don't know if the core of ragtime is good or not yet, but let's see if I can wire this so this tool doesn't require me exposing my database credentials.

13:15 I could just take a parameter that makes my app run migrations and quit, so my app is run in that mode after deployment, once, before being run in the normal mode, correct?

13:16 justin_smith: Pupeno: if your DB creds are in an environment variable, you can ensure that both environ and your project.clj get the thing from the same variable. It's ugly (doing the same task twice), but it should work, and wouldn't require passwords in the git repo ~(System/getenv "DB_CONNECTION_CREDS")

13:16 that thing with the ~ above will work inside project.clj

13:16 and environ would see the same data, under :db-connection-creds

13:18 Pupeno: justin_smith: environ does more that take data from an environment variable, it also can take defaults from the project.clj as well as a .lein-env file, which makes it possible to easily separate development/testing/production enivornments. Without environ I would end up replicating environ in inline code inside project.clj. There's also the issue that Heroku, for example, provides an environment variable that needs some

13:18 processing and I'm not sure where that code should live to be available inside a project.clj and inside the app for the app's connection.

13:19 justin_smith: Pupeno: OK

13:20 Pupeno: it would be a hack to directly use the env var, of course, and it's harder to do it right on something like heroku where you don't control your runtime environment (I had wrongly assumed a more generic cheaper vps)

13:20 Pupeno: justin_smith: does it make sense? feel free to challenge me, I'm not new to Lisp, but I'm new to Clojure, so I may be making the wrong assumptions here.

13:21 justin_smith: well, right now my plan is to do this: get it working somewhat cleanly for both, heroku and other places, and then ask in the luminus mailing list if this is something that should be integrated into their template.

13:22 I'm evaluating Clojure for my company and I care about this boring details as maintaining good security, production environments, testing, etc.

13:23 binjured: Pupeno: you can control how Heroku runs your app. just use System/getProperty and make your db cred API something like `-Ddb-name=...` and write a little shell script that parses heroku's provided envvar for db creds. provide default values in project.clj or wherever for when you're running locally and don't need to keep creds secret.

13:23 irctc: Hey all; just wanted to announce a new open source release - it's a leiningen plugin that searches your codebase for unused code. The repository can be found here https://github.com/venantius/yagni and I've put together a little blog post explaining how it works that can be found here http://blog.venanti.us/yagni/. I'll be around for questions if anyone's curious.

13:25 binjured: Pupeno: that pretty handily takes care of the implementation divide between heroku and somewhere else, and makes the creds really easy to override for an entire java process at runtime.

13:25 Pupeno: binjured: that sounds like a neat workaround, thanks.

13:26 binjured: and fwiw, i use ragtime and have been happy with it (luminus inline credentials aside)

13:27 Pupeno: binjured: that's good to know :)

13:27 binjured: are you also using yesql?

13:27 binjured: yep

13:27 Pupeno: Are you happy with it too?

13:29 binjured: yeah. it has some issues with figuring out what is and isn't a parameter due to the simplicity of its parser which, depending your DB and schema complexity, may require writing functions to avoid using the wrong tokens in a query.

13:30 but it still beats an orm or dsl so, ya know, trade-offs.

13:31 Pupeno: specifically: https://github.com/krisajenkins/yesql/issues/93

13:32 Pupeno: Is this specific to json?

13:33 binjured: yeah. and postgres. it's not something you're going to run into very often.

13:33 Pupeno: I do plan on storing hashes and arrays in postgresql.

13:43 binjured: Pupeno: hstore has a different api, as does json vs jsonb, but if you end up using '?' make note of the workaround

13:44 Pupeno: binjured: I'll keep it in mind. Thank you :)

13:49 Seylerius: Opinions on a favorite web scraping clojure library?

13:51 _kardan: Anyone got experience custom tags in Selmer? I’m trying to feed a template variable into a new custom tag {% new-tag var %}. I made sure the var hold the value by {{ var}} in the template and also tried (var :var {var} {{var}} ) inside the {% %}. Am I missing something obvious?

13:52 TimMc: irctc: Good name. :-)

Logging service provided by n01se.net