#clojure logs

2016-02-23

00:00solatis(declare ^:dynamic *queue*)
00:00solatis
00:00solatis(defn fixture [f]
00:00solatis (binding [*queue* "foo"]
00:00solatis (f)))
00:00solatis
00:00solatiswould anyone say that's idiomatic clojure? or is it an anti-pattern?
00:01solatisto me it feels like side effects/leaking... but i cannot find another way
00:02tolstoyYou could also use an atom and pass it in as a param to your tests.
00:02solatiscan i pass atoms as params in tests?!
00:02solatishttps://github.com/clojure/clojure/blob/master/src/clj/clojure/test.clj#L635
00:02tolstoyOh, well. Hm.
00:03solatislooks to me as if a test function is defined as a function that doesn't accept parameters..
00:03tolstoyOr make a macro and don't bother with the fixture.
00:03solatisyes, but i'll be damned this is a big limitation to fixtures
00:03tolstoyI think a dynamic var might be fine for tests, as long as there's no threading going on. Kinda depends.
00:03solatisyes you are correct
00:04tolstoyIt's always dangerous to ask here on #pedantic. You can do whatever actually works, esp. if you're on a deadline. I mean, totally rethinking your entire architecture to avoid the problem is an option, too. ;)
00:05solatiswell i'm strong in functional programming (haskell especially), but new to clojure/lisp
00:05solatisso i'm not sure what's most idiomatic in clojure
00:06solatisbut i _do_ notice when something feels a bit off :)
00:06tolstoyWhy do you need to pass around something to all the tests?
00:06solatisin this case, an ad-hoc message queue that is created and destroyed in the fixture
00:07solatisbut it could also be a database connection, whatever
00:07solatisi think what i really want to write is a (with-queue [name]) function
00:07tolstoySeems like I've solved that before. Hm.
00:07tolstoyYeah, a macro is good for that, too.
00:08solatisthat's what i figured
00:08solatisit would allow me to create and drop the queue within a macro
00:08solatisor rather, expose the dynamic var
00:08solatisehr
00:08solatishide
00:08solatiswhatever
00:08tolstoyOh, wait. There's a version of fixture that runs just once for all the tests in the namespace.
00:09solatisthat would mean that tests will not be isolated
00:09solatisbecause they share the same message queue
00:09tolstoySo, (reset! queue-atom (set-up ...)) (f)) then just reference queue-atom everywhere you want it.
00:09solatisoh!
00:09solatisthat's interesting
00:09solatislet me look it up
00:10tolstoy(use-fixtures :once fix1 ..) vs (use-fixtures :each f1 f2).
00:11tolstoyYou could also run a single (deftest ...) which just calls a bunch of functions with assers in them.
00:11tolstoyasserts.
00:12tolstoyMaybe not so good if you need all that fine-grained junit stuff. You know, if you're testing for Mgmt or testing for actual dev. ;)
00:13tolstoyI think one test with 100 asserts means you're a slacker, but 100 tests with 1 assert each means you're super productive.
00:13tolstoy /join #bitter
00:18tolstoyI wonder if you could do a closure as well (let [queue (construct) (deftest a ...) (deftest b ...))).
00:18tolstoyOh, no, nevermind. Bad idea.
00:19solatistolstoy: well what i'm looking for is doing this the way it's "supposed to be done".
00:19solatisi mean, this really feels like it should be a solved problem
00:19solatisbut dynamic vars feel a bit like magic
00:20solatisit's one of the major reasons i hate scala
00:20tolstoyI think the (use-fixtures :once ...) is the way it's solved.
00:20solatisi do that, and then i need to do the reset! thingie to pass around the queue ?
00:21tolstoyYes.
00:21solatismy problem is not finding out how fixtures work, my problem is that i need to pass an argument to each test function -- so my only option appears to be to use a "hidden" argument
00:21tolstoy(def queue (atom nil))
00:22tolstoy(defn fixture [] (try (reset! queue (make)) (f) (finally (when @queue (.close @queue)))))
00:22tolstoySomething like that.
00:22solatisWAIT
00:22solatisi feel like an idiot
00:22tolstoy(deftest foo (is (= 42 (take @queue))))
00:22solatisi could just as well just def this, right?
00:22solatisoh
00:23solatisthat seems more elegant
00:23tolstoyI've done that for testing a web service. Inject in a fake database component, then just start up the "real" web service and start calling APIs.
00:24solatisyes
00:25tolstoyAnother "food for thought" is that you make your queue interface a protocol, then just implement a fake one for testing. Then it doesn't matter.
00:26solatisyes
00:26solatisthat's the "best" solution
00:26solatisbut too complicated for now
00:30odeI have a one vec of maps and another seperate map.
00:30odeHow do I update only one map in the vec which has the same value for a key as the the value in the seperate map?
00:34tolstoyMaybe use reduce?
00:35tolstoyCreate a function that tests one map against another map. If there's no map, it returns the original. If there is a map, it returns the updated map.
00:35tolstoyThen just do (map #(xform % single-map) vector-of-maps).
00:36tolstoyOr loop/recur (so you can short-circuit once the match is applied), or reduce (so you can call reduced to short-circuit).
00:39odethanks, I think I was overthinking it. I will use reduce.
01:29amalloytypically you want to not have a vector of maps with an id key. if you are doing lookups and modifications by id, that id should be the key in a map, so you can get fast lookups
01:41MendozaSomeone here does android programming?
01:43lxsameerMendoza, using clojure?
01:43MendozaWanting to move from Common Lisp to Android
01:43lxsameerMendoza, join #clojure-android
01:44MendozaThat's a good idea haha, thanks
01:45tolstoyamalloy: Ah, good call. I didn't realize that's what ode was doing.
01:56sooheonamalloy: This is off topic, but do you make videos on youtube for a certain roguelike game?
01:56amalloyi do. and a couple other games since i started
01:57sooheonwow that's pretty cool, I was persuing that channel the other day, didn't know you were into clojure as well :)
01:57sooheonwas almost confused which irc channel I was in for a second
01:57amalloyyou hang out in ##crawl, i guess? i don't, these days, but i am usually in ##crawl-dev
01:58sooheonyeah off and on
02:01sooheonI enjoy your stuff. It'd be cool if you had some clojure programming vids on there as well haha
02:06kolt kolt - Im using 4clojure and have no idea how to solve the third problem, any help?
02:17sooheonlink?
02:18sooheonkolt: Do you mean https://www.4clojure.com/problem/3?
02:18koltI solved it, they are hard and they don't give any hints :(
06:33dazlowhow do I compile clojure code in realtime? Like, from raw string?
06:34zipperdazlow: Clojure is automatically compiled. Everything you run in clojure is bytecode.
06:35zipperUh what do you have in clojure to support complex types? Like the way haskell has typeclasses and OOP has objects?
06:35dazlowzipper: No, I mean, not like from leiningen, but I have gui app and text field, I'd like to compile what user types as code
06:35zipperdazlow: Is what the user types valid clojure?
06:36zipperHave you read about clojure
06:36zipperincomplete
06:36zipperclojure's eval model?
06:37zipperWhen everything is a tree? You can make your stuff into a list (tree) and call `eval` on it?
06:39dazlowzipper: oh, ok, I'll try that
06:40zipperdazlow: Have time to read? I can refer you to something.
06:40zipperdazlow: Does the user enter valid clojure?
07:57TimMcdazlow: I'm going to give you the footgun necessary for this: (eval (read-string ...))
07:58TimMcdazlow: I assume you trust the user not to write anything malicious? Because sandboxing is very hard, and if you want to accept untrusted input, you've got a tough road ahead of you.
08:00ridcullyyou can shoot off any body part with that line ;)
08:01MJB47_what about your second trigger finger?
08:57ddpiguiHello
08:57ddpiguiI am creating a project anyone good at art
08:58ddpiguirecycle
08:58ddpiguiCAN SOMEONE HELP ME
08:59ridcullyddpigui: this channel is about the programming language clojure
09:03ddpiguiik
09:03ddpiguiI am using clojure in my project
09:04MJB47yo ive used clojure before, is anyone here good at business planning?
09:04ddpiguiAnyone Good at art
09:05ridcullyddpigui: if you are looking to hire clojure developers here, maybe you could structure your request better? what is "art"?
09:05ridcullyand what is "good"?
09:06ddpiguiclear
09:06ddpiguiSo is anyone good at art!
09:06ddpiguiSo far this is the logo PS it looks bad https://github.com/alwaysontop617/PIgui/blob/master/logo.png
09:13ddpiguiSo far this is the logo PS it looks bad https://github.com/alwaysontop617/PIgui/blob/master/logo.png
09:14TimMcAgreed, but you're asking in the wrong place.
09:15Empperieven though clojure is kind of art I agree with TimMc :)
09:15TimMcLate one night, a man walks into a dentist's surgery and says, "Excuse me, can you help me? I think I'm a moth." Dentist: "You don't need a dentist. You need a psychiatrist." Man: "Yes, I know." Dentist: "So why did you come in here?" Man: "Well, the light was on."
09:16ddpiguiKk anyone who wants to join the pigui project join #gopigui
09:40TimMc,(with-redefs [dec inc, inc dec] (inc 5))
09:40clojurebot6
09:40TimMc,(with-redefs [inc dec, dec inc] (inc 5))
09:40clojurebot6
09:43hiredmanis that a question?
09:44gfredericks,(with-redefs [dec inc, inc dec] (apply inc [5]))
09:44clojurebot4
09:45gfredericks,(with-redefs [inc dec, dec inc] (apply inc [5]))
09:45clojurebot4
09:45gfredericksI guess that first one is a bit surprising?
09:45gfredericks,(with-redefs [dec inc] (with-redefs [inc dec] (apply inc [5])))
09:45clojurebot6
09:45gfredericks,(doc with-redefs)
09:45clojurebot"([bindings & body]); binding => var-symbol temp-value-expr Temporarily redefines Vars while executing the body. The temp-value-exprs will be evaluated and each resulting value will replace in parallel the root value of its Var. After the body is executed, the root values of all the Vars will be set back to their old values. These temporary changes will be visible in all threads. Useful for mockin...
09:46gfredericks"in parallel" ⇑
09:47hiredmaninc is inlined during compilation, the code generated by with-redefs doesn't effect vars until it is run, which happens at runtime, by which point your call to inc has been atleast replaced by a static method call
09:57TimMcthere's that too
09:57TimMcMy point was the in-parallel bit, which I was mildly surprised by.
10:09tangled_zhi! I'm having trouble installing datomic. I downloaded datomic-pro from My Datomic and have run the repl at bin/repl from within the directory, but when I do "import datomic.Peer" it gives me a java.lang.runtimeexception: Can't take value of a macro: #;clojure.core/import'
10:10tangled_zany suggestions?
10:11TimMc(Note to self: with-redefs and midje do *not* play well together.)
10:14hiredmanTimMc: I would say midje and clojure
10:15hiredmantangled_z: bin/repl is a clojure repl, not a java repl
10:16TimMcIn this case, a println I stuck in a with-redefs is demonstrating that the redefinition is sticking around outside of both the lexical and dynamic extent of the with-redefs...
10:16TimMchiredman: I know you would. :-)
10:17tangled_zhiredman: I'm following this tutorial: http://docs.datomic.com/getting-started.html#install
10:17tangled_zdo I need to run a different command other than import.peer?
10:18hiredmantangled_z: that tutorial shows a groovy shell being used, not bin/repl
10:18tangled_zooooh right
10:19tangled_zOk, yeah, the command works in the groovy shell.
10:19tangled_zThanks!
10:33sdegutisI'm back.
10:45sdegutisWhat's up?
10:50tangled_zI'm following a tutorial to use datomic from within a lein project, and when I run a function to create a database within the memory, it gives me a "java.lang.IllegalArgumentException : db.error/not-a-db-id Invalid db/id: #db.id[:d.part/user -1000011"
11:01sdegutistangled_z: nice
11:01sdegutistangled_z: also you have a typo in the keyword
11:04hiredmantangled_z: there is a #datomic channel
11:06hiredmantangled_z: in general, the error messages you've typed in to the channel, and the fact that you tried to type groovy in to a clojure repl, have lead me to conclude you aren't approaching this in a very exact way
11:07tangled_zhiredman: That's probably true. What would it mean to approach it in an exact way?
11:08hiredmanpay attention to the tutorial and do exactly as it says and double check that you are copying and pasting exactly
11:11max3can someone help me out here: http://www.braveclojure.com/do-things/#Symmetrizer . why is the recur variable remaining and not remaining-asym-parts
11:11max3is it because both those names are bound to the same vector?
11:11tangled_zhiredman: hmm, okay. Yeah I just tried to do a git clone on the tutorial code ... and that compiled. so must be an error somewhere in my own code, sorry!
11:11tangled_zYeah I should have tried that first. I was actually just worried that the error was due to me not having installed datomic correctly, but looks like that's not the case.
11:12max3ohhh i guess i should be thinking of loop as a recursive function and i'm just passing remaining and the (into as the two arguments
12:16gfredericksso test.check has this usability issue where when a property fails you don't get any information about *how*
12:16gfrederickswhich is normally only a problem for properties with more complex expectations
12:17gfredericksthe main contrast is with clojure.test, where A) having "more complex expectations" usually means having multiple `is` calls, and you always know which one failed; B) it uses some offensive macromagic to dig a bit farther into the exact assertion you're making so it can report the failure a bit nicer
12:19gfredericksthe main idea I'm thinking of for attacking this is having a protocol for test results; currently the result of a property is considered passing if it's truthy and not an Exception object (which is a bit messy)
12:19gfredericksyou could have a protocol that includes the above behavior, but allows libs/users to make new implementations
12:20gfredericksso that a failing test can include data about the failure
12:20TimMcI wonder if there are other testing libs that have solved this well.
12:21gfredericksfrom a user perspective though, getting that to work means either A) users have to explicitly construct these objects B) they'd have a library of alternate predicate functions to use, like =, <, instance?, and, or, etc.; C) we'd use macromagic like clojure.test does to accomplish an equivalent to B)
12:21gfredericksTimMc: probably depends on your critera for "well" :)
12:21gfrederickstest.check has until now followed the design philosophy that "well" includes "not super complicated"
12:23TimMcIt's almost like you'd want assert statements that carry context.
12:23gfredericksyep :/
12:23gfrederickswhich could be its own library
12:23TimMc"Now I'm going into the first item of the vector, so any assertions in here should append that to their path."
12:24xitriumHey, I'm getting a NoSuchMethodError: clojure.java.jdbc$query.invokeStatic trying to use Clojure 1.8. Any ideas why that might be happening?
12:24gfredericksI wrote a lib for debugging differences between data structures once
12:24gfredericksbut since this is test.check any hypothetical libs would have to be contribs
12:25TimMcgfredericks: I've been pondering making an extension to prismatic/schema that produces user-friendly descriptions of schema failures.
12:25hiredmanxitrium: are you sure you using clojure 1.8?
12:25xitriumall my projects dependencies list Clojure 1.8
12:25gfredericksTimMc: don't they already aim at user-friendliness?
12:25hiredmanxitrium: are any of your dependencies aot compiled?
12:25xitriumyes
12:25hiredmanxitrium: hard to say exactly, but that is almost certainly the problem
12:26gfredericks~aot is almost certainly the problem
12:26xitriumthe bottom-most project (that depends on the rest) uses :aot :all
12:26clojurebot'Sea, mhuise.
12:26hiredmanxitrium: is that a dependency, or your project?
12:26xitriumSo I just can't AOT? I have a gen-class in there I need to export, doesn't that need aot?
12:27xitriumit is the last Clojure project and becomes a dependency for a Scala project
12:28hiredmanyou might be able to swing it, but it will involve a much more digging around to figure it out
12:28hiredmanaot is very problematic so if you can avoid it you should
12:29TimMcxitrium: Does `lein deps :tree` show the right clojure version?
12:30xitriumTimMc: yep
12:30hiredmaninstead of using gen-class, you could write a java stub that calls clojure functions, and avoid aot that way
12:31hiredmanclojure has an api namespace meant to make it easier to call clojure from java now, and you might be able to just call that from scala too
12:31hiredmanhttps://clojure.github.io/clojure/javadoc/clojure/java/api/Clojure.html
12:32xitriuminteresting
12:36hiredman~aot
12:36clojurebotaot is almost certainly the problem
12:36hiredmanclose enough
12:37xitriumhaha
12:38hiredmanhttp://dev.clojure.org/jira/browse/CLJ-1886 aot leads to suffering
12:43xitrium:( so I'll try removing aot from a few projects and eventually migrating to the clojure java api
12:43TimMchttp://i.qkme.me/3vb225.jpg <-
12:44TimMcI actually have a back-burner story at work to remove AOT from some stuff.
12:45hiredmanxitrium: aot is even worse if you aot compile a project and depend on it from a another project (which is what I meant by aot'ed dependencies)
12:45gfredericks~TODO is remove AOT from some stuff
12:45clojurebotIk begrijp
12:45xitriumah
12:45hiredmanthat is almost guaranteed to result in what are more or less abi conflicts
12:46hiredmanand, actually, all kinds of other weird errors
12:48hiredmanbecause a. clojure's abi isn't stable, the way code is linked together can and does change (the direct linkage stuff was added in 1.8) so code built with different versions of clojure will have ahard time linking together and b. clojure's compiler operates by loading clojure code and writing the class files generate to disk
12:49TimMcWe have a lib that's used by both Java and Clojure projects. It needs to export some Java interfaces, but AOT'ing th ewhole lib means it can't always be used from Clojure projects.
12:49hiredmanwhich includes all the code in all the namespaces loaded durring compliation
12:50TimMcClojure 1.7 or so introduces a change in how code is loaded that makes this intolerable, so I'm going to see about using the lein-otf approach on it.
12:50hiredmanso if you aot a library, the jar contains, not only the class files from compiling your library, but the class files from compiling its dependencies
12:51hiredmangenerally you can get away with some slop in versions, if a dependency has a dependency on version 1.0.0 of library L and you want to use version 1.1.0 or maybe even 2.0.0 or whatever, that can often work
12:53hiredmanbut if your dependency has the class files for version 1.0.0 in its jar, you will often get version 1.0.0 even when you specify 2.0.0, or even some mix of 2.0.0 and 1.0.0
12:54hiredmanmy old boss actually wrote a post to the clojure mailing list begging people to stop aot compiling libraries back in 2009
12:54hiredmanhttps://groups.google.com/forum/#!topic/clojure/Bs70_PUj-TY
12:56hiredmanso all that above is what you get from clojure's compiler
12:57hiredmanthen you throw lein in to the mix, which at one time or another had various hacks and work arounds for b. (transitive compilation) but left a. (unstable abi) in place
12:59hiredmanthe best work around lein could have would be to popup clippy if you try to aot compile a project with the message "No"
13:01gfredericksexport LEIN_DONT_PREVENT_AOT_COMPILATION=1
13:02hiredmanexport LEIN_I_KNOW_BUT_I_HAVE_REVIEWED_THE_DOCS_AND_LOOKED_AT_JIRA_ISSUES_AND_I_STILL_NEED_THIS
13:03hiredmanTimMc: you know, the clojure repl has a -m option these days, even without lein-otf
13:03hiredmanjava -jar your-uber-jar clojure.main -m your.main
13:03gfredericksLEIN_USE_BUNDLER_INSTEAD_OF_LEIN=1
13:06hiredmanexport LEIN_NO_SERIOUSLY_THERE_IS_THIS_WEIRD_CLASSLOADER_ISSUE_IN_JBOSS_I_NEED_TO_DEAL_WTIH=1
13:38justin_smithTimMc: my approach is to make a rump namespace that has no explicit deps on any other ns (so it's only using clojure.core) and then inside it's -main or init it does a require and a resolve at runtime. That way I get one aot'd thing (that rump namespace) that can be called from the java infrastructure, without the pain of aot of any actual code that matters.
13:39justin_smithmaybe lein-otf does that better/simpler though
14:17TimMcjustin_smith: That's exactly what lein-otf does. It broke due to leiningen changes and I didn't bother fixing it because seriously, it's hardly worth the plugin.
14:19justin_smithaha
14:19gfrederickscfleming: let me know if you have any time this week to discuss details of test.check↔cursive stuff
14:39sdegutisHi.
14:42sdegutisWe would like all who are present to please respond with the number of distinct consonants in your own username. Thank you.
14:49TimMcjustin_smith: Really, I need to just change the readme on lein-otf to give instructions on how to imitate what it would do. :-)
14:50rcassidy,(count (clojure.set/difference (set "rcassidy") (set "aeiou")))
14:50clojurebot#error {\n :cause "clojure.set"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.ClassNotFoundException\n :message "clojure.set"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[ja...
14:50rcassidywhoops
14:52rcassidy,(require '[clojure.set])
14:52clojurebotnil
14:52rcassidy,(count (clojure.set/difference (set "rcassidy") (set "aeiou")))
14:52clojurebot5
14:57amalloyTimMc: "lein-otf is a brain plugin masquerading as a lein plugin. Cut your load times in half with one simple trick! Sysadmins hate him!"
15:00TimMcamalloy: Ooh... on first run, it could use cowsay to explain how to do the thing.
15:02TimMcor do the changes, then delete itself from the plugins list
15:03sdegutisrcassidy: I had similar solution
15:03sdegutis,(->> "sdegutis" (distinct) (remove #{\a \e \i \o \u}) (count))
15:04clojurebot4
15:04sdegutisHaha I'm in the 4 club alright go fourrrrs!
15:09rhg135I'm in the 0 club and 0 > 4
15:09rhg135wait...
15:29sdegutisHaha yeah
15:56CStormive added auto-complete and ac-clojure, c/p the snippet from github to init.el and works when i in cider and run auto-complete-mode. however i cant get it to autoload it– annoys me a bit i have to run it my self. (auto-complete-mode 1) seems not to fix it in init.el
15:56CStorm(emacs+clojure problem ^)
16:23justin_smithCStorm: you either need global-autocomplete-mode or auto-complete-mode 1 needs to happen in the context of each individual clojure buffer (perhaps on a clojure file load hook)
16:23justin_smithbecause right now you are just turning on auto-complete-mode on for the current buffer (probably scratch) at emacs load-time
16:27ruph /join emacs
16:42gfredericks /join linum-mode
16:49CStormjust updated Cider.. shoudnt have done that haha
16:58amalloyclassic cider
16:59gfredericks~cider
16:59clojurebotcider is Try #clojure-emacs for more help with Cider
17:01sdegutiswelp
17:02TimMc/join #clojure
17:03TimMcCStorm: I hope you version your dotfiles.
17:05gfredericksI stopped checking in my emacs libs a long time ago, but I can't remember why
17:07sdegutischecking in?
17:07sdegutislike, into source?
17:07sdegutiscontrolv ersion?
17:07sdegutis(git)
17:07gfredericksyeah
17:09sdegutisgfredericks: my solution is to keep ~/.emacs.d/ in a git repo that's pushed to a bare-repo somewhere in ~/dropbox
17:09clojurebot'Sea, mhuise.
17:09sdegutisgfredericks: i mainly only push to it when i plan to do a little work on my laptop, which these days is never
17:09sdegutisso i commit to it probably twice a year
17:10sdegutisalso dont get me started on apple battery life, piece of cr
17:11gfredericksyep
17:18TimMcclojurebot: gfredericks: my solution?
17:18clojurebotgfredericks: my solution is to keep ~/.emacs.d/ in a git repo that's pushed to a bare-repo somewhere in ~/dropbox
17:18TimMcthat bot
17:18gfredericksniice
17:19TimMcI version my dotfiles at work better than I do at home, even including my .bash_history.
17:19gfredericksI have a hybrid dotfiles system so I can share with work
17:24TimMcHow does that work?
17:24TimMcSome files are versioned in each repo, or you have branches?
17:25TimMcI don't think I'd ever run fetch or pull in a dotfiles repo, since the risk of pulling something down *into my PATH* is a little too high for my tastes.
17:25TimMcmaybe if I signed the commits...
17:26gfrederickshttps://github.com/gfredericks/dotfiles/blob/master/bootstrap
17:26gfrederickswe all have our own personal paranoia levels
17:27gfredericksTimMc: actually a better explanation is probably the README of that repo
17:38gfredericksI end up combining 3 or 4 different dotfiles sources depending on whether it's personal vs work, whether it's a local machine or a server, etc.
17:43TimMchaha: alias .....='.. 4'
17:45gfredericksI use those all the time
18:02sdegutistomaw: ok thanks
19:09gfredericksmacros and cljc never fail to confuse the hell out of me
19:11gfredericksalso, I think I may have run into an unsolveable problem
19:12gfrederickscurrently test.check's clojure.test integration consists of a macro (defspec) that expands to code that calls a function (assert-check)
19:12gfredericksthe clojure.test/is expression is inside the assert-check function, which leads to file/line reporting from clojure.test always pointing to the assert-check function rather than the user's defspec use
19:12gfredericksso I said "I know, I'll convert assert-check to a macro!", and then I had two problems
19:13hiredmanhow so?
19:13gfredericksactually, now that I've rubberducked this far I'm not sure anymore
19:13gfredericksthe clojure version works just fine but cljs fails saying "java" is not defined
19:14gfredericksmy theory was that this was somehow tied to clojure.test and cljs.test having different namespace names
19:14gfredericksbut now I'm entirely confused and have no idea
19:14hiredmanwell, like, if you just inlined the body of assert check in to the defspec macro, does it work?
19:15gfredericksGOOD QUESTION
19:15hiredmanthe stubstitution model says it should, and while that is the best, and is not always the correct model
19:20gfrederickshiredman: I'm hitting an even weirder error inlined, and don't have time to investigate right now, so will have to give up; but thanks for the hints
19:32hiredmanI bet it is around making ct/is resolve to the correct thing on the correct platform, the defspec macro only exists on clojure, but the same macro expanded output will be used in both places
19:33hiredmanrunning the cljs tests for test.check seems like I would have to install node :(
19:43WorldsEndlessWhat is the reason that I would want to deploy to wildfly inside a docker instance? Just if you would have a sticky (non-default) Wildfly setup?
21:10WickedShellwhy does (/ (float 10) (float 2)) yield a double? It seems like an excessive promotoion if it was given all floats?
21:11hiredmanclojure generally will turn ints into longs and floats into doubles
21:13WickedShellYeah I was aware of that, something I came across about boxing once lead me to the conclusion that if it was given equivelent primitve input types it would use the primitive without promotiing it...
21:13WickedShellI guess that's not the case, but its causing a huge flaw for me that is going to require writing java code to fix...
21:14WickedShell(I have to match the math that a microprossor is doing which calls for doing a floating point mul, then convert to int32, then undo it. And i don't see anyway to do that in clojure at all(
21:29justin_smithWickedShell: this sounds like a case where some java code, or maybe judicious use of no.disassemble, would be helpful
21:43solatisok, so, i come from a Haskell background, where everything is lazy
21:44solatishowever, i think in Clojure, this is not the preferred style
21:44justin_smithsolatis: it isn't even a question of style, the only lazy thing is lazy-seq
21:44solatisright
21:44justin_smithyou can use delays, but that's clumsy
21:45solatisso, if i write an interface to a message queue, the best thing would be to have a poll function that returns a sequence of messages available, right? rather than representing the message queue as an (infinite) sequence itself?
21:45solatisbecause the latter is what you would do in haskell, and then apply map/seq/whatever on the message queue
21:45justin_smithI wouldn't represent a queue as a sequence at all
21:45solatisright
21:46justin_smithsolatis: usually when I need a queue I can just use an agent
21:46justin_smithor maybe a core.async channel
21:46solatisaha, that sounds interesting
21:46justin_smithagents are basically some decent default behaviors wrapped around a queue
21:46solatisright, is it in clojure core?
21:46justin_smithyes
21:46solatisawesome
21:46WickedShelljustin_smith, right, java is the only path forward which seems ridiculous to write a java function that is 3 operations, its such a simple equation to be done
21:46solatislet me google that
21:46justin_smith,(doc clojure.core/agent)
21:46clojurebot"([state & options]); Creates and returns an agent with an initial value of state and zero or more options (in any order): :meta metadata-map :validator validate-fn :error-handler handler-fn :error-mode mode-keyword If metadata-map is supplied, it will become the metadata on the agent. validate-fn must be nil or a side-effect-free fn of one argument, which will be passed the intended new state on ...
21:50solatisjustin_smith: thanks a lot, this gives me a clue about the "right" thing to model this
21:50solatisit's annoying that every language/ecosystem has its own best practices of doing things
21:50solatisbut i really like how Clojure just gets "out of the way", i'm a lot more productive than with Haskell
21:51justin_smithsolatis: it's true, but pervasive lazy evaluation on top of the jvm would be weird...
21:51justin_smithsolatis: yeah, that's my experience too (though I have much less haskell experience - I'd make the same comparison with OCaml though)
21:52solatisyes i agree, it took me a few days before i got out of the Haskell-lazy-all-the-things kind of thinking.. "why is this function called, *i am not even using its return value!!!* ... oh wait)
21:53solatisbut clojure has the main advantage of the java ecosystem
22:15amalloyi'd be interested to try out the way frege does laziness on the jvm. i think it basically requires you to define a shim haskelly type wrapper around any java type you want to interop with, and interop with that thing lives in something like IO
22:15justin_smithamalloy: fascinating
22:15amalloyso that pervasive laziness works out okay for everything else, and it is obvious that it doesn't apply to java interop
22:16justin_smithamalloy: I would totally have used frege by now if it played well with interfaces
22:16amalloywhat does it do wrong with interfaces?
22:16justin_smithamalloy: you can only use them via interop with a java class that uses them
22:16justin_smithit doesn't allow definition or implementation directly in frege at all
22:17justin_smiththat was a deal-breaker for me
22:17amalloythere's no reify?
22:17solatisamalloy: does that include lazy I/O ?
22:17justin_smithamalloy: exactly, no reify, not equivalent to our protocols, etc.
22:17amalloywell, i bet you a trillion dollars there's an equivalent to protocols, ie typeclasses
22:18justin_smithamalloy: I mean equivalent as in "creates a usable interface"
22:18amalloyor maybe not
22:18solatiswhat are the '->' and '->>' operators called in Clojure?
22:18solatisi need something to type into google
22:18justin_smithsolatis: thread-first thread-last
22:19justin_smithsolatis: in fact emacs adopted them with those names http://endlessparentheses.com/new-in-emacs-25-1-more-flow-control-macros.html?source=rss&amp;utm_source=dlvr.it&amp;utm_medium=facebook
22:19solatisah nice
22:22solatisis there any way to rewrite this function to omit the function declaration? is there a macro for that?
22:22solatis(fn [msg] (-> msg
22:22solatis :body
22:22solatis read-string))
22:23justin_smithplease don't do multi-line pastes, but anyway I do't think that's any better than #(read-string (:body %))
22:23justin_smithinf fact it is probably worse
22:23solatissorry
22:24solatisi think you are correct
22:27KamuelaWhat does ! denote at the end of the function name?
22:27solatisimpure
22:27solatishttp://stackoverflow.com/questions/20606249/when-to-use-exclamation-mark-in-clojure-or-lisp
22:28justin_smithKamuela: in clojure.core it denotes things that are not safe in transactions, in other code typically it means "has side effects or mutates something"
22:28justin_smithhaha I corrected the accepted answer for that SO
22:28justin_smithlol
22:30KamuelaThank you
22:31solatisit's always great to see yourself being referenced online
22:31KamuelaDamn what a totally different way to look at code
22:31KamuelaThis function DOES something, flag as unsafe!
22:31solatisnah
22:31solatisit just means it has side effects
22:31justin_smiththe only people who show up to my funeral will be irc denziens, people who read my SO answers, and twitter followers
22:31KamuelaI know and it makes sense
22:32solatisthat's a big thing, because it means it might not be repeatable
22:32KamuelaYeah. I'm just saying it's amazing how that has become what coders flag. Not handling memory or anything. Just that a function mutates state
22:33KamuelaWhat a leap forward in paradigm
22:33justin_smithKamuela: handling memory is a subset of mutating state
22:33solatisKamuela: i have written a blog post that might be relevant to you: http://www.leonmergen.com/code/2015/12/04/on-stateless-software-design-what-is-state.html
22:33KamuelaYou'd better make sure you know what you're doing. State changed ahead
22:33solatisbasically, the ! means, "beware, this function leaks state"
22:33justin_smitha more concrete way to look at it: unsafe in something that retries
22:34TEttingerchoo choo all aboard the accident express! I swear it's safe
22:34justin_smithonce you have the concept of restarts / retries, things have different consequences
22:34KamuelaI'm not at all saying its wrong or silly. I'm saying its just really interesting to think about code this way
22:34KamuelaIt's like a forward shift in design
22:35solatisKamuela: in Haskell, you cannot even get away with it _without_ explicitly "flagging" things... the compiler doesn't allow you to do that
22:35solatisand yes, it's an immense forward shift
22:35solatisit makes it a lot easier to reason about code
22:36solatiswhen you think about it, the state of OOP being so dominant is really painful
22:36solatisit does exactly the thing that FP tries to avoid: tightly coupling data with code
22:37TEttingerit is interesting yeah
22:37solatisto me it doesn't make sense to say "person.moveTo(foo)", which mutates an internal state you are completely unaware of
22:38solatisand don't even get me started about the code bloat for all the interfaces, useless abstractions, etc
22:38solatis /rant
22:38KamuelaTrue. Little black boxes that you have to pander to
22:38TEttingerwe are seeing more of a shift toward immutability in mainstream OOP languages though. the CoreFX standard library of CoreCLR (open source .NET) includes a rather decent immutable collections lib, and it should be in the next .NET framework release judging by that
22:38justin_smithsolatis: but don't you see we need 1000 different containers, and each has it's own special version of "look up the value"
22:40TEttingerjustin_smith: bro, you don't even, nuh uh. I'm working with fastutil right now, which is 16MB as a no-source, no-doc jar, all code
22:40TEttingerthere are separate jars for docs and code
22:40TEttingerthere are... hundreds of specialized classes, mostly per primitive
22:41solatisjustin_smith: aha, but then you forget about c++'s STL!
22:41TEttingerit's kinda amazing
22:41solatisdon't you see that we can use templates for that!
22:42TEttingerhehe
22:42solatisand then have beautiful, elegant code like std::transform(foo.begin(), foo.end(), std::bind(&Class::bar, this, _1)) !
22:42TEttingerI was just about to link this, solatis; they generate java using the C preprocessor on special files that are between C and Java https://github.com/vigna/fastutil
22:42TEttingerthe java it makes is totally fine though
22:42TEttingerthe build process is tricky
22:43solatis:i
22:43solatis:o
22:43justin_smithbonus points if they call it CaCa
22:43solatisthat sounds almost like bringing the C-era of bison, flex, lookup tables, etc to java
22:44TEttingerohhhhh this looks like that's the problem
22:44TEttingerI think this needs actual non-windows symlinks
22:45rhg135Why would you do such a thing?!
22:49TEttingerrhg135: because writing the amount of type-specialized java it generates would drive men to the mountains of madness
22:50igotsegvTEttinger: I bet, but so can cpp macros
22:50TEttingerno template macros at least
22:51TEttingerCompiling 1878 source files...
22:52rhg135<10000 files, pfft