#clojure logs

2015-10-01

00:11justin_smithlein do clean, check, eastwood, test, repl
00:48tmtwdin cljs, why do we do put! instead of >! ?
00:52wmealingtmtwd: i assumed i'd have seen it here https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
00:53wmealingbut its not mentioned
00:53wmealingand its really hard to google those characaters
00:55wmealingmay just not be implemented.
00:59seancorfieldtmtwd: put! and >! do different things...
01:01amalloyseancorfield: would it be wrong to say that they do the same thing (or similar things), but in a different context?
01:02wmealingcharacters, man i need a break.
01:03seancorfieldamalloy: well, they can also take different arguments :)
01:03rhg135Technically, >! tells the state machine to pause then resume on successful put
01:04rhg135The symbol
01:04seancorfieldIt's been a while since I've worked with core.async but as I recall >! is blocking and needs to be in a thread or a go block, whereas put! is async on its own.
01:05seancorfieldamalloy: is that a correct summary?
01:06amalloy"blocking" is the wrong word. it has to be in a go block because it parks
01:06rhg135put! Just puts stuff on a channel, and calls a callback when done iirc
01:07seancorfieldamalloy: yes, true, that was sloppy wording :)
01:07amalloy"async on its own" i'm not sure what you mean, but i'm also not really sure how put! behaves so you are probably right
01:08amalloythe thing i know about put! is that it's the most primitive putting operation supported by the platform, which has different semantics in jvm vs js
01:23elvis4526Anyone has a good tutorial/explanations for monads? I've read all the interesting stuff that I found the first 1-2 pages on Google :p
02:23aztakmorning all!
02:29aztakanyone want to have a look at some newbie code and let me know what can be improved? https://gist.github.com/metamorph/bdb90be62e9d242eebf3
02:35sveriaztak, I wonder, why would you want to have an extra entity for a removed node?
02:36sveris/entity/record
02:55sm0keis there a way to change tools.logging root log level on repl?
03:05aztaksveri: perhaps that's a bit too much?
03:06sveriaztak, depends on the need, but why would I want to keep a node that's removed from a tree (I am not saying this is invalid, just curious for the usecase)
03:06aztaksveri: the idea was to model each possible 'state' as a separate record. The Node record could be created with a flag indicating if it was a 'deleted' node or not, sure.
03:06sveriaztak, if it's deleted, remove it from the tree
03:07aztaksveri: It's a binary tree, so you still need to be able to find its leaf nodes that are *not* deleted.
03:07aztaksveri: In that case you would need to rebalance the tree (which could be done, of course).
03:07sveriAFAIR trees will have to be rebalanced after removal of node
03:07aztakyeah, that's it :)
03:08sveriI mean, there might always be cases where it is useful to mark a node as "removed" and leave it in the tree
03:08aztakI agree (and I'm working on a re-balancing function) but in this scope I'd say the code would become *more* complex if I introduce re-balancing on removal. Maybe :)
03:09aztakthanks for the input though :) Any ideas on how to minimize the repetitive code. Each implementation of insert/member? etc. basically follows the same 'pattern'.
03:10sveriWell, my first step would be to get rid of the removed node
03:10aztakCheck if it's "this" - do one thing. Check if it's gt than 'this' then do something else.
03:10sveriand then factor the delete / insert methoud out into it's own method
03:10sveriand pass in the "action" functions
03:10aztaksveri: like a 'template class' functional style?
03:11sveriNot sure what a template class is :D
03:11aztakhehe
03:11sveriSounds like C#
03:11sveriOr some other C :D
03:11aztak(defn do-branch [current-value incoming-value on-eql-fn on-lt-fn on-gt-fn] ...) ?
03:12aztak(template method might be the correct name.. )
03:12aztakhttps://en.wikipedia.org/wiki/Template_method_pattern -- very OO.
03:12sveriyea, like that
03:13sveriand see what it looks like
03:13aztakI'll give it a spin this evening :) Thanks for taking time looking at the code!
03:14sveriYea, np, and dont take my words to serious, I just like to poke at things and see if I like it better afterwards. Dont have that much clojure experience myself ;-)
04:05marshzorI would like to build a ring request with a html Date header, is there a preferred way of doing this in clojure?
04:11mavbozomarshzor, you can use ring-mock https://github.com/ring-clojure/ring-mock to build the request
04:12mavbozoand then use ring.util.time/format-date to format your date
04:13marshzorthanks, I'll give that a try
04:24marshzorhmm I guess ring-mock doesn't really help me since the api I'm using just wants a method, uri and headers map. Good to know about though, thanks mavbozo
04:44lnostdalanyone tried clojure 1.8 yet? .. i keep getting this weird exception when compiling: https://www.refheap.com/110150
04:50neoncontrailsI'm sort of unclear on something: what does leiningen proceed to do when invoked from within a subdirectory?
04:50neoncontrails (Say, when you call "lein repl")
04:51neoncontrailsI'm trying to diagnose why I'm getting errors in some directories which should be a-ok
04:51neoncontrailsBut it runs fine elsewhere
04:54neoncontrailsI reckon it's a dependency issue of some sort, but I'm not familiar with some of the libraries that show up in the stack trace... i.e. plexus
05:09sverineoncontrails, I am not sure, but my guess is, when you invoke lein repl from a folder where you have a project.clj it reads that one and sets up the environment, but from every other folder it just reads the %USER%/.lein/profile.clj and just starts a repl
05:12neoncontrailsHmm. That makes sense, because running "lein repl" elsewhere on my server works fine whether there's a project.clj or no
05:14neoncontrailsBut I'm not sure what the problem could be, in that case. The problem dir is just a straight-up git clone of this git repo, which works perfectly on my local setup: https://github.com/bhauman/flappy-bird-demo
05:15neoncontrailsls
05:15neoncontrailsoops sorry. Similar windows :)
05:20sverineoncontrails, how about you pastebin the error?
05:22neoncontrailsSure thing. There's errors like it on the web, but those point to Heroku issues that are not an issue in this case. One sec
05:24neoncontrailshttp://pastebin.com/YA97Pi8d
05:26neoncontrailsI see elsewhere that this can be caused by a conflicting ~/.lein/profiles.clj file, but I don't appear to have one in that dir's ~/.lein folder
05:36oddcullyneoncontrails: i cloned the repo from gh and tried with the same lein version. works here
05:36mavbozoneoncontrails, what is inside subproject.clj ?
05:37mavbozoneoncontrails, is it a file inside flappy-bird-demo/ ?
05:37oddcullymavbozo: not according to the clone or the "ls" in the refheap
05:37neoncontrailsGot it. What eventually solved the problem was "apt-get remove leiningen" and manual install to /usr/bin/dir (I'd previously installed it to /bin/, which might my user might not have had access to)
05:38TEttingerphew, glad the birds can be flappy
05:38nXqdhi guys, I have a bit problem regarding working with clojurescript. When I develop with figwheel, everything works just fine
05:38oddcullyneoncontrails: that would have been my next question ;)
05:38nXqdbut when I compile the project for production with lein uberjar. The javascript has error :(
05:40mavbozonXqd, try lein deps :tree and see if there are any confusing dependencies
05:40oddcullynXqd: are/where you "Guest52" over in #clojurescript? the problem with .offsetX on nil?
05:40nXqdoddcully: ah no. I'm not
05:40nXqdmavbozo: I will try
05:40neoncontrailsoddcully: I run into dumb Unix obstacles like these pretty frequently, but I have yet to find a good overview of how to rock the command line. Any leads?
05:41oddcullyneoncontrails: `which lein` to find out what you call. never ever install build-tools from your distri unless you know it's always uptodate
05:41neoncontrailsOccasionally I'll ask someone, 'hey, how'd you get so good at Unix.' I've never met anyone who has an answer to that
05:42nXqdmavbozo: it seems to be a giant list of deps, I see some advice regarding putting exclusions. on lein-fighweel
05:42nXqdhmm, I don't think it's the solution. Do you have any ideas
05:42nXqdI work with the lein reagent template.
05:43oddcullynXqd: often the problems arise with different compiler settings
05:43neoncontrailsis `which lein` an alias of lein --help?
05:43neoncontrailsThe output is the same
05:43oddcullynXqd: can you provide the error in a gist/refheap/...
05:44nXqdoddcully: yes I will. I'm trying with the :none optimization, maybe I can see some hint from it.
05:44TEttingerneoncontrails: odd. which is a command that should list where the lein executable is on the filesystem?
05:44oddcullyneoncontrails: which tells you, where the binary is located. if you call `which lein` and see /usr/bin/lein, you see, that you use the system one. your own install would rather show up as ~/bin/lein
05:45nXqdoddcully: hmm, I have another error which is goog is not defined.
05:45neoncontrailsOh, got it. I was treating the quotes too literally
05:45nXqdthe the overall is : I get the app working with dev optimizations none.
05:45neoncontrails"`which lein'"
05:45TEttingerheh
05:46nXqdwhen I use uberjar, the app seems to work, but the interaction with javascript doesn't work. I change uberjar compiler's settings to none, then I get goog is not defined
05:46oddcullyneoncontrails: `which lein` would execute the result. its basically the same as just running lein (if it's in path)
05:46nXqdinteraction using javascript*
05:48oddcullynXqd: i can not comment on uberjars. but goog missing is most likely not having a main defined or no goog required or wrong stuff in your jar (e.g. only the generated.js instead of the whole out dir)
05:48nXqdoddcully: thanks for your comment. I think there is something wrong with my code. I just run uberjar on clean reagent template, everything seems to work fine
05:49oddcullynXqd: and if you have problems with full optimazations and external libs, then names get mangled
05:49TEttingeroddcully: but `which lein' with the straight quote at the end would not
05:49oddcullynXqd: the error would be something like "document has no method .XaJ" where XaJ is something that had a nice name before the compiler optimized it
05:49TEttingerthat's an odd custom to do quotes like that, I think it was related to some clients rendering it as proper curved quotes?
05:50oddcullyTEttinger: OP wrote it wrong here. if he had the lein help he called `...`
05:50nXqdoddcully: yeah, but I don't have that problem. I have this one Use of undeclared Var clojure.set/intersection
05:51nXqdI believe that it's correct to use clojure.set in clojurescript.
05:51TEttingerit may need to be required first?
05:51TEttinger,(clojure.set/intersection #{1 2 3} {1 4 5})
05:51oddcullynXqd: maybe figwheel requires it in its underbelly or some plugin
05:52clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
05:52TEttinger,(clojure.set/intersection #{1 2 3} #{1 4 5})
05:52clojurebot#error {\n :cause "clojure.set"\n :via\n [{:type java.lang.ClassNotFoundException\n :message "clojure.set"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLClassLoader$1 run "URLClassLoader.java" 366]\n [java.net.URLClassLoader$1 run "URLClassLoader.java" 355]\n [java.security.AccessController doPrivileged "AccessController.java" -2]\n [java.net.URL...
05:52TEttinger,(require 'clojure.set)
05:52clojurebotnil
05:52TEttinger,(clojure.set/intersection #{1 2 3} #{1 4 5})
05:52clojurebot#{1}
06:03mavbozoi'm using clojure 1.8.0-alpha5 and clojurescript 1.7.122 and I get this error Exception in thread "main" java.lang.VerifyError: (class: cljs/util$last_modified, method: invokeStatic signature: (Ljava/lang/Object;)Ljava/lang/Object;) Can only throw Throwable objects, compiling:(util.cljc:142:1)
06:07oddcullylnostdal mentioned the same error earlier
07:10lnostdaloddcully, might be related to this: https://groups.google.com/forum/#!topic/clojure/2t120_atPR8
07:12mavbozolnostdal, what a coincidence, about an hour ago i got the similar problem
07:12mavbozoException in thread "main" java.lang.VerifyError: (class: cljs/util$last_modified, method: invokeStatic signature: (Ljava/lang/Object;)Ljava/lang/Object;) Can only throw Throwable objects, compiling:(util.cljc:142:1)
07:12mavbozothis time with clojurescript 1.7.122
07:12mavbozoand clojure 1.8.0-alpha5
07:21puredanger That's clj-1809
07:22nXqdoddcully: it seems the problem is because of the clojure.set function
07:22puredangerIt's a bug in the new direct linking stuff
07:34oddcullynXqd: i tried earlier. the function works when fired in figwheel without require. have you tried requiring it?
07:34nXqdno, I just use it directly without requiring
07:34nXqdit works well in figwheel
07:34oddcullybecause figwheel requires it and so it works in figwheel
07:35nXqdbut when I uberjar, the minified version of javascript doesn't work
07:35oddcullyput it in your require where you use it and it should work also outside of figwheel
07:35nXqdah, i get it
07:35nXqdhmm, some how it's a bit trouble some with the repl isn't it :D
07:46nXqdoddcully: sometimes, I get really weird problem with the figwheel repl like, when I first use the application, it seems to not work. But after making figwheel hotreload, it works. How can we address this kind of problem quickly ?
07:49oddcullynXqd: how do you handle the reload? are you doing your stuff in the on-something-i-forgot-reload hook? iirc this does not get called on initial load but only when figwheel handles the reload
07:50roelof_Hello, Is living clojure together with 4clojure and the wonderland katas a good way to learn clojure ?
07:50nXqdoddcully: hmm, I don't have any custom reload hook here in my project.
07:51nXqdthe error when I first used ( in development ) is the exact error I get when I use uberjar version of javascript
07:52oddcullythe error with the set? i thought that you got fixed with requiring?
07:54nXqdoddcully: ah no. other ones
07:54nXqdthe error with set is fixed. But is it considered an error with the clojure.set
07:54nXqdit should be ok if I use directly with namespace, shouldn't it ?
07:54nXqdor if we use clojure lib in clojurescript, we have to require first ?
07:56oddcullynXqd: this is not like in e.g. java. you have to require
07:58spacebug_mpenet: for a uuid in cassandra, is there any reason prefer your uuid (alia, datastax uuid) over the standard java java.util.UUID/randomUUID
07:58nXqdoddcully: ah, yes.
08:02sveriHi, lets say I have an arbitrary map {:id 1 :b {:id 2 :children [{:id 4 :foo :bar}...]}} with an :id key that always has a unique value and I want to update a map somewhere inside the map while only knowing the id, but not the path to the map. How would I do that?
08:06mavbozoroelof_, i don't know about living clojure or the wonderland katas, but I found doing the first 80-100 4clojure problems helps me familiarize myself with clojure syntax and frequently used clojure.core functions
08:06roelof_mavbozo: oke, thanks
08:08roelof_mavbozo: you do nt have used any book to learn clojure
08:08oddcullysveri: i just play around with specter. transform with a walker works there
08:08mavbozoroelof_, and besides syntax and core functions, also clojure's special forms
08:09sverioddcully, funny, I also tried specter, but couldn't make it work
08:09sveriMaybe you have a small example please?
08:09oddcullysveri: https://www.refheap.com/3b6eed2bb3ab1e74f760c24a9
08:10mavbozoroelof_, i feel comfortable reading Clojure Programming
08:10roelof_oke, that is a book I know only with no exercises
08:11oddcullysveri: lacks the (use ...) sorry
08:11sverioddcully, np, I try it now
08:11mavbozoroelof_, i exercised using 4clojure
08:12roelof_oke, and when reading. You can start very soon exercising 4clojure ?
08:13mavbozoroelof_, i felt comfortable with Clojure Programming because I have a job as a programmer and i felt that book was written for me
08:15mavbozoroelof_, yes, I can directly jump to 4clojure because I have previous programming background with language with repl as ruby or python
08:15sverioddcully, great that works, somehow I assumed a simple selector would do it, but walker is exactly what I was missing
08:17mavbozoroelof_, and I started learning python and ruby by playing at the repl and they both have similar exercise tools like 4clojure
08:17roelof_oke, then for me the same. I have some experience in ruby
08:17sveriI have to admit, specter seems really useful
08:21roelof_Oke, then I will try that way. The way with the MOOC from the university of Helsinki does not work for me
08:22mavbozoroelof_, what is the name of the MOOC?
08:22opqdonuthttp://mooc.fi/courses/2014/clojure/
08:22opqdonutI guess
08:37roelof_ opqdonut yes, that one
08:45crocketHas anyone here migrated from haskell land?
08:46roelof_ mavbozo yes, the one that opqdonut said
08:50opqdonutcrocket: I use both
08:51crocketopqdonut, What is your verdict on those languages?
08:52opqdonutboth are very nice
08:52opqdonutI like haskell more, but clojure is more practical
08:52opqdonutboth emphasize purity, which I think is very important
08:55svericrocket, you want to hear the opinion of someone who tried three times to get into haskell?
08:55crocketopqdonut, That is it?
08:55crocketsveri, Do state your opinion
08:55crocketI'm not really sure about what I will use clojure for.
08:55crocketClojure can't certainly be used to write MySQL.
08:55crocketMaybe, I can.
08:56crocketIf I can bear clojure's extravagant memory usage,....
08:57svericrocket, My experience is, that the tooling is not comparable to clojure land. there is nothing comparable to leiningen, which makes it hard to start for beginners. (I know, inbetween there is stack, but it still cannot reach leiningen). Also the IDE support is not close clojure (emacs aside, which I don't want to learn). Everytime I tried it I ran into some setup troubles or problems with cabal or some other problems specific to windows
08:57roelof_pity. I cloned the offline github for 4clojure and it fails with ava.lang.UnsupportedOperationException: Unknown Collection type when I do lein run -m offline-4clojure.p1
08:57sveriI cannot say much about productivity, as I never got that far
08:57crocketemacs is ok
08:58crocketI use emacs and paredit
08:59sveriEven when I tried emacs I ran into a problem which made me have to restart ghci and emacs all the time I wanted to switch the buffer I was evaluating, there even was a known defect for this which had no simple fix available
08:59crocketI mean emacs and clojure mix well
08:59crocketnot haskell
08:59roelof_what I missed what a very nice introduction. I found no good beginners haskell books
09:00sveriroelof_, Exactly, that's another point, as a beginner it is really hard to get started at all
09:00crocketIt may be different now
09:00crocketHaskell is pretty mature at this point
09:01roelof_exactly. the "experts" say begin with CIS194 course where the second assignment is to solve the towers of hanoi recursive
09:01sveriThe language surely is, but the tooling and editor support is not, from my point of view
09:01roelof_but can someone help me with my unknown collection type error
09:02justin_smithsveri: there's a common attitude amongst haskell folks that tooling and editor support are symptoms of a shitty language
09:02justin_smith"your language is so bad it needs special editor plugins before you can be productive programming in it'
09:02sverijustin_smith, hm, I would have to disagree with this. Especially in larger projects tooling and editor stuff will become so important
09:02crockettowers of hanoi?
09:02roelof_but I have to leave for some 30 min. My daughter school is out now
09:03justin_smithsveri: I'm just reporting that this attitude is prevalent, I don't neccessarily agree
09:03justin_smithsveri: and this might explain some of the lack of tooling
09:03crocketThat sounds elitist
09:03sverijustin_smith, Yea, understood, it was an argument against that saying, not you :-)
09:03justin_smithcrocket: haskell, sound elitist? never!
09:03crocketIt also sounds exclusionary
09:05sveriGradle for instance, needs two lines of configuration to get a working java project with build, jar and test tasks + support for eclipse or intellij with auto generation of IDE files. 6 lines more will get you dependencies included. Leiningen has the same story, it is so easy to get started with leiningens templates
09:05crocketGradle is more complex than leiningen.
09:05crocketYou need to know some gradle
09:05svericrocket, You can keep it simple as well
09:06sveritrue
09:06crocketI mean you need to know some groovy to handle gradle well
09:06crocketIt's groovy
09:06sveriOTOH that gives you a lot of options
09:06sveriBut, my point was, it is very easy to get started
09:07sveriwhereas in haskell, for a beginner, the easiest thing is to go to fpcomplete
09:08crocketI believe there are ebooks that you can download.
09:28marshzoranyone know a good way to trim whitespace before and after a string? (trim " stuff ") returns "stuff" ?
09:28justin_smith,(clojure.string/trim " this stuff \n \t")
09:28clojurebot"this stuff"
09:28marshzoroh ...haha, right
09:28marshzorsorry
09:28marshzorty
09:29justin_smithyou even had the name :)
09:29marshzorI just tried (trim " stuff ") in repl, asked here, then went to google... I think step 2 and 3 need to be reversed :)
09:29marshzorI smell a bad habbit forming
09:29justin_smith(clojure.repl/apropos "trim")
09:30justin_smith,(clojure.repl/apropos "trim")
09:30clojurebot(clojure.string/trim clojure.string/trim-newline clojure.string/triml clojure.string/trimr)
09:30sveriHm, in a distributed system and an ideal world the order should not matter :D
09:30justin_smithmarshzor: apropos helps :)
09:30justin_smithsveri: eventual competency
09:32sverijustin_smith, hehe, I have to memorize that
09:45sveriJeez, I could cry, I am working for 2 weeks now figuring out a REST API + some objects and tests in JAVA. Just for the fun I took myself 60 minutes now to do the same in clojure. These endless discussions about the object structure and interfaces and abstract classes. Back and forth where it could be so easy.
09:45sveriKind of frustrating if you have the direct comparison - /rant off
09:46justin_smithcrocket: regarding your comment on another channel about clojurescript output size, are you using a minified output? because it makes a big difference
09:46roelof_one last question : Is there a way I could make 4clojure with my own editor ?
09:46justin_smithroelof_: there's an emacs mode for loading and testing 4clojure problems
09:47sveriroelof_, I always copied it into lighttable and then copied back. Not to much of an overhead, I think
09:48roelof_justin_smith: I tried that one on my cloud ide but I saw this error : unknown collection type error
09:48sveriroelof_, if you use vimperator for firefox you can also open a real vim instance in textareas from the browser
09:49roelof_sveri: oke, I use now nitrious.io cloud enviroment
09:50crocketjustin_smith, I'm aware of advanced optimization mode.
09:51sveriroelof_, looks cool, didn't know that one, however, maybe its a problem in their environment?
09:52roelof_I do not know, I downloaded the offline-4clojure github and that is giving me the problems
09:53sveriroelof_, For learning clojure I would take lighttable. you have instant feedback on your code, giving you the fastest turnaround you possibly can have
09:54sveriAlso you dont need the offline repo, like I said, just copy and paste the functions from 4clojure
09:54roelof_oke, I have then I think install linux . Im running now Win 10
09:54sveriHm, I am using clojure on W7 for two years now (except for boot) everything works fine. Don't know why it shouldnt work on W10
09:55roelof_sveri: oke, is it easy to install clojure and work with clojure on windows
09:56sveriroelof_, you have a JDK installed already?
09:56roelof_sveri: I do not think so. I have a bare Windows 10
09:57roelof_I thought for clojure you need linux or a mac
09:57wombawombaIs there any way to mix the (fn [& {a :a b :b :as kwargs}] ...) and the (fn [& {a :a b :b :or {a 1 b 2}}]) syntaxes?
09:57noncomroelof_: clojure works under win like a charm!
09:57sveriOk, so the process is like this: 1. Download and install latest JDK, 2. set JAVA_HOME variable in windows, 3. include the java bin folder in the PATH environment variable. 4. install leiningen 5. download and run lighttable
09:57sveriroelof_, if you know what you are doing and have a fast connection you are done in 15 minutes
09:58noncomwombawomba: what you need these syntaxes for?
09:58roelof_sveri: for point 2 and 3 are there any manuals
09:58sveriroelof_, http://www.mkyong.com/java/how-to-set-java_home-on-windows-10/
09:58noncomwombawomba: destructuring works for the varargs, so not sure, what's your problem aside from the strange {a :a} form instad of {:keys [a]}
09:59sveriroelof_, I have not done it on W10, but it should be straight forward too
09:59justin_smith,((fn [& {a :a :or {a 10} :as kwargs}] a)) ; wombawomba
09:59clojurebot10
09:59noncomwow
09:59justin_smith,((fn [& {a :a :or {a 10} :as kwargs}] a) :a "I hate kwargs and you should too") ; wombawomba
09:59clojurebot"I hate kwargs and you should too"
09:59roelof_oke, thanks all
09:59sveriroelof_, good luck!
10:00sveriroelof_, I am here for 20 more minutes if you have some questions
10:00roelof_light table has a repl for itself ??
10:00tdammershah, on the bright side, I have now successfully demonstrated that loop/recur does indeed run in constant memory
10:00sveriroelof_, it's inside the editor
10:00wombawombanoncom: I want a function that has default arguments, and where I get a binding to all arguments
10:00roelof_I have to leave in a few minutes. Daugther has to go to swimming lessons
10:00tdammers(fn [blah] (loop [blub blah] (if (empty? blah) nil (recur (rest blah)))))
10:00tdammersouch
10:01justin_smithnoncom: {a :a} is the base / more general form, {:keys [a]} is a sugar (which is less useful when keys of more than one map match in one destructure)
10:01noncomah, that's what
10:02wombawomba,((fn [& {a :a :or {a 10} :as kwargs}] kwargs) :a "asdfg")
10:02clojurebot{:a "asdfg"}
10:02roelof_Thanks all and have a good evening
10:02wombawomba,((fn [& {a :a :or {a 10} :as kwargs}] kwargs))
10:02clojurebotnil
10:02wombawombajustin_smith: ^ doesn't work
10:04justin_smithwombawomba: you supplied no args!
10:04justin_smith,((fn [& {a :a :or {a 10} :as kwargs}] kwargs) :an :arg)
10:04clojurebot{:an :arg}
10:04justin_smithoh, but there was also no a
10:06justin_smithwombawomba: so yeah, I guess that doesn't work
10:06wombawombajustin_smith: I want kwargs to be set to the default args by default
10:06justin_smith,(let [{{:keys [a b]} :c :keys [d e]} {:c {:a 0 :b 1} :d 2 :e 3}] [a b d e]) ; but this does
10:06clojurebot[0 1 2 3]
10:06wombawombayeah
10:06justin_smithwombawomba: kwargs are terrible
10:06wombawombaha
12:04bjadoes reader eval support special forms?
12:06justin_smith,(eval (read-string "(if true :OK)"))
12:06clojurebot:OK
12:06justin_smithI don't know if that is what you mean by reader eval, but it was a read followed by an eval
12:06justin_smithand the special form was supported in that it executed properly
12:08bja(binding [*read-eval* true] (read-string "#=(if true :OK)"))
12:09bjawhich doesn't work afaict (although I'm probably doing something wrong)
12:09justin_smithinteresting, can't resolve if
12:09bjabut (+ 1 5) returns a 6
12:09justin_smithhaha, if you try "when" instead, you get "wrong number of args"
12:09justin_smithbecause it is calling the macro as a function
12:10justin_smithbja: https://www.refheap.com/110173
12:11bjanice
12:11justin_smithso if you called str on that, and called read-string/eval on that...
12:11justin_smithlol
12:11justin_smithyour half way to a very stupid compiler at that point
12:12bjahmm
12:14bjaI think I just need to reconsider what I'm doing. (binding [*read-eval* true *print-dub* true] ....) is madness
12:16bja*print-dup*, although printing code arranged as dub-step would be neat
12:18justin_smithbja: simple - attach the wires of your tty to a speaker, then print the code to the tty, instant dubstep
12:20bjaprobably don't want to do that in the office though. they already think I perform black magic with parens.
13:18justin_smithbja: speaking of black magic, I literally did a (defn foo [x] (fn [y] (fn [] ...))) today
13:19justin_smithit was totally called for though, I swear!
13:19bjayou actually wanted the clojure and not a partial?
13:19bja*closure
13:19justin_smithbja: the non-partial form would never be used
13:20bjafair enough
13:20bjathunks ftw
13:20justin_smithI mean yeah, partial would construct the same thing, more idiomatically I guess
13:23bjawhenever I tink the non-partial form will never be used, I want to debug something in a repl in some remote place
13:23bjawhere I don't want to construct an entire system just to investigate something
13:23bja(which is why I refactored almost all of my code that was returning functions to be partials awhile back)
13:38roelofsveri: are you here to help me with Lighttable ?
13:47roelofanyon who is using light table with clojure and who can explain why I see this output #'fourclojure.core/-main instead of hello world on this code : http://lpaste.net/142085
13:48justin_smithroelof: that line does not call -main, it defines it
13:48justin_smiththe return value of defining a function in your namespace is the var that was defined
13:49justin_smithroelof: if you added on the next line (-main) you would see the result of calling it
13:49hiredmana function only runs when you invoke it
13:49roelofjustin_smith: oke, so I have to do (main) to see hello world ?
13:49justin_smith(-main)
13:49justin_smithyes
13:51roelofjustin_smith: when I do (-main) I see as output nil
13:52justin_smithroelof: println returns nil
13:52justin_smithtry adding "hello" as the last line of the function
13:52justin_smithyou should see it return "hello"
13:53roelofjustin_smith: I should ad just "hello" as the last line of -main.
13:54roelofoke, that works, so I cannot see the output of println in a repl of light table ?
13:55wombawombaSo I'm writing a set of integration tests (currently using midje), and I want some way of stating that all tests will *eventually* (at least within some period of time) pass, i.e. I want to do something like (eventually "30s" (fact (make-some-api-call) => 4)). In other words, I want to repeatedly perform the check, and have the whole thing pass without failures if the check eventually passes. Does anyb
13:55wombawombaody have any suggestions for how to approach this?
13:58roelofjustin_smith: is there a way I can see the hello world output somewhere in light table ?
14:00justin_smithroelof: my first guess would be the terminal where you started light table, if you started from a terminal...
14:00justin_smithmaybe it has a tab that shows clojure stdout?
14:00roelofjustin_smith: thanks I will look if there is a console somewhere. I totally new to lighttable
14:01justin_smithroelof: "from the view menu, select console" https://www.safaribooksonline.com/blog/2013/09/11/light-table-workflow-for-interactive-clojure-development/
14:03roelofThanks, now I can try to solve the exercises of 4 clojure.
14:05roelofAnyony body knows how I can reset 4clojure so I can start all over again
14:06wombawombaActually, I think my question is this: What should I use to test lazy sequences?
14:06wombawombaMidje seems to eagerly evaluate everything, so it might not be optimal?
14:07justin_smithwombawomba: I just use clojure.test, and a simple property based test (eg (is (= (first l) :foo)))
14:08blake_roelof: You could just create a new ID.
14:09roelofBut I use all my email adresses, so a new id cannot be done
14:11xemdetiaroelof, do you use gmail? could try the roelof+tryagain@gmail.com trick
14:11roelofxemdetia: I do not use gmail , only one hotmail account
14:12xemdetiaso it sounds like you just need to make a random new account and use that
14:12xemdetiait's not painful
14:15matthaveneryou can always use mailinator.com too, or something like that
14:16roelofI have made a gmail account so I can start working on the exercises and work with lighttable Thanks all
14:22roelofhmm, why is this not good : (= (list :a :b: :c) '(:a :b :c))
14:29bjaroelof: (not= :b: :b)
14:29blake_,(= '(:a :b :c) (list :a :b :c))
14:29clojurebottrue
14:30blake_,(= (list :a :b: :c) '(:a :b :c))
14:30clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :b:>
14:30roelofblake : the repl of lighttable says false. 4 clojure is happy with the answer. Very wierd
14:31roeloffound it I made a typo :b: instead of :b
14:31blake_oh! lol
14:31roelofsorry for the noise on this channel
14:32sveriroelof, Hi, did you get it running?
14:32roelofsveri: yes, right now I solve the first challenges. The first 10 are very simple
14:32sveriroelof, awesome
14:33blake_Is there a way to access a vector of vectors other then ((vecs 5) 5)? I know about make-2d-array, I'm talking about just this particular structure.
14:34justin_smith,(get-in [[[[1]]]] [0 0 0 0])
14:34clojurebot1
14:34justin_smithblake_: ^
14:35blake_justin_smith: I thought so! For some reason, I thought it was (get-in vecs 2 2).
14:36justin_smiththere should be a <- macro
14:36justin_smithwith the <- macro, at each step it would call the return value of the previous
14:36justin_smithso it would be (<- [[[[1]]]] 0 0 0 0)
14:36wombawombawhat's the best way to force clojure not to chunk a sequence?
14:37justin_smithwombawomba: use doseq or run! if you want side effects, then chunking doesn't matter
14:37justin_smith(usually)
14:38wombawombajustin_smith: I want to evaluate a sequence of (really slow) sequence calls, returning the first that fulfills a predicate
14:38blake_*some restrictions apply
14:39wombawombaand I really don't want to evaluate more than I have to (because slow)
14:39blake_justin_smith: Oh, that's clever. I wonder how generally useful that would be. Seems symmetrically necessary somehow.
14:39roelofsveri: I have done the first 10 exercises , I call it a day
14:40sveriroelof, nice, its a good start. Do you like lighttable?
14:40justin_smithwombawomba: in that case, there's a gist out there for a dechunk function (I think it was written by chouser)
14:40roelofsveri: yes, I helps well when im stuck
14:40justin_smithwombawomba: I just bring up run! and doseq because they are not effected by chunking problems, and are often the better choice if you care about chunking
14:41sveriroelof, Yea, thats my experience too. Tremendously helpful to see so fast what a function or expression returns
14:41roelofThanks all and have a nice evening
14:41sveriroelof, bye
14:45wombawombajustin_smith: alright, thanks
15:06blake_Is there a performance/memory use to using Java arrays or is to-array and to-array-2d more about interoperability?
15:07amalloyblake_: well, what do you think?
15:09blake_amalloy: I can't see a memory improvement. I could see a slight speed improvement if it weren't (potentially) ragged.
15:09amalloyblake_: compared to what? lists? vectors?
15:09blake_Like, byte-array, I can see both.
15:10justin_smithblake_: java arrays use less memory, because they have a lot less structure than our immutable stuff
15:10blake_Vectors. I think that's the correct analogue, i.e., vectors are as close to what Clojure has as arrays.
15:10justin_smithalso perf if they are arrays of primitives, because of cache effects
15:11justin_smithblake_: java arrays are contiguous in the heap, clojure vectors are not
15:11blake_justin_smith: 2d arrays, though?
15:11blake_But wait...vectors are not?
15:11justin_smithjava doesn't have real 2d arrays, so it would depend on which implementation you are using
15:11blake_I'm looking at to-array-2d.
15:12justin_smithblake_: vectors use a tree structure in order to allow efficient sharing
15:12blake_justin_smith: I suppose it would have to.
15:13justin_smithoh yeah, to-array-2d is just a ragged array of object
15:13justin_smithso it's not the same sort of thing that eg. a fortran programmer would call a 2d array
15:13blake_Right.
15:14blake_So, wait, what makes a vector a vector? I sort of envisioned it as an...array. Heh. But that can't be. Still it must be different from a list under the covers.
15:15justin_smithblake_: hyPiRion wrote some really excellent blog posts about how vectors are implemented
15:15justin_smithblake_: http://hypirion.com/musings/understanding-persistent-vector-pt-1
15:15thearthurblake_: it's a trei
15:16blake_Oh, I looked at that a while ago. Maybe I can understand it now. =P
15:16justin_smiththearthur: when you type "trei" do you intend that to be trei, tree, or trie?
15:16justin_smith(we have terrible names in the programming world don't we though)
15:17blake_So there's going to be some memory disadvantage, and also some speed disadvantage because of the immutability.
15:17blake_justin_smith: trieu, we do
15:22thearthurjustin_smith: I gave up long ago on anyone agreeing on a spelling pronounciation combination for these. i mean the type of tree use in clojure's vectors and maps
15:24lgascan anyone point me in the direction of what I'm doing wrong with this macro? Why is ~fields coming up nil? https://www.refheap.com/110182
15:24blake_But actually, I think the heart of my question is not really if Java arrays are more efficient but if that's what the various to-array functions is about. Like, I've never used Java arrays in Clojure. I'm all about the immutability.
15:24justin_smith,(apply str (shuffle (seq "trie")))
15:24blake_er, are about.
15:24clojurebot"irte"
15:25amalloyjustin_smith: a 12% chance of getting an actual word out of that i think
15:25justin_smithsounds about right
15:25justin_smith*rite
15:25thearthurjustin_smith: it's official irte is the new name for "exactly the thing that clojure uses"
15:26thearthurpronounced "er-tee"
15:26blake_Is it a sop? Is it the only way to use certain Java libraries?
15:26amalloyblake_: there are a few occasions where clojure programs use arrays instead of something more reasonable, for performance, but mostly it is for working with java programs that demand an array
15:27blake_amalloy: Thanks. That makes sense.
15:27justin_smith,(let [a "a"] `(~a))
15:27clojurebot("a")
15:29justin_smithlgas: (:a :b) evaluates to nil
15:29justin_smith,(:a :b)
15:29clojurebotnil
15:29justin_smithlgas: that's what I think is happening
15:29justin_smithtry (debug {:fields '~fields})
15:30lgasah that was it. thanks, justin_smith.
15:30justin_smithyou probably don't even need the ~
15:31justin_smith(or the ')
15:31lgaswithout the ~ it comes back as {:fields work.temp/fields}
15:31justin_smithahh
15:31lgaswithout either it doesn't compile because it can't find work.temp/fields
15:32lgasbut '~fields does what I need.
15:55blake_If I have a web app that's accessing a Java object, and multiple users of the web app are accessing the same object--let's say it's a calculator with a persistent set of numbers to work on, but users can change the numbers--what happens when two of them try to access it at the same time?
15:56blake_Let's say that the operations are atomic: The user makes a request of the calculator, the web app sets all the values at once and returns the result.
15:56blake_So impersistent state doesn't matter because each person sets all the values every time.
15:56blake_But could it be that they're both changing the underlying Java object safely, but simultaneously? So that the result comes out wrong?
15:57blake_Seems like that would be a possible thing.
15:59blake_Otherwise, the object would have to be locked and users would have to wait.
15:59thearthurblake_: if you can really say the opperations are attomic(as a group rather than individually) then it's safe
16:00thearthurif each value is set atomically, though without regard to the others then it's not gona be fun time
16:00blake_Well, not atomically in the sense of atoms. Java object. I have to make a call to set each value.
16:01blake_Atomically in the sense of: Each call into the web app contains all the information, the calculator is always in a neutral state, the values are always all put in and the results immediately returned.
16:03blake_I could lock the object myself, I suppose. That'd be safe. If people start complaining about response time I could...clone the object, I guess. =/
16:06amalloythat's pretty much the only thing you can do if you need to perform multiple coordinated updates to a mutable object
16:07blake_Yeah, I was coming to that conclusion. I find myself resenting Java's mutability.
17:03rasmustowhy is it that transducer composition is reversed from normal function composition?
17:05akkadrasmusto: example?
17:07justin_smithrasmusto: comp is transforming the functions, not the data
17:07rasmusto,(sequence (comp (map inc) (map #(* 2 %))) (range 1))
17:07clojurebot(2)
17:07rasmusto,((comp inc #(* 2 %)) 0)
17:07clojurebot1
17:07justin_smithrasmusto: (map inc) is a function that can take a transducer, and returns one
17:08Bronsarasmusto: transducers are not "normal" functions, composing transducers builds a transformation stack
17:08justin_smithrasmusto: so the comp is happening in order in terms of function production, but reverse in terms of the data flow
17:08rasmustoalright, I think that makes sense
17:08justin_smithright, what Bronsa said
17:09rasmustoit's actually pretty convenient that I can turn (->> (range) (map inc) (map dec)) into (sequence (comp (map inc) (map dec)) (range))
17:10rasmustosince threading is inside-out as well
18:59noncom|2does anyone here have experience working with transit?
18:59noncom|2specifically json enc/dec with non-latin chars
19:00justin_smithnoncom|2: it handles my utf8 OK, I'm fond of throwing snowmen around
19:01noncom|2heh :)
19:01noncom|2strange thing - on one machine there's no trouble. on another one - there is trouble
19:01noncom|2specifically java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0xe0
19:01noncom|2google says this error is almost as ancient as jackson
19:03noncom|2solutions aren't really solutions for me
19:03justin_smithso someone is creating utf8 that jackson refuses to handle?
19:03noncom|2justin_smith: it's actually me, yes
19:04amalloyyour non-working computer is probably creating characters using an encoding other than utf-8
19:04amalloyeg like latin-1 or some other garbage
19:04justin_smithyeah, a linux or mac box will default utf8 for most stuff, windows will not
19:04amalloyand then you take those bytes and tell jackson "hey mate here's some utf-8"
19:05noncom|2i create a webform and set :accept-charset "utf-8" then i send this back to clojure server with transit over a ws
19:05noncom|2same webform, same html. both PCs are win-7 (different editions though but it should not matter)
19:06noncom|2chrome browser encoding is set to utf-8...
19:06noncom|2i don't get where it falls out from utf-8...
19:06noncom|2it's all utf-8 over and through
19:06justin_smithuntil it isn't?
19:06noncom|2yeah!
19:07noncom|2could it be that transit somehow encodes it with non-utf-8 on cljs side?
19:07noncom|2also, the eclipse console, when i println what's coming from the ws, shows correct text
19:07noncom|2it's non-latin chars, but it is perfectly there
19:08noncom|2idk even where to start digging :/
19:09justin_smithnoncom|2: it could be that your terminal accepts utf8 bytes that jackson does not, a well behaved terminal should not throw errors when random junk gets printed right?
19:10noncom|2right
19:10noncom|2are there various kinds of utf-8?
19:12noncom|2i thought that the whole point of the "U" letter was to leave all that behind...
19:12noncom|2* the u letter in the acronym
19:21noncom|2amalloy: justin_smith: alright, i had to specify "utf-8" in (.getBytes ws-message "utf-8") so that the correct bytes are given to transit
19:21noncom|2i'm still in wonder why it works on one PC but not the other
19:22amalloythe other one has a different default character encoding set
19:22noncom|2with explicit encoding it now works ok
19:22noncom|2amalloy: but.. how? how is this possible? it must be something JVM-wide or OS-wide, but this is near crazy
19:22amalloyOS
19:24amalloynoncom|2: it would probably not hurt you to do some research on character encodings in general and utf-8 in specific, if you are confused by this issue
19:24noncom|2well, i had lots of play with them in the past, so not a total newb.. i'd say i get amazed each time something like that happens though
19:25noncom|2but i will surely try to find the roots of this one occasion
19:25noncom|2what that could be in windows doing this
19:29amalloyhttp://stackoverflow.com/questions/9312816/java-platforms-default-charset-on-different-platforms
19:33trisswould core.logic be a good place to store a list of musical facts?
19:33trisswell not a list
19:33trisslike midi notes convert to hz
19:34trisshz convert to midi notes
19:34trissmajor scale has these degrees
19:34noncom|2triss: it depends
19:34hiredmancore.logic doesn't have storage
19:34noncom|2triss: on what you gonna do with tose facts
19:35trissso I've got a map of paramaters
19:35noncom|2and yes, it does not store anything. you could define rules to define them - i meant that
19:36noncom|2triss: better use midi -> hz map
19:36trissso i've got a map of paramaters... some of the values in the map can be derived from over values in the map and vice versa
19:36noncom|2or look into the pink library
19:36noncom|2or minim for java
19:37hiredmanthat sounds sort of like something you might do with core.logic
19:37trissI'm not looking for those functions
19:37trissgot them out of overtone
19:37noncom|2what's your aim, triss?
19:38trissI'm wondering how useful something like converso could be: https://github.com/JeremS/Converso/blob/master/src/converso/core.clj
19:38trissbut for music
19:38hiredmancore.logic works more or less like: I have some that I know information and some information that I don't know, I have defined some relationships between different parts of the information, please derive the information that I don't know
19:38justin_smithso fill in the rest of this fugue...
19:40hiredmanif that sounds like what you want, then there you go
19:40trissI'm gonna have to take the plunge...
19:40hiredmanfor conversion stuff, if you sort of a closed world of conversions, and you know all the information for the conversions, you may as well directly generate all possible conversions
19:40trissI'm a few chapters in to reasoned schemer
19:40trissbut still have no clue how to impliment
19:41trissI'll have a proper look over converso...
20:20rplevydid prismatic/schema used to have functions related to walking, and were they removed?
20:20rplevyif so, what's the story on that, is it now advised to be done differently?
20:57rplevynm figured it out
21:44irctchello?
21:44clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline irctc
21:45wmealingyeah, what he said.
21:45irctclol
21:45irctchello world?
21:58TEttinger,(println "Hello, World!")
21:59clojurebotHello, World!\n
21:59TEttinger,"Hello, World!"
21:59clojurebot"Hello, World!"
23:49cflemingDoes anyone know if Clojars just got a new cert deployed?
23:50cflemingI can't connect from JDK6: “Could not generate DH keypair”, which means that the server requires a DH keypair of > 1024 bits, which JDK6 doesn’t support.
23:55nathanialI'm running a dev server with lein ring using nohup but for some reason the way I'm doing it the output isn't going to nohup.out. Is there a way with lein ring or in the application code itself I can specify a log file for all output instead of standard out?