#clojure logs

2015-06-23

03:29yeahnoobclojurebot: (/ 16 8)
03:29clojurebotExcuse me?
03:29namra.(/ 16 8)
03:30namra,(/ 16 8)
03:30clojurebot2
03:30yeahnoobclojurebot: ,(/ 16 8)
03:30clojurebotexcusez-moi
03:30yeahnoob...
03:30yeahnoob,(/ 22 11)
03:30clojurebot2
03:30yeahnoob,(/ 16 08)
03:30clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 08>
03:31yeahnoob"08" cannot be accepted...
03:31oddcully,(/ 14 07)
03:31clojurebot2
03:32yeahnoob,(24 06)
03:32clojurebot#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 ...
03:32yeahnoob,(/ 24 06)
03:32clojurebot4
03:32yeahnoob,(/ 16 08)
03:32clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 08>
03:32oddcully,0666
03:32clojurebot438
03:34yeahnoob,01234567
03:34clojurebot342391
04:51zoti'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?
04:51zot(the clojure.test + cider image of what i love: http://imgur.com/aV5SEaG )
05:03strikaHello. Is there anyone visiting EuroClojure tomorrow? Is there an official meetup on Wednesday?
05:06Glenjamini've not seen anything official for wednesday
06:04luxbockis there some way to tell leiningen to run a command without using my profiles.clj?
06:07luxbock`with-profile system` seems to work
07:35justin_smithzot: why use midje?
07:35zotjustin_smith: not my choice, in this instance :)
07:35zoti'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
08:41ambrosebs,(bigint "3")
08:41clojurebot3N
09:30TimMczot: I'm a little unclear -- you're looking to run just specific tests in your test base?
09:31zotno, 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
09:32zotif 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).
09:40TimMczot: First message cut off at "testing metadata such tha"
09:40zotTimMc: 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.
09:41TimMcYou can generate (facts "foo" a => 1) forms and have "foo" print out, right?
09:42zotthat's pretty much what I tried, thinking it would work: FAIL "random-filter-equivalence - label" at (form-init5066430655470145035.clj:11)
09:43zotlabel doesn't get treated as a local variable, but the macro just uses it as a string
09:43zotmaybe there's some other magic to get it handled differently
09:43TimMcWhat does your macro look like?
09:44zot(let [label (str "test #" x y z)] (fact label …do-stuff…))
09:45TimMcOh I see... you're not building fact forms using a macro. This is a fn.
09:45zotcorrect.
09:45TimMcI didn't realize clojure.test/testing accepted non-literals.
09:45zotme neither. but it was a pleasant surprise :)
09:46TimMcI 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.
09:46TimMcAlternatively, there might be some midje internal you can rebind... :-P
09:46zotyeah, i'm reading the midje code now, and see where it's happening.
09:46zotfor the time being, i just switch back to the clojure.test form when needed.
09:55zotmucking 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.
09:57TimMczot: There's nothing you can use binding on?
09:59zotperhaps i just need to understand metadata better - never really had to muck w/ it. i found only with-meta.
09:59zotcorrection, found vary-meta. i'll try.
10:00TimMcThere's this *fact-context* thing... eh, it's not always going to be applicable.
10:01TimMcI'd just go with a macro if you want to use midje. The internals are going to change out from under you.
10:03zotyeah, that's what i figured. plus the vary thing doesn't just work, as i guessed. but that just might be me.
10:03zotbingo: https://github.com/marick/Midje/wiki/Metadata {:midje/name label} works.
10:04zotTimMc: thanks for the co-think :)
10:05TimMcOh neat, so it does support non-literals?
10:08zotyeah, 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:13ambrosebs,(Math/pow 1.1)
10:14clojurebot#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:14ambrosebs,(let [^double a 1.1] (Math/pow a))
10:14clojurebot#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:14ambrosebs,(let [^Double a 1.1] (Math/pow a))
10:14clojurebot#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:22justin_smith,(Math/pow 2.0 42.0)
10:22clojurebot4.398046511104E12
10:22zot(inc TimMc)
10:22justin_smithambrosebs: was the hinting about trying to make that method work, or was I interpreting it wrong?
10:25ambrosebsjustin_smith: just playing around with something, don't mind me :) thanks tho
10:25ambrosebsI wanted to know if Clojure automatically coerced ints to doubles when the method calls for it
10:25ambrosebsof course I then I realised that 1.1 is a double.
10:26justin_smithah, hha
10:26justin_smithiirc even longs are coerced to ints as apropriate
10:26justin_smith,(Math/pow 2 42) ; coercion?
10:27clojurebot4.398046511104E12
10:27justin_smithyeah, that just implicitly turned long / long into double / double
10:28ambrosebshuh
10:28ambrosebsis there reflection here?
10:28justin_smithno 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:29ambrosebs,(set! *warn-on-reflection* true)
10:29clojurebot#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:29ambrosebshuh wow no reflection.
10:30ambrosebsyea I need to reevaluate how I type java methods in core.typed.
10:30Glenjaminis it a java thing?
10:30justin_smithyeah, I just saw that in my own repl, fascinating
10:30Glenjamindoes Math.pow(1, 2); work in java?
10:30ambrosebsI doubt it.
10:30justin_smithGlenjamin: oh, good question - maybe the vm implicitly converts?
10:30ambrosebsbut great question :)
10:30puredangerit does
10:30justin_smithmaybe puredanger has some insight?
10:31ambrosebspuredanger: thanks
10:31justin_smith(inc puredanger)
10:31shantipantsMath.pow is only defined for (double, double)
10:31puredangerlook up numeric promotion in the JLS
10:31puredangerhttps://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.6
10:32shantipantsclosest thing to what you want is biginteger
10:33justin_smithshantipants: we were exploring some questions about type coercion
10:34puredangerin general, you should expect widening primitive promotions to occur automatically
10:35ambrosebsand I guess the Clojure Reflector knows all about this.
10:35puredangerin some very specific cases, narrowing primitive coercions are allowed too
10:35ambrosebsfor resolving methods.
10:35puredangerI'd have to read some code to answer that fully :)
10:36puredangerI think it probably leans on methods in the Java reflection API like isAssignableFrom()
10:39ambrosebsmm (Math/pow 2 3) doesn't type check in core.typed.
10:40puredangerlook at stuff like Reflector.paramArgTypeMatch()
10:40ambrosebsit's unclear whether to extend the subtyping algorithm so Long and Double are freely exchangable, or just assign java methods more permissive types.
10:40ambrosebspuredanger: thx
10:44kwladykahttps://www.refheap.com/104388 - to what can i need "this" in defprotocol?
10:46justin_smithkwladyka: for example, you may call a method inside your method, you need this in order to do that
10:47kwladykasomething like (this another-protocol-method ...)?
10:48justin_smithkwladyka: (another-method this other args)
10:48justin_smithor (.nativeMethod this)
10:48kwladykayes, my mistake
10:48justin_smithkwladyka: also, I think your line 12 is wrong
10:48justin_smithkwladyka: I run the same code, and as expected, on line 12, it returns the reified object, not 1
10:49kwladykayes, it is example from doc modified by me
10:49kwladykai didn't change comments
10:49kwladykasorry for misrepresentation
10:50justin_smithnp, I was just confused for a moment (feared I forgot how reify works)
10:54kwladykahttps://www.refheap.com/104390 - what if wrong with that? why this error?
10:54justin_smithkwladyka: same mistake you did before - the function is create-user
10:55justin_smithcahnge line 8 to (create-user user-db {...})
10:55kwladykaech... :)
10:56justin_smithkwladyka: clojure is topsy-turvy compared to normal OO - we literally put methods before objects :P
10:57kwladyka[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:00justin_smithkwladyka: because it is always an arg, but sometimes there is reason to give it a different name
11:00kwladykaok thx
11:00justin_smithlike "_" 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:03kwladykahttps://www.refheap.com/104391 - why am i getting so many warnings?
11:05kwladykathe 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:05kwladykaand idea of using this code
11:07justin_smithkwladyka: something must be wrong with your setup, I can run that code in cljs without any errors or warnings
11:09justin_smithkwladyka: it's weird that you have destructuring in your UserDb definition
11:09justin_smith(in the protocols that is)
11:09justin_smithyou can't enforce that those keys are present or used at the protocol level, so even if it compiles it's totally misleading
11:10kwladykajustin_smith, so i should use :keys?
11:10kwladyka*shouldnt
11:11justin_smithno, not in the protocol definition - just use a normal arg, no destructuring
11:13kwladykaif i change this idea and code is good? or i should use it in another way?
11:13justin_smithkwladyka: 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:13justin_smithkwladyka: changing the protocol definition to not contain destructuring fixed this issue
11:14kwladykahuh... after 3 months i am on this stage :)
11:18justin_smith$mail mindbender1 with the latest cljs (ns ... (:import (goog History))) works
11:18justin_smithLAZYBOT WHY HAVE YOU FORSAKEN US!
11:40kawzegHey, does anyone have a recommendation for a podcast on Clojure?
11:47puredangerThe Cognicast often has Clojure topics. http://blog.cognitect.com/cognicast/
11:48seangrove,float?
11:48clojurebot#object[clojure.core$float_QMARK_ 0x52655fa7 "clojure.core$float_QMARK_@52655fa7"]
12:30sm0kehate slow clojure aot compilation much? please upvote http://dev.clojure.org/jira/browse/CLJ-322
12:32Bronsasm0ke: that's not really about compilation speed
12:33sm0keyea right, but its the major cause of aot builds taking too much time
12:34sm0kewould love to see it in 1.7 RC
12:34Bronsanot gonna happen
12:34sm0keWHAT :(
12:34puredangerno, not gonna happen
12:34sm0kesad
12:34Bronsasm0ke: read the last few comments
12:34puredanger1.7 is effectively done barring something urgent
12:35puredangerCLJ-322 does not have a consensus approach for a solution so is not ready to go in anyways
12:36puredangerbut I would like to find that for the next release
12:36sm0kehurmm 1.8 would its own seet time
12:36sm0kewould take8
12:38sm0keanyways voting would give it some importance i guess, afterall core devs look into what people are most interested in too
12:39sm0keso is the new cljc support would be baked in clojure core itself? build tools like lein and boot dont need any changes?
12:40TimMcsm0ke: 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:41sm0kethats good news if true
12:42sm0kebut next release has quite a few things going as well http://dev.clojure.org/display/design/Release.Next+Planning
12:42sm0kenot sure if its going to be quicker
12:43Bronsasm0ke: that's not really reflective of what's going to be in 1.8
12:43sm0kelean runtime sound ambitious in a small timeframe, given the diligience with which patches are pulled
12:43Bronsasm0ke: 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:44Bronsapuredanger might correct me if I'm wrong
12:44sm0kewould there be chances of a 1.7.x release pulling it?
12:45sm0keor the last x is only for bug fixes
12:46puredangerthat page is indicative of things to be considered for 1.8
12:46puredangerthere has not yet been a discussion about what will or will not be in it
12:46puredangeror timeframe
12:47puredangerI certainly have my own thoughts and preferences but obviously Rich's inputs are the deciding factor
12:48puredangerthe 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:50puredangersm0ke: cljc support is in clojure and clojurescript now. tools are in the process of being updated and are mostly there already.
12:51sm0kenice! have not really tried cljx either, but its a welcome change in the core
13:02PupenoI'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:03TimMcChicken and egg, there. I wouldn't expect the project.clj file to have access to the libraries it specifies.
13:05PupenoDoes it mean that every project out there using ragtime has custom code and/or production credentials in their repo?
13:05justin_smithalso, this must mean that ragtime can't run from an uberjar, it can only be run under lein?
13:05hiredmanPupeno: that is not how require works
13:05hiredman,(doc require)
13:05clojurebot"([& 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:05justin_smithPupeno: if so, that sounds like a design failure in ragtime
13:05Pupenojustin_smith: that's way more than I know, but I haven't witness it running in any other way.
13:05hiredmanit is a function, its arguments are evaluated
13:06Pupenojustin_smith: there's two components to ragtime, one is ragtime itself and the other one is the lein plugin.
13:07justin_smithPupeno: 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:07Pupenohiredman: I'm sorry, I'm new to Clojure, I took that require line out of the environ documentation, what am I doing wrong?
13:07hiredmanPupeno: I would read the documentation agian
13:07hiredmanagain
13:07Pupenojustin_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:08hiredmanhttps://github.com/weavejester/environ#example-usage
13:08binjuredPupeno: 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:08hiredmanthe line there is clearly different form the one you pasted
13:08justin_smithbinjured: of course the alternative is to have an optional command line arg that invokes migration behvaior
13:08binjuredsure
13:09justin_smithbut tying a migration tool to lein sucks, because that forces all your environments to accomodate lein
13:10justin_smithand many of us don't want lein to be part of staging or production environments, only using it as a build tool
13:10Pupenohiredman: a quote was lost in the copying and pasting. odd. still doesn't work though.
13:10PupenoAre any of the other migration tools any better?
13:11binjuredjustin_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:11justin_smithbinjured: sure, that's fair
13:11PupenoThe 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:12justin_smithI'm actually guilty of working on a migration tool that had a 100% lein based workflow
13:12justin_smithand I would not do it that way the next time
13:12binjuredthe general sentiment of "X should not depend on lein" seems sound to me :)
13:13justin_smithglad I'm not alone
13:14PupenoI 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:15PupenoI 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:16justin_smithPupeno: 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:16justin_smiththat thing with the ~ above will work inside project.clj
13:16justin_smithand environ would see the same data, under :db-connection-creds
13:18Pupenojustin_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:18Pupeno 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:19justin_smithPupeno: OK
13:20justin_smithPupeno: 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:20Pupenojustin_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:21Pupenojustin_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:22PupenoI'm evaluating Clojure for my company and I care about this boring details as maintaining good security, production environments, testing, etc.
13:23binjuredPupeno: 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:23irctcHey 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:25binjuredPupeno: 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:25Pupenobinjured: that sounds like a neat workaround, thanks.
13:26binjuredand fwiw, i use ragtime and have been happy with it (luminus inline credentials aside)
13:27Pupenobinjured: that's good to know :)
13:27Pupenobinjured: are you also using yesql?
13:27binjuredyep
13:27PupenoAre you happy with it too?
13:29binjuredyeah. 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:30binjuredbut it still beats an orm or dsl so, ya know, trade-offs.
13:31binjuredPupeno: specifically: https://github.com/krisajenkins/yesql/issues/93
13:32PupenoIs this specific to json?
13:33binjuredyeah. and postgres. it's not something you're going to run into very often.
13:33PupenoI do plan on storing hashes and arrays in postgresql.
13:43binjuredPupeno: hstore has a different api, as does json vs jsonb, but if you end up using '?' make note of the workaround
13:44Pupenobinjured: I'll keep it in mind. Thank you :)
13:49SeyleriusOpinions on a favorite web scraping clojure library?
13:51_kardanAnyone 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:52TimMcirctc: Good name. :-)