#clojure logs

2014-09-07

00:12babygauhttp://stackoverflow.com/questions/25706915/explain-clojure-map-reducer-implementation
00:15BAMbandaI'm having trouble installing lein, I'm on arch linux and got everything from the most updated community package
00:15BAMbandahttp://pastie.org/9533132
01:29justin_smithjohn2x: the require forms will work, within the ns the ns form defines
01:29justin_smithjohn2x: so any :as aliases only work in that specific ns
01:30babygauhttp://stackoverflow.com/questions/25706915/explain-clojure-map-reducer-implementation
01:33justin_smithbabygau: f1 is the function called for 0 args
01:33justin_smithit is using the multi-arity feature of fn
01:34justin_smithso I would guess that (f1 ret (f k v)) should evaluate to 0 1 or 2
01:34justin_smith,([:a :b :c] 1)
01:34clojurebot:b
01:34babygau@justin_smith I got that line of code, but what I don't understand is why [ret k v] is placed in the beginning of a `form`
01:35justin_smithit is definitely odd, code, that is hard for me to read after a few ciders
01:35justin_smithsorry
01:35babygaulook at `rfn` macro
01:35justin_smith(cider as in the drink, not the emacs clojure lib)
01:35justin_smithret k and v are the three things that form can return
01:35justin_smithas I showed above, a vector as an IFn returns the item at the index supplied
01:36justin_smithso f1 must end up returning 0, 1, or 2
01:36tadni_Cider typically has alcohol?
01:36babygau@justin_smith: so is it sort of `destructuring form`???
01:36lazybotbabygau: Yes, 100% for sure.
01:36justin_smithtadni_: the kind I just had did
01:36justin_smithbabygau: it is a shortcut for get
01:36justin_smith,(get [;a :b :c] 2)
01:36clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
01:37tadni_justin_smith: But not typically?
01:37justin_smithtadni_: in my town, if the menu says "cider" it is probably alcoholic, but my town is full of hipsters, so who knows what typically means
01:37tadni_Says it's unfermented, so I'd assume no.
01:38tadni_justin_smith: San Fran?
01:38justin_smith,(get [:a :b :c] 2)
01:38clojurebot:c
01:38justin_smithtadni_: Portland Oregon
01:38babygau@justin_smith: so this is a `shortcut`????
01:38tadni_justin_smith: That would've been my second guess. :^P
01:38justin_smithbabygau: in the same sense that a map or keyword as function is a shortcut
01:39justin_smithbabygau: they all end up invoking get
01:39justin_smith,(= (get {:a 0 :b 1} :b) ({:a 0 :b 1} :b) (:b {:a 0 :b 1}))
01:39clojurebottrue
01:40tadni_For living in such a meh-city tech wise, I was shocked to hear we have a Clojure Meetup. (St.Louis)
01:40babygau@justin_smith: oh my god, I just test it with repl
01:40justin_smithweird, huh
01:40babygau@justin_smith: and you're right
01:40justin_smitheveryone acts like me being right would be surprising or something!
01:40babygau@justin_smith: I don't need to use `get` method with `:keyword`
01:41babygau([:a :b :c] 2)
01:41justin_smithjust showing that keywords, maps, and symbols, and vectors all end up invoking get when used as functions
01:41justin_smithright
01:42justin_smithif you wanted to invoke clojurebot, you can use ,
01:42justin_smithfor lazybot use & or ##
01:42tadni_justin_smith: "Cider or cyder is a fermented alcoholic beverage made from the unfiltered juice of apples."
01:42tadni_Who knew? I didn't.
01:42justin_smithtadni_: thats what I drank, yup
01:42babygau@justin_smith: you're awesome!
01:42babygau,([:a :b :c] 2)
01:42clojurebot:c
01:42dorkmafiadoes my version of java matter when using clojure? i'm on 1.6 and was thinking of upgrading to 1.7 to get the usage of a library
01:43justin_smiththough in some places (like Vermont, where I was as a child) cider means an unfiltered raw juice
01:43lpvbdorkmafia: no
01:43justin_smithother places its a juice served hot with spices
01:43justin_smithlpvb: dorkmafia: only matters if you try to use java classes not provided with an older java version. Min version is 1.6 iirc
01:43dorkmafiajustin_smith: hot apple cider vs cider vs hard cider
01:44babygau@justin_smith: can you please answer my question on #stackoverflow. I'm happy to check your answer
01:44jethrokuanguys i gave a question
01:44justin_smithdorkmafia: the thing is, in different regions, each is just called "cider" with no qualifying adjective. It varies.
01:44tadni_justin_smith: We used to have hayride things as a kid, and they handed out cider to minors ... so yeah, I'm guessing it wasn't alcholic. Never had it though... so, who knows.
01:44jethrokuancan i type code here?
01:44justin_smithbabygau: sure thing
01:44lpvbnot if it's more than one line
01:45justin_smithjethrokuan: for more than a line or two, use refheap.com or a github gist please
01:45justin_smith~paste
01:45clojurebotpaste is https://refheap.com/
01:45jethrokuani'm on my phone so ._.
01:46justin_smithdorkmafia: also, with the jvm, backward incompatibility is extremely rare, there is a low probability you would break anything by upgrading to 1.8 right now
01:46dorkmafiaare there any nice tutorials on wrapping functionality of a jar in clojure? I'm really new to clojure so even just some good tutorials :)
01:46justin_smithdorkmafia: just use interop first, if it is a huge pain, you can adapt some of your code into a wrapper lib
01:46justin_smithdorkmafia: but step one is learning interop regardless
01:46dorkmafiajustin_smith: probably break everything adobe related lol
01:47justin_smithdorkmafia: I sincirely doubt it, but you can have parallel jvm installs and select which one you need for each program anyway
01:49dorkmafiai was looking for good xmpp lib
01:49jethrokuanhttps://www.refheap.com/89939
01:50jethrokuani'm kinda confused as to how the loop works
01:50jethrokuani thought locals don't vary so why is the value of sum changing
01:50justin_smithjethrokuan: the function args are different
01:50justin_smithrecur sets the new values for the arg
01:51justin_smithmost functions will return a different value when provided different args, right?
01:51jethrokuanso recur will set a new value to the function args?
01:52justin_smiththe function is called again, with new args
01:52justin_smithit's not mutating, it's calling itself (in a special way that does not consume stack frames)
01:53jethrokuanbut here (+ sum x) is called, which returns an entirely new value not bounded to any locals that the function uses
01:54justin_smith?
01:54justin_smithit's saying: return the value of calling this function with these args
01:55justin_smiththere is no mutation there
01:55jethrokuanlet me ponder over that for a while
01:56justin_smithcool
01:56justin_smithgood luck
01:56jethrokuanoh!!
01:58jethrokuanso if the function takes two args the recur must return two as well
01:58justin_smithit must take two
01:58justin_smithyou can only return one value, no matter what
01:58narayanai am happy with o really clojure programming
01:58jethrokuanah yes terminology
01:59jethrokuani'm trying to go through the joy of clojure
01:59justin_smithif you haven't programmed in a lisp before, joy of clojure will be a challenge
02:00justin_smithit's a great book, but it's not an introductory level book imho
02:00justin_smith~books
02:00clojurebotbooks is book
02:00justin_smith~book
02:00clojurebotbook is programming clojure
02:00jethrokuani've kinda browsed through programming clojure by pragprog
02:00narayanamy best friend is great lisp programmer
02:00justin_smithnarayana: some day I hope to be one
02:01narayanayou will clojure is best way for that
02:01jethrokuani feel that the joy of clojure has taught me way more already
02:02jethrokuanthough i'm still dealing more with clojurescript/om
02:02narayanafor me sometimes i using facebook for uploading examples with screenshoots
02:02narayanabut yes blog is ok
02:03narayanathese days i am reading book clojure for machine learning and making examples
02:04narayanasome basic stuffs with core.matrix and clatrix
02:06dorkmafiajustin_smith: how would I run chrome in 32 bit mode?
02:06justin_smithdorkmafia: I actually don't even know. That's pretty OS dependent isn't it?
02:07dorkmafiayah i think there is a setting I can set some where lol
04:33john2xis it just me or does cider not follow the :init-ns option in project.clj? When I `cider-jack-in` in my project.clj, it starts at the `user` namespace. But when I do `$ lein repl`, it starts in namespace specified by :init-ns
04:34zeebrahis there a reason i can't have cider-mode enabled in the cider repl? it wont evaluate anything after i enable clojure-mode in the repl
04:37john2xzeebrah: if you just want to have clojure-mode's font-locking in your cider-repl, try (setq cider-repl-use-clojure-font-lock t)
04:37zeebrahjohn2x: yep! you guessed what i wanted. I'll try that out, thanks
04:39zeebrahdoesn't look like that function exists in the latest cider though, oh well
04:41john2xzeebrah: strange, it's in their readme... and i'm on the latest version as well and it exists for me (it's a var btw)
04:41zeebrahyeah i realised after i wrote (that it's a var), in any case it didn't have any effect
04:48zeebrahit's kinda bizarre that the default behaviour is not to fontlock in the repl
05:24zeebrahhttps://github.com/clojure-emacs/cider/issues/749 <-looks like this is the bug i'm running into
05:26zeebrahand another bug which is more serious is that i dont get a stacktrace buffer popup either. it just dumps the exception into the repl at the point :s
06:01john2xzeebrah: re: the stacktrace buffer, what is `cider-show-error-buffer`'s value?
06:09zeebrahjohn2x: t. it shows the error buffer, just not the stacktrace in a seperate buffer. http://i.imgur.com/cFP8UtI.png
06:12john2xzeebrah: oh yeah, I get that sometimes too. weird.
06:13john2xare you using 0.8.0-SNAPSHOT for cider-nrepl in profiles.clj?
06:15zeebrahjohn2x: yep
06:15zeebrahi just updated after seeing the clojure-mode 3.0 ann heh
06:15zeebrahso far the experience has been not so great :/
06:47hugodzeebrah: is that a repl outside a project with lein 2.4.3?
06:48zeebrahhugod: nope, just using cider-jack-in - there isn't a project
06:49noncomanyone using ccw here?
06:49noncomwhat about java 8 and eclipse luna ?
06:49hugodzeebrah: it is a lein issue - https://github.com/technomancy/leiningen/issues/1625
06:51zeebrahhugod: oh. okay :)
06:51noncomclgv: hello, are you here? i have a little question on ccw if you maybe already know.. ^^
06:52zeebrahhugod: so do you know of a good fix or isn't there one yet?
06:53hugodzeebrah: downgrade lein to a previous version
06:54zeebrahhugod: yeah i saw that suggestion earlier but was hoping for something else
06:54hugoda new version of lein should be released any day now
06:55zeebrahhugod: that fixed my stacktrace problem though. good pick up!
06:56borkdudecan I express in pristmatic/schema: I want the return value of a function to be a sequence of maps, with arbitrary keys in them?
06:57hugodborkdude: [{s/Any s/Any}]
06:57borkdudehugod ok
07:06borkdudeany advice on using schema's with channel output?
07:08borkdudeI guess I'll use a transducer as a validation fn
07:14cfleminghugod: Hi, the other day you asked about how Cursive was more sophisticated than cider, and I'd just gone to bed
07:16cfleminghugod: Basically Cursive actually analyses syntax, so it resolves symbols in the editor from source
07:17cfleminghugod: Since it also indexes, this allows lots of cool stuff - symbol rename, find usages, navigation etc
07:17cfleminghugod: This all works for global symbols (vars) and local bindings.
07:18cfleminghugod: Also things like auto-require and automatically building scaffolding for proxy/reify/deftype/defrecord forms
07:19cfleminghugod: It'll support extracting and inlining methods shortly, which you need symbol resolution for.
07:20cfleminghugod: Since it's based on source, all this works with no REPL running.
07:21cfleminghugod: The main issue with it is that it needs understanding of the syntax of forms, and the syntax in Clojure is extensible - internally Cursive is based around an extension API that I'll be opening up so others can add support for libs they use, or for internal APIs.
07:22cfleminghugod: Basic support (symbol resolution) is pretty trivial to add, some more sophisticated libs (typed clojure etc) need more work.
07:23hugodcfleming: interesting that it works with no repl
07:23borkdudethe docs here https://github.com/Prismatic/schema/ talk about s/validator for performance
07:23borkdudemaybe I'm overlooking something, but I can't find it
07:23cfleminghugod: Yeah, it's all based on static source analysis
07:23cfleminghugod: Which has its ups and downs
07:24hugodcfleming: clj-refactor supports some of those things, and there are plans to use tools.analyzer to enable things like function extraction (not sure where that work is at)
07:25cfleminghugod: yeah, clj-refactor still has some stuff that Cursive doesn't, but nothing difficult to add, just a matter of time.
07:25cfleminghugod: Cursive now has local binding extraction which is really nice.
07:26hugodyeah, completion includes local bindings in cider now
07:26cfleminghugod: But the auto-import is probably my favourite recent feature - type str/tr<complete> and [clojure.string :as str] gets added to your requires when "trim" is completed.
07:27hugodright - clj-refactor adds auto-import too
07:27cfleminghugod: But only for namespaces you've configured in .emacs, right?
07:27hugodindeed - cursive learns these itself?
07:27cfleminghugod: Yup
07:28cflemingAs long as you have that ns imported with that alias somewhere in your project.
07:28hugodhow do you distinguish the author/project style from the style of some random clj file that you have open?
07:28hugodoh, it is based on files from a single project?
07:29cflemingRight, although since I know all the namespaces I'm going to add a version that pattern matches too, if there's no matching explicit prefix.
07:29cflemingi.e. it'll match str to clojure.string and propose it since clojure.string has a var starting with tr
07:30cflemingIt'll only do that if there's no exact match.
07:30hugodinteresting - I wounder if cider could use completion to do something similar
07:30cflemingI totally recommend it if you can - it's great.
07:31cflemingI'm going to add things like move function from one ns to another soon, that will add and remove the relevant ns decls to the source and target ns
07:31cflemingCursive also marks unused local vars, and will shortly mark unused imports/requires
07:32borkdudein Prismatic Schema, is there something to turn on ^:always-validate for every s/defn during development?
07:37cflemingbeamso: Glad you're enjoying Cursive :-)
07:37hugodcfleming: so mostly advantages stemming from analysing the code iiuc
07:37Sh00ckHello guys, i'm new to clojure (i enjoy it so far). why can't i put a function "under" the call? (IMG: http://url.udev.io/llp9f)
07:37cfleminghugod: Yeah, that's the main difference.
07:38cflemingIt has other advantages - it inherits IntelliJ's debugger support, which is really nice
07:38hugodcfleming: yeah, debugger support can certainly be useful
07:39cfleminghugod: And the IntelliJ inspection infrastructure is nice, it'll allow me to do Kibit/Eastwood right in the editor
07:39cfleminghugod: with quickfixes etc
07:40cfleminghugod: I'll be presenting about all this at the conj if you're there, we should get a beer if so
07:40beamsoSh00ck: because you're calling the function before you've defined it
07:41hugodcfleming: probably will not make it this year :(
07:41cfleminghugod: bummer, next time
07:41Sh00ckbeamso: yeah, but in example Go or Rust it works :o
07:42hugodcfleming: thanks for going through these - interesting to hear what you are up to with Cursive. I should probably fire it up and give it a try :)
07:43cfleminghugod: Hehe, I'd be interested to know what you think!
07:43hyPiRionSh00ck: You can if you do (declare function-name) at the top – but yeah, it's a weird thing you get used to
07:44beamsoSh00ck: true, but it may not work in a shell script or in ruby outside of a class
07:44hyPiRionSh00ck: I think it's done that way to motivate simplicity
07:44hugodcfleming: of course
07:44Sh00ckhyPiRion: thanks! it works :)
07:52kitallisis there a better way to do this http://pastie.org/9533650?
07:56lavokadusing reduce
08:04kitallislavokad, for that I'll have to do a map-indexed
08:10lpvbDDDDDDD"A
08:13lodinkitallis: If you don't want to rewrite it using reduce etc you can still remove the variable "no" and check for (seq (rest coll)) instead.
08:14tobikkitallis: you don't need map-indexed if you use reduce, see http://pastie.org/9533673
08:15kitallistobik, aha
08:15kitallisof course
08:16kitallislodin, that makes sense too
08:16kitallisthanks
08:17lodinkitallis: I don't see any reason to increment i manually though. You only using it in some-fn and i does not effect the next iteration.
08:17lodin*affect.
08:19lodinkitallis: so (map-indexed some-fn coll) looks perfect for the job, no?
08:21kitallislodin, well, some-fn returns a map, which needs to be merged back in
08:23lodinkitallis: Right. So try to move out i, some-fn, and coll from make and see what's left.
08:23kitallisthis was my other version: http://pastie.org/9533686
08:25lodinkitallis: Try replacing (map-indexed vector coll) with (map-indexed some-fn coll) and adjust reduce accordingly.
08:36kitallislodin, i've got it, just struggling with some syntactical mess, one moment
08:47wjlroeIs there a protocol I can extend on a record to provide toString on that record? I currently have a (show) function in my own protocol but (str) doesn't know about it obviously
08:49kitallishttp://pastie.org/9533727
08:49kitallisno idea why i couldn't get the reader macro form working
08:49kitallislodin, thanks a lot!
08:49wjlroeAh the protocol is Object, why didn't I think of that?
08:50lodinkitallis: Nice.
08:51lodinkitallis: You don't need to provide the fn though. Just pass some-fn.
08:52lodinAll you need is (reduce {} (map-indexed some-fn coll)).
08:52lodinerr, (reduce merge ...)
08:53kitallislodin, cool
09:20gfrederickswjlroe: not technically a protocol; Object is special-cased in defrecord (see the docstring)
09:25wjlroegfredericks, ok, I can't see any mention of Object in the docstring and the implementation is a wall of code so that's not clear to me
09:28gfredericks,(-> #'defrecord meta :doc (->> (re-find #".{10}Object.{10}")))
09:28clojurebot"ethods of Object. Note tha"
09:28gfrederickswjlroe: ^ it's there
09:29wjlroeoops missed it
09:30wjlroeMy mistake for attempting to multi-task
09:59J_ArcaneI seem to be a bit stuck on this: http://clojurescriptkoans.com/#destructuring/3
10:01J_ArcaneI tried (str first-name " " last-name " aka" (reduce #(str " " %1 " aka " %2) aliases)) but I seem to get an extra space after the first "aka" so it fails.
10:01justin_smithJ_Arcane: I think you want to use clojure.string/join
10:01justin_smithinstead of that reduce
10:03justin_smithanother bonus, join uses a StringBuilder, which will perform much better than repeated calls to str where the previous partial string is never used again
10:03maxpnhow to refresh dependencies in project.clj? like npm update
10:04justin_smithmaxpn: either restart your process, or use alembic.still
10:04justin_smithmaxpn: or do you mean get newer versions? in clojure it's best to ask for a specific version, you can use lein ancient to see what could be upgraded
10:06maxpnyes. for example I have [org.clojure/data.json "0.2.4"] in my project.clj . is there easy way to know laterst version 0.2.5?
10:06justin_smithlein ancient
10:06maxpnis it separate tool?
10:07justin_smithit comes with lien
10:07justin_smithyou literally go to the project directory and run "lein ancient"
10:07justin_smiththat's the command
10:07maxpn 'ancient' is not a task. See 'lein help'
10:07jeffterrellActually I think it's a plugin.
10:07justin_smithoh, it must be a plugin
10:07jeffterrellAdd this to your ~/.lein/profiles.clj
10:07jeffterrell[lein-ancient "0.5.5"]
10:08jeffterrellIn the [:user :plugins] spot.
10:08maxpnthank you!
10:08jeffterrellI found that plugin a couple weeks ago. Very useful!
10:09justin_smithI got suspicious of upgrading, between clojure.data.json and the various emacs modes for clojure
10:11maxpnis there an easy way to add incremented version number to uberjar?
10:11maxpnbuild number or git hash
10:12maxpnI'd like to have a build number in my web app
10:13maxpnautomatically incremented number.
10:13justin_smithmaxpn: there is a lein plugin for something like that, my google-fu is failing though
10:14justin_smithhttps://github.com/relaynetwork/lein-release
10:15maxpnyes, got it.
10:15maxpnthanx
10:15jeffterrellThe wonderful world of lein plugins. :-)
10:15J_Arcanejustin_smith: Thanks, that worked: (clojure.string/join " " (list first-name last-name "aka" (clojure.string/join " aka " aliases)))
10:16justin_smithjeffterrell: maxpn: lein is where most dev tooling happens (that isn't editor specific at least)
10:16justin_smithJ_Arcane: cool, that looks about right, yeah
10:17jeffterrellI found a plugin the other day that made it super easy to deploy my backend API server as an Ubuntu service. I think it was called init-script. I love not having to worry about that sort of stuff.
10:21maxpnbut how can I get project.clj/version number at runtime?
10:21justin_smithmaxpn: it will be in the pom.xml - I know there is a way to access that, one moment
10:23maxpnpom.xml? i don't have that in my project.
10:24justin_smithmaxpn: lein jar / lein uberjar generate one
10:24justin_smithand if you aren't using one of those to deploy, you are doing it wrong
10:26justin_smithmaxpn: try (System/getProperty "myproject.version")
10:28justin_smithwith myproject being changed to the project version of your project, of course
10:28maxpnI could just create and update myproj/version.clj: (def VERSION "1.2.3 build NNNN") every time I do uberjar
10:28justin_smithmaxpn: try the getProperty thing first
10:28maxpnbut I hope there already is a plugin for that/
10:29justin_smithoh, wait - the getProperty thing only works from within lein
10:29justin_smithcheck this thread https://groups.google.com/forum/#!topic/leiningen/7G24ifiYvOA
10:29PeakCodelein pom
10:30justin_smithPeakCode: that generates a POM, but that's not what we are talking about
10:30PeakCodeOK, sorry.
10:31justin_smithmaxpn: if you create a file with those contents, put it under resources rather than source
10:31justin_smithsince it's data, not code
10:52bounbhm, strange error when i try "lein koan run", any clues? https://www.refheap.com/89957
10:54justin_smithbounb: looks like it is related to the whole https for maven fiasco
10:54bounbi see... what to do?
10:55justin_smithyou could downgrade to 2.4.2 temporarily "lein upgrade 2.4.2"
10:55bounbthanks!
10:57bounbjustin_smith: oh, i am on 2.4.2...
10:57justin_smithugh
10:57justin_smithdunno then
10:57justin_smithtry 2.4.3 just for getting the deps, then switch back?
10:58bounbk
10:58justin_smithvia lein deps of course
11:00bounbno dice, lein deps gives me same error
11:00justin_smithmaybe clojure koans is messed up? I am going to try
11:01bounbcheers
11:01PeakCodeI think the problem is with the JDK. Try using another one.
11:02justin_smithbounb: lein deps finds all of it on the first try here (2.4.2)
11:02bounbgood idea. using Java 1.7.0_65 OpenJDK 64-Bit Server VM atm. i'll try 1.8
11:02justin_smithI am using oracle jdk 1.8
11:02bounbthx, will upgrade
11:08bounbstill no good, although it's now complaining about clojars.org rather than maven.org
11:08bounbi refuse to believe it's an issue caused by OpenJDK vs Oracle...
11:26technomancybounb: it could be OS-installed jdk vs manually-installed jdk
11:26technomancythe OS-provided one usually integrates better with the existing certificate store
11:28bounbi just installed them with my package manager, i have openjdk 7 and 8, seems to be same issue with both
11:29technomancyit could be a proxy trying to MITM you or something
11:30hyPiRionbounb: it's a CA-cert store issue iirc
11:30bounbi think that's it hyPiRion, was reading some github issues
11:30bounbnot sure what to do though
11:32hyPiRionbounb: try to install ca-certificates for java. It's e.g. ca-certificates-java for debian/ubuntu
11:32hyPiRionso `sudo apt-get install ca-certificates-java`
11:33bounbi had that, but i reinstalled it and it works. thanks!
11:34hyPiRionah, nice
11:38bounbclojure is just quality from the ground up, community n all
11:44justin_smithwe try
11:45dbaschand catch
11:46J_ArcaneI'm impressed by the fact that Clojure seems the only Lisp community that understands the value of interactive learning tools. :P
11:46dbasch(= (type justin_smith) Duck)
11:46justin_smithJ_Arcane: dunno, racket may be superior onthat account
11:47justin_smithJ_Arcane: racket was designed from the beginning to be a teaching / learning language
11:47J_Arcanejustin_smith: DrRacket is a great starter IDE, but the learning process is still fundamentally "read this book and type in/solve the exercises on your own". By interactive tools I mean stuff like codecademy or the koans.
11:48justin_smith4clojure too?
11:48J_ArcaneYeah.
11:50dbaschthat may be just because is newer, languages invented in the past 5-10 years tend to have good interactive tutorials and tools
11:50dbasche.g. go, Rust
11:51J_ArcaneThere is a web REPL for Racket, but it's not actually hosted anywhere ATM.
12:23MethodicalI am trying to test a post to a liberator rest endpoint. I can write a successful test for a get request but I can't seem to manage to pass data to the post. Here is the code I am using https://www.refheap.com/89958
12:29lpvbi/w zoom
13:21jeffterrellJ_Arcane: I've heard that The Little Schemer takes an inductive learning approach, FYI. Though of course that's different than a community valuing the approach.
13:22J_Arcanejeffterrell: I've heard good things about it as well, and of SICP.
13:22jeffterrellYeah, definitely SICP. Gotta love that one.
13:23jeffterrellMethodical: Cool that you're using Liberator. I've heard good things. But I've never used it, so can't help you.
13:23gtrakwhat's the best thing for a CLJS slideshow?
13:24Methodical@jeffterrell Liberator is really pretty nice and so far straight forward to use. I think it is more of a ring-mock question that liberator though.
13:25jeffterrellgtrak: Kids these days seem to be using reveal.js a lot. (cf. slides.com) Since CLJS has JS interop, you could use that.
13:25jeffterrellDunno about a particular CLJS slideshow library/tool though.
13:26gtrakI've played with that, also considering gorilla-repl/session.. or just org-mode..
13:26gtrakmight be nice to do the whole thing as an om app
13:26gtrakwithin reveal
13:28jeffterrellThat would be cool.
13:29jeffterrellI love the idea of "notebook" style programming that gorilla gives you.
13:30bounbthe guy that wrote gorilla introduced me to clojure
13:30bounbis he in here, need to thank him for that
13:30jeffterrellMethodical: Nothing looks wrong to me in your example, but there's plenty of stuff I'm not familiar with, not having used Liberator. I do wonder whether Liberator is smart enough to find the request map with a ring `(ANY [_] ...)` endpoint, instead of something more like `(ANY [_ :as req] ...)`, but I dunno.
13:31justin_smith(ANY [_} ..) is not ring, it's compojure
13:31lavokadhi, in myapp.routes.home namespace there is (defroute myroutes (GET "/page.html" [] (layout/fun))). This file is myapp/routes directory. In my project.clj ring section there is reload? true. When I change layout/fun to something different I have to reload the server to see the changes
13:32goraciohi there - who can help with deployment and hosting clojure app ? i think about immutant and using WildFly but there are some questions about it
13:32justin_smithlavokad: set your handler by referring to the var
13:32justin_smith#'handler instead of handler
13:33justin_smithlavokad: the issue is that ring does not see changes to the def unless you set the handler to the var - it does the resolution once and doesn't see any updates
13:34justin_smithbut it knows that it needs to deref on each request if you use the var form
13:34hellofunki'm trying to get the js equiv of foo.add(bar) in clojurescript. lein compiler reports Unknown dot form of (. foo -add (bar)) -- which is an expansion doesn't make sense since bar is not a function.
13:35justin_smithwait, how are you trying to invoke that?
13:36justin_smithfoo.add(bar) should translate to (.add foo bar)
13:37hellofunkjustin_smith why not .-add, isn't that for functions?
13:37justin_smith.-add is for properties
13:37ben_vulpeshow does one do the {:keys } destructuring when ones keys are strings and not :keywords ?
13:37justin_smithnot for methods
13:37justin_smithben_vulpes: :strings
13:37ben_vulpesoooooh
13:38justin_smithif they had a sense of humor it would be "strings"
13:38ben_vulpesi tried that!
13:38justin_smith{"strings" [a b c]}
13:38justin_smithheh
13:38goracioso anyone running clojure sites with immutant ?
13:38lavokadjustin_smith: however if modify anything in myapp.handler then everything reloads. Moreover, from this moment I can also change myroutes.routes.home and the everything reloads in the browser
13:39justin_smithlavokad: so only certain spaces don't get reloaded?
13:41lavokadright. and just until I do a change in myapp.handler namespace. From that moment every namespace I change reloading happens well
13:41justin_smithvery odd
13:42justin_smithdid you add the new namespaces whil the app was still running by any chance?
13:42lavokadSo i start the server, go to myapp.handler, put a space there, save, and then it is ok
13:42lavokadjustin_smith: no, i didnt
13:54dorkmafiaso i'm really new to clojure and trying to figure out how i can make a program taht uses interfaces..
13:56justin_smithdorkmafia: do you have a specific java interface that already exists, which you want to implement?
13:56narayanai am using emacs live great stuff
13:56dorkmafianope i'm starting from scratch :)
13:56justin_smithin clojure, it makes more sense to define a multimethod or protocol
13:56dorkmafiai'm going to make a bot and I would like to abstract the messenger client
13:57justin_smithunless you need the interface to be callable from java
13:57justin_smithyeah, use a protocol or multimethod for that
13:57justin_smithmultimethods are more flexible (they can dispatch using an arbitrary function on all args, not just the type of the first arg) but protocols perform better
13:58justin_smithprotocols are trickier in interactive development too
13:58justin_smith(that is, they get tricky if you need to redefine them)
13:59dorkmafiak thanks i'll check it out more..
13:59dorkmafia:)
14:07benmosscan someone explain to me why `(java.nio.file.Files/createTempDirectory nil)` throws “No matching method”? http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createTempDirectory(java.lang.String,%20java.nio.file.attribute.FileAttribute...)
14:08justin_smiththat's a vararg method, right?
14:08benmossyeah, ah that is it again
14:08justin_smithyou need to pass an empty FileAttribute array as the last arg
14:09benmosswhereas in Java passing just null would be fine? `Files.createTempDirectory(null)`
14:10justin_smith,(into-array java.nio.file.attribute.FileAttribute [])
14:10clojurebot#<CompilerException java.lang.ClassNotFoundException: java.nio.file.attribute.FileAttribute, compiling:(NO_SOURCE_PATH:0:0)>
14:10justin_smithbenmoss: right
14:11benmossdo you know why Clojure can’t behave the same way? just curious
14:11justin_smithbecause varargs are a fiction
14:11justin_smiththey are actually an array argument, the javac compiler just pretends they are separate args
14:11justin_smiththe clojure compiler has no such feature
14:12benmossah
14:12justin_smithsimilarly, we can't do generic collections in clojure (though due to lisp style typing, we don't notice that)
14:12benmossand in the absence of the argument the java compiler creates an empty array
14:12justin_smithbenmoss: it takes all args after the nth (which may be none) and makes an array of the proper type
14:12justin_smithand that is what the method sees
14:13benmossgotcha
14:13benmosscool, that helps, thanks :)
14:14hellofunkwhat is the clojurescript equiv of this: document.body.appendChild(renderer.domElement);
14:14hellofun`i'm trying this: (dom/appendChild (.body (dom/getDocument)) (.domElement renderer))
14:19benmossi believe `(.appendChild (.-body js/document) (.-domElement renderer))`
14:20hellofunkbenmoss: thanks
14:34timothywIn test.check, I see generators like gen/keyword, gen/vector, etc.
14:34timothywBut I don't see a generator for sets (gen/set)
14:35timothywIs there a preferred semantic for for generating sets?
14:37lavokadi'm gonna ask this again, just in a bit clearier way
14:37lavokadI do lein new compojure-app testing. Then I go go routes/home.clj and add a function called home2 which prints "hello me". Then I change (GET "/" [] (home2)). Reload chrome, still hello world. I do to handler.clj, put a new line, save and now chrome refreshes with "hello me". Moreover, I go to back to home.clj and change (GET...) back to home. Chrome refreshes now with hello world.
14:42gfrederickstimothyw: (gen/fmap set (gen/vector g)) isn't terrible
14:43arrdemtimothyw: sets of what?
14:43gfrederickslavokad: did you save the first time?
14:43timothywgfredericks: ah, what’s the ‘g in (gen/vector g)
14:43lavokadgfredericks: sure
14:44timothywarrdem: well, in my case, a “group” can have a set of “users”
14:44J_ArcaneFizzBuzz in a tweet (clojure): (map #(cond (= 0 (mod % 15)) "FizzBuzz" (= 0 (mod % 3)) "Fizz" (= 0 (mod % 5)) "Buzz" :else %) (range 1 100))
14:44J_ArcaneAny pointers on possibly shortening that further?
14:44gfrederickstimothyw: your underlying generator; for the elements of the set
14:45gfredericksJ_Arcane: are you golfing or wondering about idiomatic code?
14:45timothywgfredericks: ah right
14:45arrdemtimothyw: right. and users have some representation. my point is that a "keyword" is an actual set of atomic values where as a "set" is a distinct potentially ordered collection of arbitrary values. Consequently there is no baked in "set" generator because you want a set of _something_.
14:45gfredericksJ_Arcane: I think condp could handle that
14:46J_Arcanegfredericks: Just new to the language and playing.
14:46timothywarrdem: riiight, ok got that… then why’s “gen/vector” there?
14:46J_ArcaneI'll look at condp.
14:47arrdemtimothyw: because gen/vector is parametric on the set of things that can be in the vector. that's the 'g gfredericks used above.
14:47gfredericksarrdem: a hypothetical gen/set could work the same way
14:47arrdemgfredericks: sure I'm just trying to drive home why it would have to be generator parametric
14:48gfredericksI didn't think there was confusion about that
14:48gfredericksbut I am trying to not listen to thomas the tank engine at the same time
14:49noncomanyone using ccw here? how does it work with java 8 and eclipse luna ?
14:50timothywarrdem: ok, I think I’ve got it… I’m going to try the fmap approach
14:50arrdemtimothyw: good luck!
14:50timothyw:)
14:50tadni_noncom: ccw being counterclockwise, the package for eclipse that bundles clj?
14:51J_Arcanegfredericks: Nice. Even shorter: (map #(condp = 0 (mod % 15) "FizzBuzz" (mod % 3) "Fizz" (mod % 5) "Buzz" %) (range 1 100))
14:51noncomtadni_: right
14:52tadni_noncom: I remember reading it works with Java 8, I'm not sure about different variants of Eclipse.
14:52dbaschJ_Arcane: your :else could be anything truthy, e.g. 1
14:52noncomi see ...
14:55J_Arcanedbasch: I'm not sure what you mean. The result appears valid anyway.
14:55gfredericksJ_Arcane: you should be able to include the mod logic in the predicate
14:55gfredericks,(doc condp)
14:55clojurebot"([pred expr & clauses]); Takes a binary predicate, an expression, and a set of clauses. Each clause can take the form of either: test-expr result-expr test-expr :>> result-fn Note :>> is an ordinary keyword. For each clause, (pred test-expr expr) is evaluated. If it returns logical true, the clause is a match. If a binary clause matches, the result-expr is returned, if a ternary clause matches, i...
14:55J_Arcanegfredericks: That's the thought I had, but I've had trouble figure out how to simplify it.
14:56dbaschJ_Arcane: I meant, for the version in which you were using cond, :else could be anything truthy (e.g. a digit or a symbol)
14:56dbaschalso, technically that’s not FizzBuzz because you’re not printing anything :)
14:56gfredericks(condp #(zero? (rem %2 %1)) n 15 "FizzBuzz" 5 ...)
14:56J_ArcaneHeh, that's a fair point.
14:56gfredericksJ_Arcane: ^
14:56J_ArcaneAha, yes. (didn't know about rem)
14:58hyPiRion#(case (mod % 15) 0 "FizzBuzz" (3 6 9 12) "Fizz" (5 10) "Buzz" %)
14:59gfredericks(inc hyPiRion)
14:59lazybot⇒ 44
14:59gfredericksJ_Arcane: ^ don't do that that's weird
15:00J_ArcaneHeh heh,
15:01hyPiRioncore match is also good for fizzbuzz
15:06J_ArcaneHmm. The (rem) solution actually winds up costing me one character, because I have to switch map's function from # to fn.: (map (fn [x] (condp #(= 0 (rem %2 %1)) x 15 "FizzBuzz" 3 "Fizz" 5 "Buzz" x)) (range 1 100))
15:11hyPiRionJ_Arcane: flip the fn and #
15:12hyPiRion#(condp (fn [x y] (= 0 (rem y x))) ..)
15:16J_ArcaneNope. Still 1-char longer. (map #(condp (fn [x y] (= 0 (rem y x))) % 15 "FizzBuzz" 3 "Fizz" 5 "Buzz" %) (range 1 100))
15:21arrdemGrimoire 0.3.6 incoming... bunch of basic maintenance fixes and a new static site build.
15:33J_ArcaneDamn. there's a 77-char FB solution logged at anarchy golf. I wonder how they did it. By the time I get it to print I'm at 114.
15:39dbaschJ_Arcane: here’s one in 80 http://clojurefun.wordpress.com/2012/09/21/code-golf-in-clojure/
15:41gfredericks,mod%
15:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: mod% in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:41gfredericks,#(mod% 3)
15:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: mod% in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:42gfredericksthat can't work
15:42gfredericks,(map #(let[t(mod% 3)z{0"Fizz"}]({0(str(z t)'Buzz)}(mod% 5)(z t%)))(range 1 101))
15:42clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: mod% in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:42gfredericks,(map #(let[t(mod % 3)z{0"Fizz"}]({0(str(z t)'Buzz)}(mod% 5)(z t %)))(range 1 101))
15:42clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: mod% in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:42gfredericks,(map #(let[t(mod % 3)z{0"Fizz"}]({0(str(z t)'Buzz)}(mod % 5)(z t %)))(range 1 101))
15:42clojurebot(1 2 "Fizz" 4 "Buzz" ...)
15:43gfredericksis there an older version of clojure where that parses as two symbols?
15:43gfredericks&(map #(let[t(mod% 3)z{0"Fizz"}]({0(str(z t)'Buzz)}(mod% 5)(z t%)))(range 1 101))
15:43lazybot⇒ (1 2 "Fizz" 4 "Buzz" "Fizz" 7 8 "Fizz" "Buzz" 11 "Fizz" 13 14 "FizzBuzz" 16 17 "Fizz" 19 "Buzz" "Fizz" 22 23 "Fizz" "Buzz" 26 "Fizz" 28 29 "FizzBuzz" 31 32 "Fizz" 34 "Buzz" "Fizz" 37 38 "Fizz" "Buzz" 41 "Fizz" 43 44 "FizzBuzz" 46 47 "Fizz" 49 "Buzz" "Fizz" 52 53 "Fiz... https://www.refheap.com/89960
15:43gfredericksI guess so
15:43gfredericks&'#(mod% 3)
15:43lazybot⇒ (fn* [p1__22095#] (mod p1__22095# 3))
15:43gfredericks&'#(mod%3)
15:43lazybot⇒ (fn* [p1__22106# p2__22107# p3__22105#] (mod p3__22105#))
15:43dbaschgfredericks: prior to 1.5
15:44J_ArcaneYou can save some characters by ditching the map and doseq'ing over the sequence: (doseq[i(range 1 101)](println(#(condp = 0 (mod % 15) "FizzBuzz" (mod % 3) "Fizz" (mod % 5) "Buzz" %)i)))
15:44J_ArcaneBut that's still 105, and I'm not sure much more space can be removed without it failing. (I found the issue with the mod% as well)
15:46dbasch,(doseq[i(range 1 101)](println(#(condp = 0(mod % 15)"FizzBuzz"(mod % 3)"Fizz"(mod % 5)"Buzz"%)i)))
15:46clojurebot1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n16\n17\nFizz\n19\nBuzz\nFizz\n22\n23\nFizz\nBuzz\n26\nFizz\n28\n29\nFizzBuzz\n31\n32\nFizz\n34\nBuzz\nFizz\n37\n38\nFizz\nBuzz\n41\nFizz\n43\n44\nFizzBuzz\n46\n47\nFizz\n49\nBuzz\nFizz\n52\n53\nFizz\nBuzz\n56\nFizz\n58\n59\nFizzBuzz\n61\n62\nFizz\n64\nBuzz\nFizz\n67\n68\nFizz\nBuzz\n71\nFizz\n73\n74\nFizzBuzz\n76\n77\nFizz\n7...
15:46dbaschJ_Arcane: ^
15:48J_ArcaneAhh, yup, looks like I was too cautious.
15:48J_ArcaneThat makes 98. :D
15:51J_ArcaneI think I'll break there, need sleep soon. thanks for the help.
16:40SagiCZ1hi guys.. is there a way to list all available methods i can call on a particular java object?
16:46SagiCZ1,"am i here?"
16:46clojurebot"am i here?"
16:46arrdem#clojure is pretty quiet on sunday
16:48SagiCZ1arrdem: how come? is everyone in church?
16:49mdeboardSunday is the day we rest from an arduous week of human and animal sacrifice
16:49PeregrinePDXSpending time with friends and family I would guess
16:49mdeboardor that
16:50SagiCZ1why are we here then
16:50mearnshirc in church
16:51SagiCZ1hi-tech
16:58mearnshdedication
17:00mdeboardirc is love
17:00mdeboardirc is life
17:02danneusunday is my hammock time
17:04mdeboardrhickey would be proud
17:05mearnshchurch of rhickey
17:05mdeboardHammock-shriven Development
17:05mearnshhaha
17:05mdeboardI had to look up "shriven" to make sure I got the definition right
17:06mdeboard"hear the confession of, assign penance to, and absolve (someone)."
17:06mdeboardchurch-appropriate.
17:06mearnshi had to look it up to double check i got the joke
17:06mdeboardlolol
17:16gfrederickshuh.
17:16gfredericksformat strings default to exactly 6 decimal places
17:46tadni_"Instarepl" in Lighttable is pretty neat.
18:10jeffterrellWhy does this work:
18:10jeffterrell,(meta (with-meta inc {:a 1}))
18:10clojurebot{:a 1}
18:10jeffterrellBut this doesn't?
18:11jeffterrell,(meta ^{:a 1} inc)
18:11clojurebotnil
18:12tadni_I don't think I like Lighttable as much as Emacs, but I have a lot more of a liking than I intially thought I would.
18:14jeffterrellRead up on http://clojure.org/metadata to make sure I'm not missing something obvious, but it said both forms should be equivalent.
18:18Bronsajeffterrell: the ^{:a 1} is putting the meta on the symbol inc
18:18Bronsa(with-meta inc {:a 1}) is putting the meta on the function
18:19Bronsa,(def a 1)
18:19clojurebot#'sandbox/a
18:19Bronsa,^:foo a
18:19clojurebot1
18:19Bronsa,(with-meta a {:foo 1})
18:19clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IObj>
18:19Bronsajeffterrell: ^ is it more clear now?
18:20jeffterrellI'm not sure how your examples help, but I get what you're saying about metadata being applied to the symbol rather than the function.
18:21Bronsajeffterrell: so in the case of ^:foo x, the compiler will see the metadata -- in the case of (with-meta x {:foo true}) the compiler doesn't but the runtime value of x does
18:21jeffterrellThat would explain the behavior, but it seems (a) like the reader macro is a pretty useless feature if that's true, and (b) at variance with the docs.
18:22Bronsajeffterrell: that's neither the case :)
18:22jeffterrellHeh, that's good. :-)
18:22jeffterrellOK, so you're saying it's a run-time vs. compile-time thing?
18:22Bronsarun-time vs read-time actually
18:22jeffterrellOK
18:23Bronsathis is because the compiler "replaces" symbols with the value of the Var they're pointing at
18:23Bronsa,(meta ^:foo [1])
18:23clojurebot{:foo true}
18:23Bronsa,(meta (with-meta [1] {:foo true}))
18:23clojurebot{:foo true}
18:24Bronsain case of collection literals, it "works" as you might expect it to work for symbols too
18:24jeffterrellAh, because there's no var-lookup for collections. Interesting.
18:24jeffterrellHmm, what happens with a function literal?
18:24jeffterrell,(meta ^:foo #(+ 1 %))
18:24clojurebot{:foo true}
18:25jeffterrellInteresting. So it's really that symbols-pointing-to-vars are the special case here.
18:25Bronsathat's not a "feature" of function literals, it works for (fn [] ..) too
18:25jeffterrellThat's surprising…to me at least. :-)
18:25jeffterrellSorry, I meant anonymous functions, not function literals.
18:25Bronsafn and reify are documetned to propagate the read-time metadata to the run-time object they return
18:25jeffterrellOh interesting.
18:26Bronsawell, reify is. fn I'm not sure but the implementation does it
18:26jeffterrell,(meta ^:foo (fn [x] (+ 1 x)))
18:26clojurebot{:foo true}
18:26Bronsa,(doc reify)
18:26clojurebot"([& opts+specs]); reify is a macro with the following structure: (reify options* specs*) Currently there are no options. Each spec consists of the protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [args+] body)* Methods should be supplied for all methods of the desired protocol(s) and interface(s). You can also define overrides for meth...
18:26Bronsawell
18:26jeffterrell,(meta ^:foo inc)
18:26clojurebotnil
18:26Bronsa"reify always implements clojure.lang.IObj and transfers meta data of the form to the created object."
18:27Bronsa^ that's from the docstring of reify
18:27jeffterrellOK, makes sense.
18:27Bronsajeffterrell: the difference there is that the compiler knows at compile time that (fn []) and (reify) WILL be able to have metadata attached to them
18:27Bronsawhile for a var, that's not the case
18:28Bronsabecause var are dereferenced at runtime
18:28Bronsavars*
18:29jeffterrellHmm, it's still not quite clicking for me, but maybe this question will help me understand.
18:30jeffterrellHow would I access the metadata if I say `^:foo inc`? You said it's attached to the symbol inc? Can I access the `{:foo true}` map somehow?
18:30Bronsajeffterrell: you can't access it
18:30Bronsathe compiler has it at compile time
18:30Bronsabut at runtime it doesn't exist
18:30Bronsayou can access it via a macro though
18:30Bronsa,(defmacro x [y] (list 'quote (meta y)))
18:30clojurebot#'sandbox/x
18:30Bronsa,(x ^:foo inc)
18:30clojurebot{:foo true}
18:32jeffterrellAhh, OK, I think I got it. The compiler sees all the metadata that is attached via the ^ reader macro form. Then it passes it on to the actual object (available at run time) in certain situations. But the symbol-referencing-a-named-fn case is not one of those situations.
18:32jeffterrellIs that about right?
18:32Bronsajeffterrell: yes
18:32jeffterrellIs that the significance of this error message:
18:32jeffterrell,(meta ^:foo "s")
18:32clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Metadata can only be applied to IMetas>
18:33Bronsano
18:33Bronsajeffterrell: metadata can only be applied to some clojure objects
18:33Bronsathose objects whose class implements the interface clojure.lang.IMeta
18:33jeffterrellAh, OK, that makes sense.
18:34Bronsayou can attach metadata to: the clojure collections, the clojure referenec types, reify, functions and defrecords
18:34Bronsayou can't attach metadata to strings & keywords for instance
18:34jeffterrellHmm, alright. Good to know.
18:35Bronsaeven though keywords are clojure objects, they are interned so metadata wouldn't make any sense
18:35jeffterrellThanks a lot for explaining, Bronsa. That is super helpful!
18:35jeffterrellLet's see if this works:
18:35jeffterrell(karma Bronsa)
18:36Bronsajeffterrell: it's (inc username) :)
18:36jeffterrell(inc Bronsa)
18:36lazybot⇒ 48
18:36jeffterrellSweet!
18:44hyPiRionit's
18:44hyPiRion(identity Bronsa)
18:44lazybotBronsa has karma 48.
18:48jeffterrellWeird, I would think that would return 'Bronsa :-)
18:49jeffterrellBronsa: Oh, one other question, what did you mean, "the Clojure reference types"?
18:50jeffterrellI'm guessing that either means things like refs and atoms (because they refer to something and can be deref'd) or else the basic types like int, float, etc.
18:52Bronsajeffterrell: yeah ref, atoms, agents, vars etc
18:52jeffterrellOK, makes sense, thanks.
19:24augustljust did (defn my-fn [{:keys test}] ...) and got the error "java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol". The error is obvious, but the error message is pretty bad, and it's not the first time Clojure doesn't yield readable errors
19:24augustldoes the clojure compiler have suboptimal error handling for performance reasons?
19:24augustlor is it just that nobody has cared to improve it yet?
19:25augustlis it perhaps one of the biggest challenges of functional programming - in order to handle errors well, you need to manage and pass around a "context" all the time everywhere? :)
19:26hyPiRionaugustl: see https://www.youtube.com/watch?v=o75g9ZRoLaw on improved error messages from macros
19:26justin_smithaugustl: my take is that we just don't make much use of validation
19:31augustlthe error in question is probably that way because way down in a function somewhere a seq is being created, and at that point there is no information about which line number, file etc the error occurred in
19:31augustlhyPiRion: saved for later, have to be silent right now :)
19:32hyPiRionMe too :) I should in theory be in bed as well
19:35augustlhyPiRion: seems like this particular instance was macro related, btw
19:35augustlthe error has a nice line number in it, but it's the line where the macro is invoked :)
19:38cbarrettI'm coming from a Scheme background -- why does clojure have keywords? What's the advantage of :foo over 'foo?
19:39beamso,(:foo {:foo "bar"})
19:39clojurebot"bar"
19:39hyPiRion,('foo {'foo "bar"})
19:39clojurebot"bar"
19:39llasramcbarrett: Clojure symbols can carry metadata, which means two symbols can be equal but not reference-identical and have different metadata
19:39cbarrettWhen is that useful?
19:39llasramcbarrett: Whereas equal keywords are also guaranteed to be reference-identical
19:40cbarrettI'm sure there's a reason for all this, just trying to understand
19:41llasramcbarrett: Clojure uses metadata in a variety of ways, but metadata on symbols is used most commonly to communicate type information to the compiler or to macros
19:41cbarrettWhat sort of type information do symbols carry? Don't they evaluate to themselves?
19:42hyPiRioncbarrett: what I found as more important is that keywords evaluate to themselves.
19:42hyPiRioncbarrett: for example
19:43hyPiRion,(let [x (with-meta 'foo {:lineno 10, :column 8})] (meta x))
19:43clojurebot{:column 8, :lineno 10}
19:43hyPiRionCould, in theory, be used to give better error messages
19:44llasramcbarrett: Or for a type example:
19:45llasram(fn [^String s] (.index s "\n"))
19:45cbarrettHmm.
19:45cbarrettI'm not really following.
19:46cbarrettIt seems like kind of a wart...
19:46llasramThe ^String is metadata syntax, shorthard actually for ^{:tag String}
19:46llasramThat communicates to the compiler that `s` is of JVM type `String`, which allows it to emit code which directly invokes the `.index` method vs using (much slower) runtime refelction
19:48cbarrettI'm very new to Clojure so I feel like I'm missing something or it's a taste / style thing
19:48cbarrettBut it just seems like pushing implementating details into the user's lap
19:48cbarrettLike the loop / recur thing (which I understand is needed given the nature of the JVM etc)
19:49cbarrettNot trying to criticize, just trying to figure out where the gap is.
19:50llasramcbarrett: I think there's some of that (pushing implementation details)
19:51llasramClojure symbols support metadata (along with most Clojure data structures) which prevents equality from being identical with reference identity
19:51cbarrettMy background is Scheme (and Haskell) so
19:51llasramThe latter is a useful property, so Clojure has a separate type with that property, which also happens to have the additional useful property of `eval`ing to itself
19:52cbarrettHm.
19:52cbarrettSo symbols aren't atoms then?
19:53cbarrettIn the general sense of that temr
19:53llasramThe atom vs not distinction isn't as clear on Clojure
19:53cbarrett*term
19:53cbarrettI don't know the clojure definition of it
19:53cbarrettThe general sense being an inlined string ensuring pointer quality and value equality are isomorphic
19:53arrdemIn Clojure an "atom" is a distinct atomic reference type. It's not used to describe whether a value can somehow be traversed or partitioned as in other lisps.
19:54cbarrettyeah I didn't know about that
19:54llasramcbarrett: Symbols are (Scheme-wise) atoms in the sense that they aren't collections, but like I said before -- they don't have the pointer=value equality property
19:54cbarretthm
19:54cbarrettOK
19:54cbarrettSeems weird but
19:55cbarrettRecovering the property of pointer equality being a proxy for value equality seems useful.
19:55llasramcbarrett: Exactly, and that's what keywords provide
19:55cbarrettDon't quite undertsand why that property was lost in the first place
19:56llasramcbarrett: AFAICT, because rhickey decided that it would be useful for symbols to carry metadata
19:56llasramThis appears to be going a bit circular
19:56cbarrettNo that's a good explanation
19:56cbarrettThank you
19:56arrdemClojure: Rich made a design decision and the rest of us choose to live with it
19:57cbarrettThat's perfectly fine
19:57cbarrettTrying to understand those design decisions & build intuition
19:59hyPiRioncbarrett: I agree that recur is also an implementation detail pushed onto the users, but I've found it somewhat helpful actually. In Scheme or Haskell, I can't immediately see whether a function is tail-recursive or not when it calls itself, but I do in Clojure.
19:59cbarretthyPiRion: explicit recursion is the goto of functional programming
19:59cbarrettmorphisms being the structured programming alternative.
20:02hyPiRionwell, at times I've had to implement things which doesn't overflow the stack. At that point it's reassuring to know that the function is tail recursive.
20:03justin_smithcbarrett: morphism as in "If f is a morphism with source object A and target object B, we write f : A ⤇ B."?
20:03hyPiRionConsider the difference between stric and lazy fold in Haskell, for instance.
20:03cbarrettYeah
20:03cbarrettThere's a whole library of these things
20:03cbarrettwith scary sounding greek names but they're just patterns
20:03cbarrettYou've probably implemeneted e.g. paramorphisms before
20:05cbarrettMany of these structured recursion patterns can be transformed an interative comuptation or can be written to use a side-channel stack rather than the language's call stack.
20:05justin_smithcbarrett: scala isn't very popular around these parts in general, but from what I've seen that kind of approach is much more compatible with scala than clojure
20:05cbarrettNever written any Scala
20:05cbarrettMy introduction to this stuff was thru Haskell and category theory.
20:06cbarrettWas looking at doing source transformation using them and then trying to make assertions about whether two transformations composed cleanly, etc.
20:07cbarrettReducers and transducers seem like they'd fit well into such an algebraic formalism.
20:07justin_smithnot to say you cannot do ct informed clojure, but it'll be a fight, and an odd fit. There are lens and monad libraries, but they don't get used much, because they are complex to use, harder to use than standard clojure, and perform poorly.
20:08cbarrettSure, I'm not trying to
20:08cbarrettjust that's the intuition I hve.
20:08justin_smithgot it
20:10justin_smithcbarrett: we have functions like map, iterate, and reduce, which are almost always preferable to a raw recursion scenario
20:10justin_smithbut on the odd instance recur is clearer
20:11cbarrettjustin_smith: indeed. these morphisms I mentioned are just generalized versions of those that work on any structure, not just lists / sequences (e.g. trees)
20:11cbarrettsame intuition
20:11cbarrettjust with more types ;)
20:15BAMbandaDoes anyone have a hack for the clojure repl? Can we get command history and syntax highlighting without being in emacs and without rlwrap?
20:15BAMbandaAlso I prefer the actual clojure jar instead of the lein repl ...
20:15justin_smithBAMbanda: nrepl supports middleware, so it's at least possible
20:15justin_smithoh, well nrepl is the lein repl, so good luck
20:16justin_smithnrepl will be easier to extend than the one built in
20:16BAMbandahmm, I have the latest lein, and haven't done anything to profiles.clj and get weird error messages
20:16BAMbandajustin_smith, let me show you a pastie
20:17justin_smithfeel free to share
20:17BAMbandahttp://pastie.org/9534957
20:18justin_smithlooks like 2.4.3
20:18justin_smith(lein 2.4.3 that is)
20:19justin_smithtry "lein upgrade 2.4.2"
20:19BAMbandahmm, let me try
20:19justin_smiththe error goes away if you run lein inside a project directory
20:19justin_smiththe lein team did not catch the error, because they only run lein repl inside projects
20:20BAMbandainteresting, whatever happened to the idea of exploratory hacking diaries
20:20justin_smithBAMbanda: dunno - I use projectless repls all the time, but it's uncommon among more experienced clojure devs for some reason
20:21BAMbandajustin_smith, perfect it workds now. Do you accept bitcoins>
20:21BAMbanda?
20:22justin_smithno, thanks anyway though
20:22BAMbandasure
20:22arrdem(inc justin_smith) ;; they're both internet points
20:22lazybot⇒ 74
20:23BAMbanda(inc justin_smith)
20:23lazybot⇒ 75
20:23BAMbanda:)
20:24BAMbanda(def justin_smith (* justin_smith justin_smith))
20:24justin_smithheh
20:24justin_smitharrdem: if only I could trade in #clojure karma for drugs
20:24arrdemjustin_smith: STARTUP IDEA GOGOGOGO
20:24BAMbandatoo bad the ram will clear and your outta luck
20:25justin_smithBAMbanda: clojurebot uses a db of some sort
20:25BAMbandahmmmm, time to hackk
20:25arrdemjustin_smith: mongo. if the ram clears no karma :P
20:25justin_smithheh, got it
20:29jeffterrellBAMbanda: As far as command history goes, the regular `lein repl` should support the standard readline bindings out of the box, e.g. ^P and ^N.
20:29jeffterrellCan't help you with syntax highlighting. That would be cool though.
20:30justin_smithjeffterrell: well, one of his requirements was that he doesn't want to use lein repl
20:31jeffterrellHeh, fair enough.
20:31jeffterrellMissed that part.
20:33BAMbandanahh, its fine now. I just had a lot of trouble with lein for a while, java specifically (security certificate/maven issues)
20:34BAMbandaRuby has a project called pry, that replaces its standard "repl" called irb and it is jammmmmmm_packed with features
20:34justin_smithBAMbanda: yeah, there has been some weirdness with the latest lein release
20:34BAMbandaThe ability to launch default editors to edit source, syntax highlighting, plugins, and a bunch of stuff.
20:34BAMbandalein carries the same potential
20:35BAMbandabut has the advantage of the lisp tradition that arguabaly gave birth to repl style coding. So I was hoping to see some more. Maybe I should contribute syntax highlighting
20:35justin_smithmiddleware are our version of plugins
20:35BAMbandayeah i should check it out
20:35justin_smitha middleware to syntax hightlight makes sense
20:36justin_smiththere was once talk of middleware for arbitrary mime types
20:36justin_smithso that a repl inside a browser for example could display non-textual data in a natural format
20:36arrdemwe need a native clojure syntax highlighter anyway...
20:36jeffterrellAgreed: syntax highlighting middleware sounds pretty spiffy.
20:37justin_smithBAMbanda: have you looked at gorilla?
20:37BAMbandano, let me check it out right now
20:38BAMbandathe mime repl idea sounds sickk
20:38justin_smithhttp://gorilla-repl.org/
20:38justin_smithgorilla gets close to some of that
20:38BAMbandasweeeet
20:40caternsigh
20:40caternall these things would be nice
20:40caternif they had nice keyboard shortcuts and buffers and everything
20:40caternbasically, if they were inside emacs
20:40caternrather than a browser
20:40caternliterate org-mode clojure programming?
20:41justin_smithcatern: that does work, without the things like built in plotting of course
20:41justin_smithcatern: though if your code outputs an svg, emacs could display that
20:41BAMbandagorilla kind of reminds me of wolfram language style coding
20:41cbarrettlooks a lot like IPython as well
20:41BAMbandaplots, graphs, 3d geometrial objects...etc
20:41caterni wish they worked better, i wish emacs webkit integration was finished already
20:41justin_smithBAMbanda: yeah, I think that those the influences
20:42arrdemcatern: oh that's actually happening? I thought it was a joke
20:42BAMbandavery powerful stuff, its exciting to be a developer these days
20:42BAMbandaimagine back in the day, low level memory management, no glitter
20:42justin_smitharrdem: catern: cutting edge emacs features wallow in poes law like pigs in mud
20:42BAMbandawoah, i just read emacs webkit integration
20:42BAMbandasounds serious
20:42arrdemBAMbanda: someone doesn't write os and below software....
20:43gfredericksif I type "emacs vim integration" will it suddenly be a real thing too?
20:43cbarrettgfredericks: there's actually a pretty good vim mode for emacs.
20:43arrdemgfredericks: lol evil-mode get wrekt
20:43caternarrdem: well someone's doing it...
20:43gfredericksnah I'm imagining you have vim running in the background for some reason
20:43caterngfredericks: that's why i want this to be inside emacs, so i can use vim keybindings...
20:44BAMbandai definitely admire and respect the kernel guys, without them we'd be nothing
20:44caterngfredericks: what, you want it to be inside vim? or someone to reimplement vim yet again, very poorly?
20:44gfredericksM-x eclipse-mode
20:44cbarrettcatern: lol
20:44justin_smithgfredericks: awesome
20:44BAMbandabut we are able to be more fluid in our usage of language as expression
20:44BAMbandagfrederikcs: M-x komodo-mode
20:44arrdemgfredericks: when you really want to make sure that you don't have any ram left...
20:45BAMbandaarrdem, bare-metal scalable hypervisors in the cloud
20:45BAMbandaI heard it from a clojurepodast from cognitec, things are happening
20:46BAMbandahttp://blog.cognitect.com/cognicast/?tag=podcast
20:46caternarrdem: well it isn't an official feature or anything, it just would be nice and add to emacs' already insane level of power
20:48arrdemGrimoire 0.3.7 dropping in a minute...
20:48arrdemlooooots of cleanups
22:06jamesnvcHi! I’m seeing some very confusing issues when compiling clojurescript at runtime, where (= :method (keyword “method”)) is false
22:07TEttinger,(= :method (keyword "method"))
22:07clojurebottrue
22:07jamesnvcThings work under :simple optimizations, but then die under :advanced, seemingly because variables that are supposed to be bound by destructuring a map with {:keys […]} are nil
22:07TEttingerhm
22:08jamesnvcI’m not sure if that’s what’s causing the problem, but it is very confusing
22:08TEttingerI would be confused too... I don't use cljs so I can't be of much help
22:08jamesnvcI’ve been seeing issues about strange things happening with keywords hashing, I guess this is part of it
22:09jamesnvcdammable difficult to get a minimally-reproducable test case though
22:18justin_smithjamesnvc: on the online cljs fiddle I can't reproduce that http://cljsfiddle.net/
22:18jamesnvcyeah, I can’t reproduce it out side of my app either
22:19hiredmanjamesnvc: clojurescript has it;s own keyword equality predicate that is not =
22:19hiredmanI forget what it is called
22:19jamesnvcoh?
22:19Bronsakeyword-identical?
22:20Bronsahiredman: I belive = works fine though
22:20jamesnvcI remember seeing that identical? doesn’t work on keywords, but I thought = did
22:20jamesnvcyeah
22:20hiredmanoh
22:20hiredmanmaybe I am misrembering
22:20Bronsajamesnvc: which version of cljs are you using?
22:21hiredmanbut a runtime created keyword not comparing as equal to a compile time constant keyword seems like exaclty that issue
22:21jamesnvcthat aside though, the actual problem seems to be that destructiing a map isn’t working
22:21jamesnvcBronsa: 0.0-2322 now, was seeing the same on 2277
22:22Bronsajamesnvc: ah, dunno then
22:22jamesnvchiredman: yeah, I figure it must be something like that — I’m only seeing the issue when I’m doing some kinda crazy run-time invocations of the clojurescript compiler
22:26jamesnvcfor some reason, literal keywords are also being output as undefined in javascript
22:26jamesnvcI guess that’s why they aren’t equal :/
22:27justin_smiththat's fucked up
22:27hiredmanjamesnvc: are you incrementally compiling clojurescript?
22:28jamesnvchiredman: no, it wipes everything between compiles
22:29hiredmanjamesnvc: the clojurescript compiler generates what is basically a global constant table of keywords, if you are incrementally compiling and running bits of clojurescript, you might be overwriting that global table of keywords with a different table with different keywords
22:29jamesnvchiredman: hmm, that sounds promising
22:29jamesnvcyeah, constants_table.js is empty
22:30jamesnvcthat doesn’t seem right
22:37jamesnvcAny idea as to why constants_table.js would be completely empty?
22:47danielcomptontadni_`: same, it looks pretty cool
22:50tadni_danielcompton: I wonder if it will spark interest into this, http://sicpinclojure.com/, project.
22:51tadni_This has actually been one of the motivating factors leaning me to Clojure over other Lisps.
22:51danielcomptontadni_: I saw it as sicpinclojure that would get finished
22:52tadni_danielcompton: Well, SICP Distilled mentioned it will translate the examples, but I don't think he was planning on putting them into a text outside of his helper text/site.
22:52danielcomptonright.
22:53tadni_danielcompton: I mean, if most of the leg work is already done -- it'd be trivial to use/copy it in sicpinclojure.com .... assuming that's legal.
23:08ddellacostaso, I've been a loser and not updated lein in a long time, then I finally did, and now it seems like tab completion isn't working for me. what did I do wrong, or did I miss some information at some point?
23:09justin_smithddellacosta: in a lein repl in a terminal?
23:09ddellacostayeah
23:09ddellacostajustin_smith: and I just noticed the message "Unable to initialize completions."
23:09justin_smithwell, there you go :) - dunno what makes that happen though - is this related to a plugin in your profiles.clj?
23:10ddellacostajustin_smith: huh, that's a good guess, let me try disabling everything there to see
23:11ddellacostajustin_smith: nope, still the same. hrm.
23:12ddellacostahmm, looks like maybe this has to do with reply and clojure-complete, which makes sense
23:13justin_smiththat's a separate plugin, right?
23:14ddellacostajustin_smith: is it a plugin?
23:15justin_smithoh, I guess not
23:15ddellacostajustin_smith: I've noticed that when I start lein it is complaining about not finding that--but the thing it, it was always complaining about not finding that to the extent that I had started ignoring it, and only now does it actually seem to matter
23:16justin_smithodd
23:16ddellacostayeah, I have to poke around a bit more
23:16ddellacostamaybe I can just install that
23:16ddellacostaalright, well, thanks justin_smith!
23:21ddellacostayeah, simply including clojure-complete in my project.clj did it, but kind of annoyed that I had to do that...seems like it should get picked up if it is a basic lein (via repl-y) dependency?
23:23justin_smiththe idea may be to make the completion middleware modular, so people can use the one they prefer? maybe this is related to editor tooling
23:24arrdemAFAIK cider completion is already REPL independent middleware
23:25technomancy ddellacosta: are you using lein master?
23:25ddellacostatechnomancy: um, this is just the latest update, one sec
23:26ddellacostatechnomancy: 2.4.3, just from doing an upgrade yesterday
23:27technomancyddellacosta: oh, no idea then; sorry
23:27danielcomptontadni_: it's from a short story Leiningen vs The Ants
23:27danielcompton$google Leiningen vs the ants
23:27lazybot[Leiningen versus the Ants--Carl Stephenson (1893-1954)] http://www.classicshorts.com/stories/lvta.html
23:27ddellacostatadni_: read the top of the README here: https://github.com/technomancy/leiningen
23:27tadni_danielcompton: Oh wow, no fooling?
23:27danielcomptontadni: and Ant is a Java build tool
23:27tadni_Ah.
23:27ddellacostatechnomancy: no worries. Who knows what kind of arcane old settings I've got hanging around here. :-(
23:28abaranoskywhat do I need to do to get my patch into Clojure? I've got it on JIRA, and started a thread on the clojure-dev mailing list. Do I now just wait for the clojure.core team to give it a yay or a nay? Or do I need to actively try to drum-up some support for the patch?
23:28technomancyddellacosta: for the record, `lein downgrade $OLD_VERSION` is a thing too
23:28technomancyabaranosky: I recommend generous bribery
23:28abaranoskyha
23:28abaranoskymaybe I should fork Clojure ;)
23:28technomancyyou could also hire a professional thief to pilfer the SSH private keys and passphrase of a core member
23:28ddellacostatechnomancy: gotcha, will consider that
23:29justin_smithtechnomancy: lein upgrade $OLD_VERSION works too, and sends the stern message that you are switching because the old version is better
23:29technomancyjustin_smith: lifehack: `lein "upgrade" $NEW_VERSION` also works, but sadly the shell strips the sarcasm before Leiningen can detect it
23:30justin_smithlol
23:30ddellacostacan't you also do lein upgrade "$NEW_VERSION" ?
23:30technomancyyeah
23:30ddellacostafor minor bug fix releases
23:30technomancyfor whatever
23:30ddellacostasorry, maybe I'm projecting
23:31ddellacostalein upgrade $DDELLACOSTA_HUMOR_CONST
23:38danielcompton$DDELLACOSTA_HUMOR_CONST is already up-to-date.
23:38ddellacostadanielcompton: I think that's a burn somehow
23:39ddellacostadanielcompton: but the $DDELLACOSTA_HUMOR_CONST settings aren't sufficient for me grasp it
23:39ddellacostasetting rather
23:43danielcomptonHow does one give clojure apps a more useful name in jps than 'core'?
23:47arrdemtechnomancy: how do dependency scopes interact with profiles? reading the maven documentation they seem redundant.
23:48L8DWhere should I start if I want to replace my existing node.js express REST API with Clojure?
23:49L8DAnd replace my client-side React app with ClojureScript's om?
23:51hipitihopI have a large vector of maps, about 30k and I need to detect duplicates based on extracting multiple keywords from each map e.g. using (juxt :w :r :s :t) I have tried with group-by and frequencies, eliminating the juxt, all are too slow, e.g. I'm getting 55-60 seconds so I need to rethink the approach altogether. anyone have ideas for alternate algo ?
23:53arrdemhipitihop: do you need to count duplicates? a chunked map/reduce merging on values with + could work...
23:54justin_smithhipitihop: what about using select-keys?
23:54justin_smithhipitihop: never mind, that won't actually be faster than comparing juxt results
23:55danielcomptonhipitihop: do you need to detect duplicates or just remove them?
23:55hipitihoparrdem, ideally counted but not important, as long as I know which combination of keys has > 1
23:55hipitihopdanielcompton, just detecting which ones are
23:55arrdemhipitihop: can you show a small I/O case? http://refheap.com
23:56arrdemanyone know if there's a standard URI encoding for Maven dependencies?
23:56danielcomptonhipitihop: what's the distribution like? Are they mostly unique or mostly mixed?
23:56hipitihopdanielcompton, mostly unique, so duplicates are an edge case
23:57justin_smithhipitihop: another question, where are the maps being generated? there is likely a more efficient possibility at the site of map creation (or the site of loading the maps from their source)
23:58justin_smithand now that I think of it, lazily comparing the keys one at a time (bailing at first non-match) could be faster than running juxt then checking equality
23:58danielcomptonhipitihop: I did this a while ago and used java.util.TreeMap
23:58danielcomptonhttps://gist.github.com/danielcompton/4b1a59054a40a89c19ec
23:59danielcomptonI saw a 5x speedup but my sample size was much smaller than yours
23:59danielcomptonhipitihop: or it's at least similar
23:59hipitihopjustin_smith, maps are generated from a prior xml parsing step which creates a vector of maps each map represents an element in original xml i.e. keywords in resulting map correspond to attributes in each element
23:59danielcomptonarrdem: from my coworker talios: "not in any official standard I don't think - the general one most people use is mvn:grouopId/artifactId/version/extension/classifer"
23:59danielcomptonarrdem: :i.e. mvn:org.apache.felix.karaf/apache-felix-karaf/1.4.0/xml/features: