#clojure logs

2013-09-18

00:53glosoligot very silly question here, I have read about deftype and defrecord and it was marked that it compiles down to Java classes, so it got me wondering, what to does clojure code compiles by default?
00:54callenfucking netsplits.
00:54rplacaclojure compiles to Ja classes all over the place, but not so explicitly as with defrecord and deftype
00:55rplacas/Ja/Java
00:55glosolirplaca: so that's what got me wondering, what's does explicit stand for in such context ?
00:55TEttingerglosoli, yeah, if AOT isn't on, you can take a look at the compiled bytecode and what names it gave it in... classes/ , was it?
00:55rplacawell, you get a class with a defined set of fields and methods and a name that is "your" name
00:56TEttingerstuff like core$_main$iter__18__22$fn__23$fn__24.class
00:56rplacaotherwise, things like functions compile to classes, but Clojure picks the names and interfaces that they implement
00:57rplacaand the "standard" datatype are predefined classes
00:57rplacathat you just use without having to think about it much
00:58glosoliinteresting thanks!
00:58rplacaglosoli: np. enjoy!
02:12callenrplaca: if at all
02:21indigoHm, apparently Windows thinks clj files are "Windows Shell Common Dll"s :P
02:23R_MacySilly question, is the dash in front of a function symbol a convention (to show it's private) or language feature? how about a * following a function symbol.
02:23R_Macy(I don't mean *my-thing*, but rather my-thing*)
02:28R_MacyIn other words, (defn- foo []) is analogues to (defn -foo [])?
02:29heathcross-posting we are
02:29heathban him! ;)
02:29R_Macyha
02:33R_Macygot an answer to foo* thanks heath (http://www.cliki.net/naming%20conventions)
02:33R_Macystill trying to figure out -foo
02:34heathhttps://groups.google.com/forum/#!topic/clojure/rzvMp44ZN0I
02:34R_Macyah so - signifies an entry point
03:19hhenkel_Is there a good way (other then multiple if clauses) to check for multiple values in a datastructure and fail if one is missing?
03:20ambrosebshhenkel_: what kind of datastructure?
03:21ambrosebshhenkel_: usually (every? pred coll) works well
03:22hhenkel_ambrosebs: a simple map...i'll check "every".
03:23ambrosebshhenkel_: clojure.set has lots of tools that are probably useful too.
03:23hhenkel_ambrosebs: how would I notify a user what explicit value is missing there?
03:23ambrosebshhenkel_: (set/difference (set expected) (set actual))
03:24ambrosebs\
03:25hhenkel_ambrosebs: Ah, that looks exactly like what I've been looking for. Thanks!
03:26aaelony_trying to understand the monoid function and why (clojure.core.reducers/fold (clojure.core.reducers/monoid max #(Double/NEGATIVE_INFINITY)) (clojure.core.reducers/map inc (range 10))) works but (clojure.core.reducers/fold (clojure.core.reducers/monoid (juxt min max) #(Double/NEGATIVE_INFINITY)) (clojure.core.reducers/map inc (range 10))) does not....
03:26ambrosebshhenkel_: keep in mind the set ops don't do input validation, it's up to you to ensure you only pass sets.
03:29hhenkel_ambrosebs: Yes, thanks, that's a good hint.
03:49ambrosebsWhat is a MetaExpr in the Compiler.java?
03:54borkdudeyay, my Emacs.app is finally working from brew, using the same live pack as from my other machine :) thanks for the help yesterday evening
03:54chordwhat projects are you guys working on?
03:57chordanyone there?
03:59ucbhey chord
04:00chordwe should work on starcraft clone written in clojure
04:00chordyou gonna help?
04:01ucbnah, no time
04:01ucbthanks for the offer though
04:02chordno time what?
04:02chordwtf you wasting your time on
04:02ucbheh
04:02ucbnice try
04:03chordtell me what you're using your time on?
04:04chordso you're doing nothing
04:04chordtons of free time?
04:05borkdudespending time on nothing can be very nice, meditation
04:05borkdudeit's actually very difficult to do it
04:29chordsomeone talk
04:29chordchannel is totaly dead
04:32muhooin nrepl.el, is there some way to be able to hit RET on a line in an nrepl error stack trace and go to that line in the file?
04:32muhoocause i'm sure tired of doing it manually :-/
05:14muhoozzzzzz http://www.youtube.com/watch?v=ypKP1BvRZaM
05:25hhenkelWhy do I get an "IllegalArgumentException Duplicated Key" if I alter the example from http://clojuredocs.org/clojure_core/clojure.core/merge to have to keys "b" ?
05:26hhenkelThe text states that this case would be handlet, doesn't it?
05:27fredyrthe example already has two :b keys doesn't it?
05:27fredyrdid you add two inside of the map literal perhaps?
05:28clgv,(merge {:a 1 :b 2 :c 3} {:b 9 :d 4 :b 20})
05:28clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: :b>
05:28clgvthat?
05:28clojurebotthat is dumb
05:28clgvlol
05:28ucbheh
05:28fredyrhah
05:28fredyrclgv: yeah, that's what i meant
05:28clgv,{:b 9 :d 4 :b 20}
05:28clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: :b>
05:28clgv&{:b 9 :d 4 :b 20}
05:29clgvoh that one is lazy again
05:29clgvfredyr: hhenkel: there was a discussion about modifications concerning that behavior on the ML - but I do not recall what they decided finally
05:30hhenkelfredyr: You're right my fault....I have to be more attentive...
05:30fredyr:)
05:30fredyreasy thing to miss
05:32clgvhhenkel: fredyr: https://github.com/clojure/clojure/blob/master/changes.md#210-set-and-map-constructor-functions-allow-duplicates
05:32fredyrclgv: at least python does allow it -- prolly more of the dynamic languages
05:33clgvfredyr: the above notes describe the distinction between literal and constructor functions
05:36fredyr,(hash-map :b 1 :a 9 :b 9)
05:36clojurebot{:a 9, :b 9}
05:37fredyrseems like a pretty good choice
05:38djcoinAnyone know how to have the doc of some functiosn in lighttable ? (is it possible to have a nice dialog box somewhere to show the doc when hitting some keys ?)
06:33hashcatI wrote ((fn [x y] '(+ x y)) 10 20) and expect it return '(+ 10 20), but it give me '(+ x y)
06:34hashcatHow can I replace symbols in list?
06:34llasram&((fn [x y] `(+ ~x ~y)) 10 20)
06:34llasramOh, no lazybot
06:34llasram,((fn [x y] `(+ ~x ~y)) 10 20)
06:34clojurebot(clojure.core/+ 10 20)
06:35hashcatThanks
06:35llasramhashcat: OOC, what's the higher-level thing you're trying to achieve?
06:36hashcatllasram, play with genetic programming
06:37llasramInteresting
06:37hashcatI'm planning to implement it on distributed system
06:39hashcatI'm reading avout and swarmiji for that
06:50wei_compojure's (response/file-response "index.html" {:root "resources/public"}) doesn't seem to work inside an uberjar. is there a workaround?
07:04wei_to answer my question above: (response/file-response (.getPath (clojure.java.io/resource "public/index.html"))) works inside an uberjar
07:04muhoohmm this seems a stupid name for this function. and doesn't it already exist somehwere under a better name? (defn munge-map-vals [f m] (zipmap (keys m) (->> m vals (map f))))
07:05ambrosebsmuhoo: probably should be called update-vals
07:06ambrosebsmuhoo: it's probably around in some utility libs.
07:06clgvmuhoo: yeah update-vals would be better and using reduce-kv to build the new map faster
07:10wei_^ oh wait, actually it doesn't work inside an uberjar :(
07:12llasrammuhoo: I've seen a similar function named `map-vals` in a few places, including prismatic's plumbing
07:14muhoothanks
07:16muhooah https://github.com/bendlas/plumbing/blob/master/src/plumbing/core.clj#L32
07:17mrchancehi! how do I read all forms from a file? Do I really have to create a PushbackReader, read from it in a loop and wait for exceptions?
07:17muhooi wonder how many clojure utility libraries there are out there. one for every clojure programmer, maybe?
07:17muhoo(hell, i have one)
07:17llasrammrchance: You can provide a value to return on EOF vs exception, but otherwise -- yes
07:18mrchancewow, that is pretty bad. Better than nothing though. Thanks!
07:19mrchance@muhoo: I have one too, and every other clj programmer I know does as well
07:19llasrammrchance: Well, but your loop can be just (->> (repeatedly ...) (take-while ...))
07:19mrchance:)
07:19muhooooh neat (fn-> foo bar) instead of #(-> % foo bar)
07:19clgvmrchance: you could only have one clojure form in that file though - vector or map, containing everything
07:19mrchance@llasram: yeah, it's not that bad
07:19TEttingercouldn't you just eval?
07:19mrchance@clgv: I want to analyse cljs files to autoextract externs
07:20mrchanceSo no single form per file
07:20llasrammrchance: BTW, on IRC one generally doesn't prefix people's handles with `@` -- the convention is to just refer to their name by itself
07:20clgvah ok^^
07:20clgvmight have been a config file scenario ;)
07:20mrchancegood to know ^^ pretty new to it
07:21muhooa lot of people are used to the twitter machine instead
07:22mrchanceHehe, I actually don't use that, don't know what part of my brain produces the @s
07:22mrchanceMaybe subconcious twitter influence
07:22clgvhmm the for-map of plumbing seems pretty non idiomatic using the atom
07:23mrchanceah, speaking of non-idiomatic: I want to use clojure.walk to extract the symbols
07:24clgvmrchance: maybe the macro expansion walking from zach tellmann or the one of tools.reader is a better fit
07:24mrchancehm, yeah
07:24mrchancethe clojure.walk only seems to have rewrite capabilities
07:24mrchancelittle strange to rewrite the datastructure itself to extract something
07:24clgvbut it will delete emtadata
07:25mrchancethats no problem for me
07:25clgvok.
07:25clgvoh, you just want to walk the code unexpanded?
07:26mrchancehm, maybe expanded would be nicer, but I see that could be problematic with cljs
07:27mrchanceGuess interfacing to verbose js libs would be a common usecase for macros
07:28mrchancewell, I just need a list of all extern functions and members, so I guess I could just process the macro definitions as well
07:30mrchanceit's really ugly that we have to do the externs by hand
07:30mrchanceDoes anyone know of a project to address this?
07:32hashcatllasram: I found a better solution
07:33hashcat(cons 'fn (cons '[x y] '((+ x y)) ))
07:34mrchancehi ejlo ^^
07:35clgvhashcat: you can just build lists normally. no need to use lowlevel cons. equivalent to your above expression: (list 'fn '[x y] '(+ x y))
07:35hashcatthen I can manipulate the list and eval it during run-time
07:35hashcatclgv: Thanks
07:36hashcat`(+ ~x ~y) is not going well during run-time
07:37clgvhashcat: for fixed templates it should be suitable
07:37hashcatclgv: I agree
07:38clgv,(let [x 'a, y 'b] `(+ ~x ~y))
07:38clojurebot(clojure.core/+ a b)
07:41tgoossensIs there a clean way (in existing library) to do this (completely conceptual): (map [:name :country] persons)
07:41tgoossensinstead of (map #(vector (:name %) (:country %)) persons)
07:42tgoossens(i'm just searching a more concise notation for doing the described concept)
07:43AimHereIf there's no pressing reason to call your function 'map', you could knock up a tiny little macro or function to do it
07:43andrewmcveigh|wotgoossens: (map (juxt :name :country) persons)
07:43tgoossensinteresting
07:43AimHereOr what he said
07:43tgoossensfantastic
07:44tgoossensi need to google that (juxtaposition)
07:44andrewmcveigh|woyep, can be very usefull ;)
07:44tgoossensamazing
07:44tgoossensthanks a lot
07:45andrewmcveigh|wonp
07:50seangrov`I'm thinking about a cljs helper function for error reporting, maybe extending errbit to support this:
07:51hashcatis there any alternative to default clojure intepreter?
07:51hashcatdirection keys behave silly
07:52seangrov`Catch the error, send it to your error-reporting service, along with some metadata about what version of your code you're using - then the error-reporting service looks up the source map for the given version (that you've uploaded as part of your deploy process), and all errors are reported in original line numbers/symbols
07:52seangrov`It's got to be the obvious next evolution of airbrake/rollbar/errbit and friends, but I don't think any support this properly right now
07:53seangrov`Proxino was going to do it, but I don't know what their status is
07:57seangrov`I guess rollbar does support it, actually
07:57seangrov`Should check it out
08:51ciphergothWhen using lein repl :connect to a URL, you can authenticate by putting the username and password in the URL. Is there any other way to provide the username and password?
08:59emil0rdoes anyone know how to make the lobos library correctly migrate migrations defined in another project that is in one of your dependencies? i've already tried to redefine lobos.migration/*migration-namespace* and it's not working when it's from a dependancy. works fine as long as it's inside the project itself
09:38borkdudeyep, juxt
09:46clgvhashcat: what do you mean? the repl? there is leiningen which offers a pretty decent repl via `lein repl`
10:07mikerodwhere could I find the performance properties of doing something like (conj (sorted-set :e :d :c) :a) ?
10:08mikerodI haven't came across much information on how "insertions" work on these sorted data structures
10:09ambrosebsmikerod: I don't know, but conj is supposed to be the fastest way to do it.
10:11mikerodambrosebs: Hmm I see. I could analyze the source for a while I suppose. I guess I'd assume it is a "fairly" efficient mechanism, as opposed to just resorting a whole new collection.
10:11mikerodThat much is obvious after a quick glance.
10:11ambrosebsmikerod: all of Clojure's data structures use structural sharing to some degree.
10:11hyPiRionsorted-sets are just persistent rb-trees afaik, they have O(log n) time complexity for insertion
10:12mikerodambrosebs: yeah that is a good point.
10:12mikerodhyPiRion: thanks, it does look like the are rb-trees
10:18ciphergothI'm trying to use "lein repl :connect https://...&quot; to connect to a Heroku instance. It prints "Connecting to nREPL at https://...&quot; and then hangs. When I ^Z and kill it, it prints "Welcome back!" before it dies. How can I diagnose what's going on?
10:20aatifhHi, has anyone ever tried django xadmin(https://github.com/sshwsfc/django-xadmin) and managed to run it successfully? I really liked the themes and plugins but facing some issues. Thanks in advance.
10:21aatifhHumble apology. Wrong channel!
10:33ambrosebsBronsa: should jvm.tools.analyzer reset the current namespace to clojure.core or user (or similar) before analyzing a file?
10:33ambrosebsBronsa: how does CinC handle it?
10:34dnolenambrosebs: fwiw in CLJS we reset to cljs.user
10:35ambrosebsdnolen: ok. That's good enough for me.
10:35Bronsaambrosebs: Compiler.java only relies on the current value of *ns* and so does CinC
10:35ambrosebsBronsa: hmm ok :)
10:35clj_newb_2345if I have 1 quad-core Xenon, the JVM can use all 4 cores. If I have 2 Quad-Core Xenon on Ubnutu Linux, does the JVM use all 8 cores, or is each "linux process" limited to just 1 CPU?
10:36ambrosebsBronsa: I find the ns form is usually in some random namespace after I analyze a file.
10:36dnolenambrosebs: CLJS is a bit odd if we ever intend to support (load-file ...)
10:36ambrosebsdnolen: yes, I just considered that.
10:37Bronsaambrosebs: what do you mean?
10:38Bronsaambrosebs: fwiw clojure special-cases the resolution of `ns` to clojure.core/ns
10:38ambrosebsBronsa: I mean the :env of the first form that's analyzed claims it's from the current namespace.
10:38ambrosebsBronsa: which is a bit odd.
10:40Bronsawell, if *ns* is user and you encounter (ns foo), the form (ns foo) is effectively in the user namespace
10:42ambrosebsBronsa: yes. Is that how load works in Clojure?
10:42Bronsaambrosebs: yeah, it just evals all the form of the file in the current ns
10:43ambrosebsit doesn't sound like something I need to worry about then.
10:43clgvclj_newb_2345: you can use all cores
10:43clj_newb_2345even across different CPUS?
10:43clj_newb_2345linux + java just handles this for me behind the scenes?
10:43jtoyhow does one redeploy with ring and not have the site hang while its deploying? on rails for example you can let teh old process contineu to run until the new one is fully up
10:43clgvyour operating system linux does it
10:43jtoywith ring I kill the old process, then start the new process, that is at least 30 seconds on my box
10:48clgvjtoy: the technical problem is the exclusive use of the port right?
10:50clgvjtoy: you could have a "facade process" on the actual port that forwards to your application. when you make the target application configurable you can let the old one running, start the new one, switch and kill the old one
11:01TimMcIt's called a reverse proxy.
11:03clgvTimMc: ah thx ^^
11:04jtoyclgv: is there any library that does this already?
11:05clgvjtoy: no idea.
11:05arrdemjtoy: what are you proxying? http?
11:06TimMcYou can even see some repeat prefixes: Kingmaxj1w6 Kingmaxm3o8 Helloxaod97 Hellodgjm30
11:06TimMcBah, wrong channel.
11:06jtoyarrdem: yes htttp, I do have nginx in front currently
11:06arrdemjtoy: nginx can do some selective proxying, but I've also used clj-proxy
11:08jtoyarrdem: ist caleld selective proxying?
11:08arrdemjtoy: I don't remember, but it's in the sample configs site
11:08jtoyok, thanks
11:11jtoyarrdem: I dont see anything called clj proxy, is it a different library?
11:13arrdemjtoy: sorry I always get the name wrong. it's ring-proxy.
11:13arrdem$google ring-proxy
11:14arrdemjtoy: this https://github.com/tailrecursion/ring-proxy
11:15arrdemjtoy: I'm sure that nginx is impericaly faster, but that's really easy to get running.
11:20jtoyarrdem: yeah, i will probably use nginx, i just wanted to see how it would work through pure clojure
11:20silasdavishow do you test if a value is callable?
11:21arrdemsilasdavis: &(fn? #(:foo %1))
11:21mdrogalis,(doc ifn?)
11:21clojurebot"([x]); Returns true if x implements IFn. Note that many data structures (e.g. sets and maps) implement IFn"
11:21silasdavisthanks
11:21mdrogalisI *think* IFn <-> Callable ?
11:21arrdem,(doc fn?)
11:21clojurebot"([x]); Returns true if x implements Fn, i.e. is an object created via fn."
11:22silasdavismdrogalis, so all methods are nil-returning IFns?
11:23silasdavisuhm 'pure methods' I mean
11:26mdrogalissilasdavis: Eh?
11:26mdrogalisConfused :)
11:26arrdem,(cannuc? 'mdrogalis)
11:26clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: cannuc? in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:27silasdavisI'm wondering about whether a void java method would implement IFn in clojure
11:27mdrogalisarrdem: No sir. :)
11:27silasdavisor whether only explicit implementers of IFn would
11:27mdrogalissilasdavis: No, I'm afraid not.
11:27mdrogalisYeah, the latter.
11:28silasdavisin which cast callable != IFn
11:28mdrogalisMust be the latter then.
11:29silasdavis(I was only actually after ifn? in this case anyway)
11:29mdrogalisAh, try this.
11:30mdrogalis,(instance? java.util.concurrent.Callable inc)
11:30clojurebottrue
11:30mdrogalisThat should do it.
11:38manutterAre there any libs that let you set up arbitrary events, register handlers, and then trigger the events? I'm thinking server-side, not anything javascripty
11:45eggheadmanutter: you wight want to check out rxjava for clj, or core.async
11:46manutterThanks, I've looked at core.async but not rxjava, I'll check it out.
11:47manutterI'm working on something similar, I'm just checking for other libs that might overlap with what I'm doing.
11:48eggheadah, then you might want to also look at lamina
12:04BlankVersehow do I reload a clojure android app in repl(using lein droid)
12:07manutteregghead: cool, thanks much. Gonna look at lamina some more in any case. :)
12:07clgvif I have a long running process in a thread that prints to stdout which is sent from nrepl server to my nrepl client. after the client disconnects, does the nrepl server still attempt to send the output to the client?
12:09clgvok the answer is, it dies with socket closed exception...
12:23BlankVerse(use 'foo.bar :reload-all) should reload and display changes made to foo.bar..
12:24BlankVerse(use 'org.stuff.clojuroid.main :reload-all)
12:24BlankVersenil
12:24BlankVerseshould it return nil?
12:25BlankVerse(load-file "src/org/stuff/clojuroid/mail.clj")
12:25BlankVerseErrnoException open failed: ENOENT (No such file or directory) libcore.io.Posix.open (Posix.java:-2)
12:33clgvBlankVerse: yes, it should return nil
12:45BlankVerseclgv: it means the module is reloaded?
12:45clgvBlankVerse: there will be exceptions if something went wrong
12:45BlankVerseclgv: on the repl?
12:46BlankVerseor logcat
12:46clgvBlankVerse: tools.namespace is a library that tries to do proper reloading
12:46clgvI dont know what logcat is
12:47clgv,(let [f (fn [] (throw (Exception.)))] (f))
12:47clojurebot#<Exception java.lang.Exception>
12:47BlankVerseits android logger , my clojure repl is running on android and I am trying to reload my clojure app from repl
12:47clgvlooks similar to this ^^ in the repl ;)
12:47BlankVerseclgv: ok, this comes when i do (load-file "src/org/stuff/clojuroid/mail.clj")
12:48clgvBlankVerse: oh, I never used clojure on android. in normal clojure you'd usually see the exception reported in the repl
12:49moquistlein says "Could not reserve enough space for object heap / Could not create the Java virtual machine." googling gave me "-d64 -XX:MaxHeapSize=256m" opts for java, and that works if I already have a .jar. But now 'lein uberjar' gives me the same message, and adding ':jvm-opts ["-d64" "-XX:MaxHeapSize=256m"]' to my project.clj didn't help... I'm not sure what to try next.
12:49coventry2BlankVerse: I notice that you have "(use 'org.stuff.clojuroid.main)" in your first form, but are loading mail.clj in the second one. (Might be behind; I was reading from the IRC log.)
12:51coventry2moquist: Try running "DEBUG=true lein uberjar" to make sure the options are getting passed through.
12:51moquist
12:51moquistoops, wrong window focused...
12:52moquistcoventry2: that just told me "Leiningen's classpath: :/home/moquist/.lein/self-installs/leiningen-2.1.2-standalone.jar", in addition to the same message
12:53BlankVersecoventry2: ah thanks a lot!
12:53moquistcoventry2: I'm assuming lein doesn't get as far as reading project.clj, since the JVM never starts.
12:54coventry2Yeah, I guess so.
12:54BlankVersenow , it give java.lang.ClassNotFoundException: complete.core
12:54moquistcoventry2: FWIW: http://pastebin.com/qS0VE3f6
12:55coventry2moquist: Try passing the opts in the env var LEIN_JVM_OPTS.
12:55moquistcoventry2: YAY! That's what I was looking for.
12:55moquistI was looking around for java env vars, but didn't look for lein env vars.
12:56moquistcoventry2: many thanks.
12:56coventry2lein is just a bash script. Easy to read.
13:09`cbpIf I have a defprotocol on namespace A, a defrecord + extend-type on namespace B, and I wanna use those methods on namespace C what do I have to import/require?
13:09`cbpThis is confusing me so much :P
13:14maleghastAnyone know how to set up a Clojure / Compojure web app to treat all strings as UTF-8..?
13:14mdrogalis`cbp: I believe you need to require the protocol from A, and important the defrecord from B.
13:14mtpmaleghast: what are the defaults?
13:15maleghastI am unsure, but the app in question is receiving UTF-8 text and mis-rendering it
13:17`cbpI am requiring the protocol + method from A, requiring B, importing the defrecord from B and it's not working :P
13:17justin_smith`cbp: I think it is import a, require b
13:18justin_smithsince a definies the java thing (the protocol), and all you need from b are functions that create the records (so require suffices)
13:19`cbpextend-type puts the record methods on the namespace that created has the defprotocol though
13:23maleghastmtp: I have to log off in a couple of minutes… Thanks anyway, I'll do some Googling ;-)
13:23slpsys_part
13:23amalloymaleghast: utf-8 is the default character encoding when java converts bytes to chars/strings
13:24amalloyyour app is probably receiving text encoded in some other way, not utf-8
13:24amalloyor serving it right and your browser is mis-rendering it
13:24maleghastamalloy: ok, the payload I'm getting is serialised with MessagePack - I will look there...
13:26justin_smith`cbp: http://sprunge.us/iHZH?clojure minimal example I just cranked out of how to do it
13:26justin_smithyou use ns.protocol in the defstruct ns/protocol-method to invoke it
13:30mheldis there an analogous command for lein/compojure to 'rake routes' in the ruby/rails world?
13:31weavejestermheld: Remind us what that does :)
13:32mheldweavejester: tells us what routes are defined
13:32weavejestermheld: In that case, no, at least not in Compojure's case. The routing mechanism for Compojure is very flexible, but essentially opaque.
13:33indigomheld: Ah, using Clojure for web as well? ;)
13:34weavejesterI think there is room for a routing library that's data-based. One that could be queried, but one that's less flexible than Compojure.
13:34weavejesterPedestal has something like that, but I don't think it's a separate library.
13:35mheldindigo: yeah!
13:35mheldweavejester: over time, I do wish to contribute to the web-ness of clojure but for now I just need to finish this project ;-)
13:39`cbpjustin_smith: thanks I have something wrong but I dont know what :P
13:41justin_smith`cbp: was the example I pasted unclear?
13:41justin_smithI guess I didn't have the requires and imports
13:42`cbpjustin_smith: I tried it on a repl adding the requires and imports as I have them and it works so that's why I don't know what's wrong :P
13:42indigomheld: Yeah I'm just getting started in it... it's such a relief after what I do at work
13:42justin_smitha.Foo would be imported, a/bar and b/->baz would be required
13:43dobry-denrasmusto: Dude this is great. ~/dotfiles with a `make link`.
13:43rasmustodobry-den: <3
13:44`cbpjustin_smith: import doesnt work on defprotocol
13:44rasmustodobry-den: glad it worked for you :)
13:49mheldwhy is it so hard to figure out how to accept JSON with my clojure app!?
13:50mheldgod damn it
13:50Apage43accept json?
13:50konr`what framework are you using?
13:50augustlmheld: cheshire.core/parse-string? :)
13:50Apage43^^
13:51justin_smithmheld: there is also a ring middleware for incoming json
13:51augustlor parse-stream
13:51mheldjustin_smith: I've been trying to use it but alas, none of the json gets parsed
13:51augustlmheld: what exactly is the problem?
13:51mheldI'll poke around with cheshire
13:51augustlnote that most servlet containers expose the :body as a read once stream
13:51augustlmheld: ^^
13:52dobry-denwhy use chesire instead of just clojure.data.json/read-str
13:52justin_smith`cbp: user> (import (a Foo)) => a.Foo
13:52justin_smith
13:52Apage43if you're using the middleware, it'll only take effect if you send stuff as Content-Type: application/json (or similar)
13:52justin_smithdobry-den: clojure.data.json is terrible
13:52dobry-denjustin_smith: in what way?
13:52seangroveSeems like a complicated way to tokenize + parse https://github.com/AdamBrodzinski/RedScript/blob/master/lib/compile.js
13:52ro_stjustin_smith: are you sure? stuartsierra has worked on it recently
13:52justin_smithdobry-den: the api is unstable
13:52konr`clojure.data.json can't serialize dates, uuids etc
13:53ro_stkonr`: isn't that true of JSON generally?
13:53mheldcurl -X POST localhost:3000/pingbacks -d{hi:'marc'} -> (POST "/pingbacks" {body :body} (create-pingback body)) doesn't return anything (create-pingback is just an identity function right now)
13:53Apage43curl -X POST -H "Content-Type: application/json"
13:53technomancyro_st: there's no standard way to do it, but that shouldn't mean it's impossible
13:54mheldApage43: that did it
13:54ro_stwhat i mean is, JSON doesn't support like edn does
13:54mheldApage43: gracias
13:54justin_smithro_st: I have seen cheshire be much more sensible with data coercions than data.json
13:54konr`ro_st: yes, but cheshire can transform an UUID into its string without much hassle
13:54ro_styou have to roll your own
13:54Apage43and whatever other doodads you hit that API with should have ways to set the request body content type as well
13:55justin_smithro_st: roll your own, or just use cheshire who rolled it for you
13:55`cbpjustin_smith: it tells me "interface a.Foo is not a protocol" when I try to import
13:55technomancyof course the idea of keeping a UUID around as a separate type distinct from strings in your codebase itself is fairly suspect anyway unless you're concerned about memory usage
13:55ro_stwasn't aware chesire added that
13:56augustlstringly typed programs ftw :)
13:56ro_stheh
13:56Apage43the nice thing about cheshire is you can extend it
13:56ro_stwe're lucky enough to use EDN everywhere
13:56Apage43so if you have some wacky type buried in a big nested map, you can just teach cheshire about the type rather than try to fix it on the way in
13:57jtoycan anyone tell me why when I run this code, it never prints out and results is always an empty list: https://www.refheap.com/18767
13:57ro_stthat's handy
13:57jtoyI know it has to do with laziness, but im not sure how to fix it
13:57`cbpcurse clojure error messages :(
13:57ro_stjtoy: wrap (for) in (doall)
13:57ro_stnothing consumes the result of the for and so the laziness is never realised
13:58ro_stor do thing (for ..)] (println thing) ...
13:58konr`ro_st: what do you use on the front-end?
13:59ro_stcljs :-)
13:59jtoyro_st later on in my code I do run (/ (reduce + (map :precision results) ) k) which should realize it?
13:59dobry-denin a real app youd consume `results`. so id just wrap (doall results) temporarily to see it
13:59konr`any specific library/framework?
13:59amalloyro_st: if results is empty, wrapping it in doall won't make a difference
13:59ro_stkonr`: a shoreleave-pubsub + enfocus lashup
14:00dobry-denyeah that's a good point, wouldnt it be LazySeq if that was so
14:00ro_stnext iteration will be a pedestal app
14:00ro_stamalloy: true
14:00konr`cool! I've been trying to push cljs here as well :)
14:00ro_stkonr`: the awesome bit is really reusing code server/client
14:01ro_stthe same code that produces the data on the client also consumes it on the server
14:02justin_smith`cbp: can you paste a simple repl session that creates the error you are getting?
14:02konr`using shoreleave, right?
14:02konr`any specific reason you are trying pedestal-app?
14:04augustlangular and ember has shown that separating generating data to represent UI state and updating DOM elements is awesomesauce. Pedestal works similarly, except clojure, and with great architecture, and functional :)
14:05ro_stkonr`: pedestal-app is a slam dunk for our app
14:06ro_stit does properly the things that i ended up doing (very) naively in our current app
14:06ro_stevent sourcing user data, using queues to ship data back and forth, etc
14:07ro_sti just did it badly because i used loads of atoms and pubsub and essentially made some clojure spaghetti :-)
14:08ro_ststill, it's only 2k loc of spaghetti instead of the 11k of google closure spaghetti i had written before finding clojure
14:09noncomif i do (spit "some-file.file" (str "hello\nhow\nare\nyou?)), the resulting file contains the string like it is here, with the \n characters in it. how do I make them into real newlines?
14:09`cbpjustin_smith: ... lol
14:10AimHerenoncom > You sure? It works the way you intend it to, for me
14:11konr`noncom: strange, (spit "/tmp/foo" (str "hello\nhow\nare\nyou?")) did create a file with newlines here, too
14:11`cbpjustin_smith: Apparently I had an error somewhere else and the protocol cache (didn't know about that) never updated so it never found the methods I defined. I did lein clean after fixing that other error and everything starts working -_-
14:11noncomhmmm, maybe it's because you're on linux and i am on windows?
14:11AimHereHow are you reading the file?
14:11noncomwindows uses \n\r
14:12noncomi am not reading, i want to write a string to a new file
14:12AimHereI think it's \r\n, but it's been a while
14:12AimHereYeah, but it might be that the way you're reading the file is turning the 'newlines back into '\n's
14:12AimHereThe windows thing is more likely though
14:13`cbpjustin_smith: thanks for your help :P
14:13noncomoh i just open it with an editor..
14:13justin_smith`cbp: I think maybe some stuff technomancy has been doing with trying to reduce startup time has been making lein clean more neccissary. That's just speculation on my part though. Maybe I am doing more protocol and macro changes than usual lately.
14:14callen`cbp: stop using protocols unnecessarily :P
14:14justin_smith`cbp: no prob
14:59mdeboardAnyone else in this datomic deal at strangeloop
14:59mdeboardplease stand up and announce yourself
15:01konr`what datomic deal?
15:01mdeboarddatomic intro session
15:02callenso. jealous.
15:02callennot only is Rich talking about core.async, but there's a datomic session? :(
15:11callenThat sad, sad moment when you realize you're going to have to write a manual loop/recur instead of using clojure.walk/walk for your problem. http://i.imgur.com/wQPAsdN.gif
15:24bracki_How do I look up docs on thing like # or @?
15:25mdrogalisbracki_: Those symbols are sugar for dispatch-macro and deref.
15:26mdrogalisbracki_: Also, the dispatch macro, being a reader macro, is a little special. It doesn't have a ClojureDoc bit associated with it.
15:26BrackiSo what is the dispatch-macro useful for?
15:27coventryBracki: You can get the nomenclature for them out of tools.reader: https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader.clj#L543
15:27mdrogalisBracki: Utilizing the Lisp Reader.
15:27Brackimdrogalis: what?
15:27mdrogalisControl+f for Dispatch (#) http://clojure.org/reader
15:29BrackiSo take #'f for example. All it does is expand to (var f). Why is that useful?
15:31mdrogalisBracki: That's really just sugar. It becomes useful when you want to extend Clojure itself.
15:31mdrogalisThe quote after the hash is meaningful.
15:31mdrogalisI can put another character after the hash and make it mean whatever I want.
15:31mdrogalis#(inc %) <- The ( after the # is significant, in the same manner.
15:31coventrymdrogalis: I thought clojure doesn't really have reader macros.
15:32mdrogaliscoventry: It has one, but it doesn't support user defined reader macros.
15:32mdrogalisJust one extensible one.
15:33coventryCan you give an example of giving whatever character follows # an arbitrary meaning?
15:33TimMcdata-readers
15:33TimMcBut it doesn't have the kind of control you're thinking of.
15:33mdrogalis,#uuid "803e1294-c4bd-4c89-bbbf-501f992caffb"
15:33clojurebot#uuid "803e1294-c4bd-4c89-bbbf-501f992caffb"
15:34mdrogalis#xxxxuuid "803e1294-c4bd-4c89-bbbf-501f992caffb"
15:34mdrogalisUUID is defined too.
15:34mdrogalisThe xxx one failed because thats not defined.
15:34coventryOh, OK, I thought you meant something more general than that.
15:34TimMcNo, it failed because you forgot the comma. :-P
15:34mdrogalisTimMc: lolol *Facepalm* Nice.
15:34TimMc,#xxxxuuid "803e1294-c4bd-4c89-bbbf-501f992caffb"
15:34clojurebot#<RuntimeException java.lang.RuntimeException: No reader function for tag xxxxuuid>
15:34mdrogalisThanks
15:34mdrogalisWarning: Fatigue has indeed set in.
15:35seangrov`,#{1 1 1 1 1 1 3 3 3 3 2}
15:35clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Duplicate key: 1>
15:37Bracki,#'
15:37clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:37Bracki,#'partial
15:37clojurebot#'clojure.core/partial
15:38mdrogalis#' is sugar, no meaning on its own.
15:38mdrogalis`var`, on the other hand, does.
15:39seangrov`,(var partial)
15:39clojurebot#'clojure.core/partial
15:39Bracki,(doc var)
15:39clojurebotI don't understand.
15:39seangrov`It's just common(-ish) to want to grab vars, hence there's a built-in reader macros to make the syntax more terse
15:40bjais there a way to determine what namespace I'm running in for my clojurescript code?
15:40seangrov`bja: Namespaces aren't available at runtime in cljs, sadly
15:40BrackiWhen do I need vars?
15:40seangrov`I'm not totally clear why not, if it's just an implementation detail or it's fundamentally not possible
15:41bjais there a way I could find out where I'm running (or what required me) from google closure library?
15:41Brackihttp://clojure.org/special_forms#Special Forms--(var symbol) is not very helpful.
15:42seangrov`bja: What are you trying to do?
15:42bjafigure out the namespace my function is in for logging purposes
15:42seangrov`Ah, well, there's *ns* in clojure, but not clojurescript, I believe
15:44coventryI wonder if you could just persuade the cljs ns macro to drop a *ns* var in the specified namespace.
15:45seangrov`coventry: Interesting idea!
15:48seangrov`I don't know what *ns* offers in clj-jvm though, I suppose it may have some special properties that js objects don't have
15:51timsganyone use org-babel much? the documentation's a bit weird, I'm trying to figure out how to eval source blocks that contain noweb refs
15:52dnolentimsg: probably more responses to that question in #emacs
15:54timsgdnolen: yeah, I'll look there
16:00AimHereHmm. Being a good little functional programmer, I want to send a function as a parameter to a method in a class declared using gen-class, but apparently I have to declare the arguments beforehand; Since (class <function name>) returns just the name of the function, that's not really useful. Is there a way of doing this that I've missed, or will I have to use some clunky workaround?
16:01coventryseangrov`: People might expect (binding [*ns* ns] foo) to execute foo in ns, which might be bad.
16:01`cbpIs there a way to clear the protocol method cache? :(
16:04`cbpfreaking protocols just lead to madness and despair
16:05TimMcAimHere: The function will be called from Clojure?
16:05AimHereYeah
16:05TimMcYou could describe it as a Fn, or even just an Object.
16:06Apage43,(supers (fn []))
16:06clojurebot#<ClassCastException java.lang.ClassCastException: sandbox$eval29$fn__30 cannot be cast to java.lang.Class>
16:06muhoo`cbp: it seems less janky on cljs
16:06Apage43,(supers (class (fn [])))
16:06clojurebot#{clojure.lang.Fn clojure.lang.AFn java.util.Comparator java.util.concurrent.Callable clojure.lang.AFunction ...}
16:07muhoonot sure why. maybe because then you're not fighting the jvm, i guess
16:07AimHerePhew, I was worried I might have to dig up some boneheaded java pattern to wrap the function in!
16:11`cbpApparently I was requiring/importing in the wrong order or heck i don't know :P
16:11`cbpI should write this down somewhere
16:38squidzwould there be an easy way to export a csv file with clojurescript?
16:38squidzI dont' really want to add an additional library if I can keep it simple
16:41nDuffsquidz: there's more to CSV than just comma separation -- there are quoting and escaping rules and such.
16:42nDuffsquidz: ...if you want something that really does it right, a third-party library is probably the right approach. If you just want to split lines by commas, well, that's trivial. :)
16:43squidznDuff, it doesnt have to be fancy i will only have number values along with a header
16:43dnolensquidz: http://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side ?
16:43squidzand the first column will be text(kind of like a vertical header), but other than that everything will be numeric
16:44squidzthanks dnolen that is exactly what I was looking for.
16:46rasmustois there a consensus on whether to keep example code in source clj files? I'd like to have good documentation in docstrings, but runnable snippets make sense too
16:47rasmustoShould I put (comment) blocks after the code I want examples for or use separate namespace (or something else)?
16:49coventryrasmusto: It's nice if you can make tests out of the examples.
16:51hyPiRionrasmusto: http://stevelosh.com/blog/2013/09/teach-dont-tell/
16:53lpetithello
16:53lpetitI have weird behaviors while using zippers
16:54lpetitI don't know exactly how, but I've managed to get a loc whose node is nil, that's weird
16:56dnolenrasmusto: I think people generally try to avoid the clutter. I like it in the early stages of development.
16:57rasmustocoventry: Okay, I like the idea of unit tests that double as documentation
16:58rasmustohyPiRion: will give it a read, I saw it a while back but didn't finish :)
16:58amalloylpetit: what's weird about a nil node? depending on what kind of zipper you've defined, that's perfectly reasonable, right?
16:58coventryFWIW, it says that relying on tests for documentation is a terrible idea. :-)
16:59rasmustodnolen: I have a bunch of namespaces that I gitignore that have fragments of my runnable code in them, I tried to keep them out of controlled files, but now I want to be able to share
17:00rasmustodnolen: I also had the "benefit" of being the only one writing code in its early stages, so those snippets didn't need to be shared until now
17:00dnolenrasmusto: I don't see the point most people won't look at your source
17:01lpetitamalloy: well, yes, with my zipper, my guess is that it's not: https://gist.github.com/laurentpetit/6615228
17:01rasmustodnolen: true, I think I'll go the teachable unit test route, which should benefit me personally in the long run
17:02lpetitamalloy: I think I should only get nodes which are Strings, or maps, a-la zip.xml map
17:02lpetitContemplating creating a t-shirt named "Zippers: you're doing it completely wrong", at least addressed to me ;-)
17:03tbaldridgelpetit: it doesn't help that zippers need to be re-written (using protocols). I said I'd do it once, never did.
17:03lpetittbaldridge: never too late ;-)
17:20crocketIs there a good way to handle modularity in clojure?
17:21tbaldridgecrocket: namespaces?
17:22crockettbaldridge, namespaces don't solve modularity problem.
17:22crocketnamespaces solve name collision problem only.
17:22tbaldridgeplease explain the problem you are trying to solve
17:22tbaldridge"handle modularity" is too broad
17:22hyPiRionexplaining what you mean by modularity would help
17:24bjafwiw, I figured out how to find my current namespace in clojurescript: https://gist.github.com/emidln/bd33d9c0b40d20f60508
17:25crocketI have OSGi in mind when it comes to modularity.
17:29tbaldridgecrocket: perhaps look into using queues with multiple servers/JVMs. Allows you to start/restart/update nodes on the fly without taking down other parts of the system
17:30crockettbaldridge, queues?
17:30crocketDo you mean network queues?
17:32tbaldridgecrocket: yes, kafka, ZeroMQ, RabbitMQ, etc.
17:32crockettbaldridge, ZeroMQ is my bet.
17:32tbaldridgeif you don't need reliable/durable message passing
17:32crocketHowever, using OSGi would be easier to work with than ZeroMQ in general.
17:33tbaldridgecrocket: but it also is a slightly outdated model in which it is cheaper to put everything on one server. If that JVM/server dies, you loose everything and what good is modularity then?
17:33crockettbaldridge, modularity still holds.
17:34crocketfault tolerance isn't the only benefit.
17:34crocketBeing able to swap a module on the fly is good.
17:34crocketBeing able to mix and match is good, too.
17:34tbaldridgecrocket: not as good as being able to swap an entire server on the fly.
17:35crockettbaldridge, I think OSGi and Message queue can be used together for maximal modularity.
17:35crocketWhat about akka?
17:36tbaldridgeactor systems are like the system I described, but it attaches the queues to the processes. So if the process dies, you loose the queue.
17:37crockettbaldridge, Why is OSGi a slightly outdated model?
17:38tbaldridgeThe old model assumed that you would run monolithic servers in-house. These days with AWS and other cloud services, it's not uncommon to run many small VMs. With smaller VMs you can start/stop the entire machine at will.
17:38tbaldridgeno need for all the overhead/complexity of a module system.
17:39tbaldridgeEven then, some companies these days will kill the entire VM (even delete the disk) on a software upgrade.
17:39crockettbaldridge, You're talking in terms of administrator.
17:39crocketThat's valid case.
17:40crocketHowever, in developers' point of view, code modularity can be harder with ZeroMQ.
17:40tbaldridgeor even on a hour by hour basis, see Elastic Bean Stalk, the load balancer has the power to kill/start nodes as the load on the cluster changes
17:40tbaldridge*Beanstalk
17:40tbaldridgecrocket: why do you need code modularity?
17:41crockettbaldridge, coders need code modularity.
17:41tbaldridgewhy?
17:41clojurebothttp://clojure.org/rationale
17:41tbaldridgethanks clojurebot
17:41crocketnon-modular code is difficult.
17:42tbaldridgeRight, that's where namespaces come in, imo. Or even in-process queues like core.async. Functional programming also helps as each function is isolated from the state of the system.
17:42tbaldridgeIt's also very common in Clojure to split out your system into many smaller libraries, that helps as well. No need for a complicated module management system.
17:42crockettbaldridge, namespaces don't solve modularity problem.
17:43crockettbaldridge, namespaces solve a part of it, name collisions.
17:43crocketname collision is a symptom of non-modularity.
17:43tbaldridgecrocket: they also allow you to logically split out your code into smaller parts
17:44TimMcUUIDs solve all name collisions.
17:44crockettbaldridge, I'll have to experiment with ZeroMQ and OSGi and see which works.
17:45crockettbaldridge, a complicated module management system helps you deal with managing library dependencies. But I'm not aware of tradeoffs yet.
17:45jstew/
17:45crocketTo get a hand in tradeoffs, I have to use it.
17:46tbaldridgecrocket: take a look at lein, library dependencies is what it was designed to handle.
17:46crockettbaldridge, Do you use message queues a lot for modularity?
17:47tbaldridgecrocket: yes, both for inter-process/VM communication, as well as inner-process. See http://github.com/clojure/core.async for the latter
17:48crockettbaldridge, What do you use for IPC?
17:48tbaldridgecore.async
17:48tbaldridgeah sorry, wrong thing
17:49tbaldridgeZeroMQ if I don't need reliable message passing, RabbitMQ if I do.
17:49tbaldridgeor even just plain old REST if I don't need a queue
17:49crocketmeh
17:49crockettbaldridge, What do you mean by REST?
17:50tbaldridgeas in I structure my code as a collection of services that serve up HTTP, with EDN as the transport.
17:52tbaldridgecrocket: also think about what it would be like to build Systems the way NetFlix does it: any node should be able to fail at any time.
17:52tbaldridgeSo they actually have a script called Chaos Monkey that randomly kills servers, if problems occur, you have issues with your design: http://techblog.netflix.com/2012/07/chaos-monkey-released-into-wild.html
17:53crockettbaldridge, How do they manage processes?
17:53tbaldridgethey don't, they manage servers. They run on AWS, and have many, many VMs. The script kills the entire VM.
17:54crocketoh jesus
17:54crocketI don't have a luxury of many VMs.
17:55crocketI'm a poor man left with a single server.
17:55tbaldridgeSo back to your original question, everyone builds their Clojure systems differently, that's my preferred approach.
17:56crockettbaldridge, Do they use OSGi with clojure?
17:57tbaldridgeno. also see https://groups.google.com/forum/#!topic/clojure/Ro9WO0USGTM
17:57rasmustolazybot: wb
17:58crockettbaldridge, REPL?
17:58tbaldridgehttp://tryclj.com/
17:58tbaldridgethat's a repl
17:59crocketHow is REPL related to OSGi?
17:59lazybotrasmusto: Thanks.
18:00tbaldridgecrocket: Clojure is a dynamic language, so they're stating in that mailing list thread that OGSi is somewhat hindered by the fact that Clojure programmers can re-define functions at a whim
18:00tbaldridgeIt's even possible to to fire up a REPL on a remote box and dig around in the service while it's running
18:02bjaexceptions to my system get flagged in sentry with information that makes it possible for me to repl in and recreate the scenario on the fly
18:02bjaI'm pretty sure I can't go back to doing it another way
18:07crockettbaldridge, If you need to build a big program from modules, OSGi is still an answer.
18:14tbaldridgecrocket: I'm just saying, I've seen Clojure used in some really massive systems. I have yet to hear of anyone using OSGi in production
18:19jtoyis this the recommended way to serialize clojure objects? http://stackoverflow.com/questions/1288877/what-would-be-the-correct-way-to-serialize-this-java-object-in-clojure i see it is 4 years old
18:23Apage43jtoy: I wouldn't. Use pr-str and clojure.edn/read-string
18:24jtoyApage43: cool, I will try that, the object is maps of maps, i think that should be fine ,the other issue is it is about a gig in size
18:24Apage43http://clojure.github.io/clojure/branch-master/clojure.edn-api.html http://clojure.github.io/clojure/branch-master/clojure.core-api.html#clojure.core/pr-str
18:48TimMcbrehaut: I have been infected with a taste for dubstep. D-:
18:49brehautTimMc: that sounds unhealthy!
18:49javehello
18:50TimMcIt's all technomancy's fault. He pointed me to a chiptune-ish album that had some dubstep hiding in it.
18:50winkwhich one? :P
18:51brehautlol
18:51winkmore for the chiptune part actually
18:51brehautTimMc: you sure it wasnt just a malfunctioning hard disk?
18:51RaynesTimMc: http://www.youtube.com/watch?v=xjx1PVdsVvk Take one of these twice a day.
18:51callenbrehaut: if 20-somethings are stomping the floor, it's dubstep. If a greybeard is stomping the floor, a server's hard drive is failing.
18:52callenThe More You Know ☆彡
18:52winklol
18:53javeif I'm going to expose a number of clojure methods to java with :gen-class, what is the convention? Do I wrap functions with new functions with - in front of the name?
18:59mlb-why is my test-atom not "Hello {:msg \"hello world\", :type \"log\"}" ? https://gist.github.com/mlb-/6616629
19:01danielszmulewi-1howdy
19:02amalloymlb-: `for` is lazy. it is never correct to see (for ... (doseq ...))
19:03noonianhi danielszmulewi-1
19:03mlb-amalloy: so I'd want nested `doseq`s?
19:04TimMcbrehaut: No, I haven't moved on to the really hard stuff yet.
19:04TimMcI mean, I did experiment with catting /dev/hda to /dev/snd back in college, but never again.
19:05brehautTimMc: you need to run it throguh an envelop filter and a beat synced parametric EQ and it'll be bang on
19:05noonianmlb-: yes that should fix it. because you don't do anything with the return value of publish (which is a lazy seq) after you call it, its evaluation is never forced
19:07mlb-noonian: your explanation helps, thanks =]
19:08dbaschwhat's a better way to do this? (map #(map read-string %) [["1", "2"] ["3", "4"]])
19:08dbaschtrying to convert a list of pairs of numeric strings to pairs of numbers
19:10callendbasch: golf or "better"?
19:10dbasch"better" as in less ugly
19:12callendbasch: write a mmap function that doesn't map memory but maps a twice-nested list :)
19:13`cbpand hide it in the closet
19:13rasmustodbasch: ,(map (partial map read-string) [["1" "2"] ["3" "4"]])
19:13rasmustoheh
19:13dbaschrasmusto: that's marginally better I suppose
19:14dbaschbtw, the output of that goes into this ugly function, which could really use improvement: https://www.refheap.com/18775
19:14callenrecursion without loop/recur?
19:14callenbrave.
19:15AimHere,(walk #(mapv read-string %) identity [["1" "2"] ["3" "4"]])
19:15clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: walk in this context, compiling:(NO_SOURCE_PATH:0:0)>
19:15AimHere,(clojure.walk/walk #(mapv read-string %) identity [["1" "2"] ["3" "4"]])
19:15clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.walk>
19:15callenAimHere: good idea!
19:15rasmustoI've got a new way to walk.walk/walk
19:16callendbasch: walk is a more general solution, but I don't know how much pretty you'll get?
19:16callenprettier*
19:28dbaschI want to believe this is a bit better, thoughts? https://www.refheap.com/18779
19:42`cbpdbasch: maybe this: https://www.refheap.com/18780 :P
19:42jmonettahey guys! is it possible to shadow a special form with a macro in clojure?
19:42`cbpjk
19:42dbasch`cbp: thanks
20:02rasmustojmonetta: I think that's what most of the special forms become, so yes
20:02jmonettarasmusto: thx for your answer
20:03jmonettaI was trying to do some code walk with replacements
20:03jmonettawith our clojure macrolet definitions
20:03rasmustojmonetta: ex: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4083
20:04jmonettaand I think it's specially avoiding macrolets to shadow special forms
20:06jmonettalike (macrolet [(if [test then-form else-form] `(if ~test (do (print "then") ~then-form) (do (print "else") ~else-form))))] (if 1 5 6))
20:06jmonettathat doesn't work
20:06jmonettathe macrolet doesn't expand the if special form
20:07jmonettalooking at the source it's supposed to protect the users
20:07jmonettabut I think this doesn't allows you to do some code walking/replacing using macrolets as in common lisp
20:11rasmustojmonetta: interesting, that's beyond what I know
20:12coventryfn is not a special form, strictly speaking. That redefinition is over an earlier clojure definition https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L42
20:12jmonettahmm I was pretty sure that was allowed in CL, but now it's giving me an error :(
20:12coventryThe special form is fn*
20:14jmonettahttp://letoverlambda.com/index.cl/guest/chap5.html
20:14jmonetta"Code-Walking with Macrolet"
20:15jmonettathat's what I'm trying to accomplish
20:16cespareIf you wanted to do a loop over squares how would you do that?
20:16cespareI can construct a lazy seq of squares, but it's more typing than just squaring the number inside a (while true ...) loop.
20:16Apage43where is this macrolet from? is it the clojure.tools.macro macrolet?
20:17Apage43(the one you're using, not the CL one)
20:18coventryClojure doesn't macroexpand forms which start with one of its special forms: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L6475
20:18cespareah, iterate is what I want, I think.
20:19jmonettaI'm using clojure tools macrolet
20:19jmonetta[org.clojure/tools.macro "0.1.2"]
20:19jmonettathat one
20:20Apage43ah, but the problem as coventry points out is in clojure.core/macroexpand-1
20:23Apage43but, the way I read clojure.tools.macro it should not be using that to expand the macrolets
20:23Apage43only to expand regular macros
20:23Apage43(that is, you *should* be hitting this branch https://github.com/clojure/tools.macro/blob/master/src/main/clojure/clojure/tools/macro.clj#L75-L76 )
20:25jmonettalet me check
20:25jmonettathx
20:26cespareWhy does (newline) cause flushing but printf with a newline at the end does not?
20:27mtpbecause (newline) causes flushing
20:27mtppretty much
20:27cesparejava's dumb, got it
20:28mtpuhhh, no
20:28mtpthe definition of the function "newline" includes "flush the output buffer"
20:28cmathesondoes (println) also flush? i always have to (println (format)) but i would rather printf
20:28mtpafaik
20:28cesparemtp: where is this definition?
20:28cesparemtp: I'm reading the docs and it just says that it prints a newline, and notes that it's equivalent to System.out.println()
20:29mtphuh, i could be wrong
20:29cesparecmatheson: that's exactly the annoyance i'm having
20:29cesparei was excited to discover printf, then sad to discover that i need to revert to (println (format )) after all
20:29mtpnot sure how you can derive "java is dumb" from "these two functions do different things", though
20:31cesparewell, it's directly exposing the java behavior afaict, which apparently doesn't flush even if the input ends with a newline.
20:40noprompt;_;
20:43AimHereThat's what loop/recur is for - there would be no need for it if you could only remember what the rotten sequence function you really need is called...
20:44callennoprompt: not even mapcat's actual implementation in core uses loop recur :P
20:44callenyou guys know there's a way to query the bot for functions that produce the desired output given example input, right?
20:45AimHereHow clever is it?
20:45nopromptcallen: fuck that i'll just query "lessons learned from writing horrible clj code"
20:45callenit's like a runtime Hoogle for Clojure.
20:45callenAimHere: it works fine but it's sometimes more inclusive than you want if you don't give a specific enough example.
20:45nopromptcallen: haha, it should be called "Cooger"
20:46AimHereWell does it do that Byrd/Friedman thing of spitting out the first 50 functions that evaluate to 6?
20:46noprompti'll say it again, recognizing you've written some bad code is the first step on the road to recovery.
20:46AimHereOr does it just look for named clojure functions!
20:46cesparehow would I reload a library inside lein repl? (If i just lein installed a new version)
20:47nopromptcespare: are you using emacs with nrepl?
20:47cesparenoprompt: nope
20:47noprompterrm... load-file?
20:47nopromptload?
20:48callencespare: (require '[clojure.tools.namespace.repl :refer [refresh]]) (refresh)
20:49callennoprompt: done.
20:49nopromptcespare: he/she may not be using clojure.tools.namespace
20:49callenuse clojure.tools.namespace.
20:49nopromptcallen: like this (use 'clojure.tools.namespace)?
20:49nopromptlol
20:49callenif you need to go spear fishing you'd better have a fucking stick.
20:49nopromptcallen: dude, i'll choke a fish out with my bear hands.
20:50callenbare hands?
20:50nopromptthat's right *bear* hands
20:50callenbear hands seems to work too.
20:50cesparecallen: ok, i can use clojure.tools.namespace, but I wasn't before
20:50callenchange your lein profiles for :user :dependencies to include c.t.n
20:50cesparecallen: is that something I should put in my user project thingy
20:50callencespare: profiles.
20:50callencespare: ~/.lein/profiles.clj
20:50cesparecallen: yes that.
20:50callennoprompt: I can loop you into the loop.
20:50callencespare: yes. do that.
20:51callennoprompt: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded
20:51callenI hate that he's decided to claim this as his own, but whatever. Do it anyway.
20:51nopromptcallen: yeah, i've read that.
20:51callenwell...do it.
20:51callenc.t.n.r is amazing.
20:52noprompti don't like putting my name on stuff or taking ownership. i don't even like licenses or copyrights.
20:52callenit's great for re-running tests with too
20:52nopromptit feels icky.
20:52rasmustocallen: would it be better to have it as a per-project thing? (in terms of sharing code or w/e)
20:52nopromptstill i've done these things.
20:52callennoprompt: I think Sierra got tired of being the Stuart the Lesser. Needed to put his name on something.
20:52callenrasmusto: no.
20:52callenrasmusto: it's a local dev tool.
20:52callenyou shouldn't be writing code that uses c.t.n.r
20:52rasmustocallen: kk
20:53callenit's just repl dev.
20:53callenit's an Emacs macro for me.
20:53callenI use terminal REPL for running tests (up arrow, hit enter)
20:53callenand Emacs REPL for experimentation/dev
20:53nopromptstuart sierra's talks trick me in to thinking i actually understand them.
20:53nopromptbut i like them anyway.
20:54cesparecallen: so how do i figure out the version of c.t.n.r that I should use? When I search clojars for that, nothing comes up. It's also not in the readme.
20:54callenhg commit -m "primary keys that aren't really primary."
20:54nopromptcallen: that's how i run tests too.
20:55rasmustocespare: it says 0.2.4 on github
20:55cesparerasmusto: that's for c.t.namespace
20:55callenclojars is...not how you should be finding packages :P
20:55cesparecallen: ok, please enlighten me
20:55callenthere's a lot of proxy packages on there from forks.
20:55cesparei'm new to this
20:55callenofficial github repo -> lein line
20:55nopromptcallen: it's a nice sanity check to make sure you don't have anything weird going on after long Emacs sessions.
20:55callen[c.t.n "0.2.4"] line from the README.md
20:55justin_smithI checkout out my clojure app in jvisualvm, and saw 600k+ instances of class character
20:56cesparecallen: i did that. That didn't give me c.t.n.r
20:56justin_smithis this normal? is it something weird about my app?
20:56cespareI assume that's a different package?
20:56callennoprompt: I bounce between the two REPLs.
20:56rasmustocespare: https://github.com/clojure/tools.namespace#releases-and-dependency-information
20:56callenjustin_smith: I've only done runtime profiling in YourKit, can't say.
20:56callendoesn't sound right though :)
20:56nopromptcallen: term repl/emacs nrepl?
20:56callenyeah.
20:56justin_smithyeah, that represents quite a bit of ram
20:56cespareok, i must just be requiring it incorrectly.
20:57nopromptcallen: usually that's what i have going on but i seldom use the term repl.
20:57rasmustocespare: oh, maybe I'm the one out of the loop, just read your last comment
20:57callennoprompt: I experiment in emacs nrepl, start firming up the implementation in the buffer for my actual code file, test from emacs nrepl until it seems to work. Then I write a test and start hammering the terminal REPL.
20:57cesparecallen: I get a filenotfoundexception when I do your require line, even though I clearly have the package (lein repl printed stuff abouting downloading c.t.n from central)
20:57callenit's like a meta-loop of development behavior.
20:57nopromptcallen: i don't like using nrepl-jack-in because sometimes i want to connect to another repl session
20:57callencespare: reload the repl
20:57rasmustocespare: er, nm, maybe that's the right thing
20:57callennoprompt: I don't do nji
20:57cesparecallen: I did
20:58nopromptcallen: it's alla 'bout strait M-x nrepl
20:58callen[org.clojure/tools.namespace "0.2.4"]
20:58cesparecallen: yes that's what I have.
20:58callenI had 0.2.3
20:58callentry 0.2.3
20:58cesparecallen: I'm in a project though, and the project doesn't have it.
20:58callendoesn't matter
20:58cesparecallen: maybe i need to switch namespaces or something?
20:58callenI only have it in profiles.
20:58callen...no
20:58cesparek, no idea then.
20:58callentry 0.2.3
20:59callencheck your ~/.m2
20:59callennoprompt: I do the testing -> terminal REPL flow because it's faster than checking multiple assertions manually
20:59cespare0.2.3 doesn't work, looking in ~/.m2
20:59callenit lets me set up a batch of assumptions.
20:59muhooi asked this earlier, not sure if there was an answer: how does one in nrepl.el hit RET on a line in an nrepl error stacktrace and go to that file and line?
21:00muhoobecause, it doesn't do that, and i'm thinking it probably should.
21:00callenmuhoo: mouse-click definitely does it to me sometimes.
21:00cesparecallen: how is this organized? find ~/.m2 -name namespace doesn't come up with anything
21:00callenlet me throw an error and find out.
21:00nopromptcallen: one thing i do like about testing in emacs vs the term is that failing tests get highlighted. that's always nice. especially with is.
21:01nopromptcallen: i've got a lot of tests that use are too but i almost wanna switch them back to let/is so i can get see precisely the failing test.
21:02callenmuhoo: goes to the top of the file if I give it a file for me. Not directly.
21:02muhoomouse click does squat for me, RET does squat too.
21:02callenoh it definitely prompts me.
21:02callenit just isn't very helpful.
21:03callennoprompt: my workflow is 50% experimental, 50% test driven.
21:03callenI don't really write tests first, they happen after I've formulated assumptions about what should and shouldn't happen based on the earlier experimental stage.
21:03callenI don't like baking my assumptions into tests until I understand the data and the code I'm interacting with.
21:04callenI don't write that many tests either.
21:05callenI've got 16 tests for 400 LOC on what I'm working on right now.
21:05callen16 assertions, 7 tests, sorry.
21:06cesparecallen: ok, i found 0.2.3 and 0.2.4 in my .m2
21:07cesparecallen: I've also verified that inside there, tools/namespace/repl.clj exists (in the jar), which is exactly the file that shows up with a FileNotFoundException when I require
21:07nopromptis there an fn that's equivalent to [(filter pred coll) (remove pred coll)]?
21:07rasmustocallen: how do I get it to use the :user profile when I launch a repl? cespare: yeah, I'm getting something similar
21:07callenmy code also tends to form a push-down stack of helper/component fns push down the root fn that forms a more proper part of the API
21:08hyPiRionnoprompt: split-with I think
21:08noprompti'm not looking for split-at or split-with
21:08callenrasmusto: I don't know what's going on with you guys.
21:08callennoprompt: wat
21:08noprompthyPiRion: split-with is take-while/drop-while
21:08rasmustonoprompt: #(juxt filter remove) ?
21:08nopromptrasmusto: bam! nice.
21:08noprompt:)
21:09nopromptcallen: yeah, no, that couldn't possibly be sane right
21:09callenoh I see.
21:09noprompt:P
21:09callenwow, a good excuse to use juxt.
21:09callenbravo rasmusto.
21:09nopromptjuxt is the shit legends are made of.
21:09callenthat was today's juxt quota.
21:09rasmustocallen: I slurped it over from yesterday's quota
21:10callenI used juxt, however inappropriately, yesterday.
21:10callenturned it into destruct :(
21:10callenI used a group-by and a projection function today.
21:12cesparecallen: rasmusto works if it's in the project.clj, btw
21:13nopromptrasmusto: that was the highlight of my day.
21:14callenwell wtf happened to Leiningen profiles?
21:15rasmustocallen: yeah, I was trying to do a `lein with-profile user repl` or somesuch
21:15noprompt(def divide (juxt filter remove))
21:16rasmustohahaha, I actually used (juxt filter remove) in my code today without thinking about it
21:16rasmustoirc is a powerful influence
21:19muhoooh, that was exciting, and stupid. i upgaded to nrepl 1.8 and now i get no stacktrace at all :-/
21:19rasmustohrm, I'll give c.t.n.r a shot tomorrow
21:19noprompti wanna make async regex patterns
21:20callenrasmusto: if I really wanted to, I could use "juxt filter remove" instead of my group-by :P
21:20callennoprompt: wtfffff are you doing?
21:20callenasync...regex...what?
21:20muhooah, there's a nrepl-popup-stacktraces variable
21:20nopromptcallen: yeah, lol
21:21muhooand... RET does something, it says "No error here". so that's an improvement.
21:21nopromptcallen: think about checking m1|m2|m3 blah blah concurrently
21:22cesparerasmusto: callen it happens with any library, not just c.t.n.r. Maybe I'm not using lein profiles correctly?
21:22nopromptcallen: i saw this it kinda inspired me to mess around https://github.com/coreperf/rejit
21:23nopromptcallen: normally i have no clue what i'm doing. i just go in to rabbit holes for the hell of it.
21:23callenhrm. using apply and flatten in the same line. I have something horribly wrong.
21:23callenhave done*
21:23callenmuhoo: yak-shaving advanced mode?
21:24callenI...am going to replace my flatten with mapcat identity and pretend it's somehow better. k? k.
21:24amalloyITYM "using flatten", callen. nothing wrong with apply
21:24amalloyuh, yes, that is generally ~100x better
21:25callenwhere's the 100x coming from? (serious question)
21:25amalloyalthough (apply concat xs) is more popular than (mapcat identity xs)
21:25amalloyoh, just that about 1% of the time flatten is a good choice, and 100% of the time concat is
21:25noprompt(apply concat xs) is nice.
21:26noprompt<3 concat
21:26noprompt<3 mapcat
21:26callenSimplified example: (apply hash-map (flatten [[:a 1]])) -> (apply hash-map (mapcat identity [[:a 1]]))
21:26callensecond one is what it got replaced with.
21:26amalloycallen: those both make me want to throw up
21:26amalloy(into {} [[:a 1]])
21:26callenamalloy: it's the result of group-by.
21:26callenoh SON OF A BITCH
21:26nopromptyeah i was just about to say into
21:26amalloywell, have fun. i'm off
21:27callenshould've known to use into from your goddamn 4clojure answers.
21:27muhoointo is the shiznit
21:27muhooalmost as cool as juxt
21:27noprompt"red elf needs food badly"
21:27callenmuhoo: almost.
21:27nopromptwell that's my queue to go eat.
21:28cesparecue?
21:28muhoono, he's using core.async to eat
21:28cespareor did you see a line of people walk by, who are all going to go eat, and you're about to join them
21:28nopromptcespare: i tend to Ms. pell stuff because it's funny to me.
21:29callencespare: maybe he lives in Soviet Russia and must queue for potatoes.
21:29callenhahahaha. who I kidding. no afford potatoes.
21:29nopromptmuhoo: that's a funny thought.
21:29muhoo(def food (java.util.concurrent.SynchronousQueue.))
21:29noprompt(put my-mouth (<! food))
21:29muhoonoprompt: yeah, much nicer
21:30callenBWAHAHAHAHA. Passing tests.
21:30muhooi really should get on the core.async bandwagon. the syntax sugar is so nice
21:30nopromptmuhoo: you could probably model the whole eating process if you took the time to wire it up.
21:30callenmuhoo: I use it for testing RabbitMQ in my unit tests cleanly.
21:30nopromptthat'd be funny.
21:30callenmuhoo: core.async propagates the state cleanly (without globals) from the callbacks to the unit test fns.
21:31muhoothough lamina does the job, core.async seems so much slicker.
21:31muhooit has that rhickey simplicity thing baked in
21:31callenLamina is very good at what it does, but I think core.async is better suited for "lightweight" uses like mine.
21:31nopromptmuhoo: i've only recently be using it on the client side.
21:31callenI think core.async is going to be my go-to (ha ah!) library for marshalling callback state and behavior.
21:32nopromptcyallater
21:32callenwithout, you know, smacking global state around.
21:32callennoprompt: latah.
21:33cesparehow can I see my classpath?
21:33cespareinside lein repl
21:35cespareok...so the things in my ~/.lein/profiles.clj just aren't in my classpath.
21:36callenbizarre.
21:36callencespare: which profile are you using?
21:36callenare you overriding the profile in your project.clj?
21:36cespareThe one in my profiles.clj is called :user, but I don't see anything about profiles in my project.clj
21:37cesparehow do I see the current profile?
21:37cespareok, trying out lein-pprint for teh debugz
21:38cespareoooooooooooooooh, nvm
21:38cesparei see what I done
21:38cespareeveryone carry on
21:39callencespare: ...what'd you do?
21:39cesparecallen: added the library to :plugins, not :dependencies ><
21:40callencespare: happens to the best of us :)
21:41cespareok, pop the stack, back to the previous problem now that I can reload my library
21:54cesparecallen: btw, that refresh thing doesn't actually reload the library that I reinstalled with lein repl
21:54cesparestill gotta restart lein repl
21:55coventrycespare: Check out pomegranate. I hear good things about alembic for this, too.
22:01callenalembic is more "whole" than pomegranate in the sense that it's less hassle to use and can synchronize with the project.clj
22:01callenalembic is what I use.
22:01callencespare: refresh is for reloading existing code, not fucking with your classpath :)
22:02cesparecallen: i don't need my classpath to change
22:02cesparei'm debugging a library. I make a change and lein install it. Then in my test project's repl, i want to reload
22:06coventrycespare: You need a lein checkout dependency. https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies
22:10cesparecoventry: ah perfect, thanks
22:20cespareWhat's this about? #<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/tools/macro__init.class or clojure/tools/macro.clj on classpath: >
22:21callencespare: you've now exceeded your free IRC support plan limit, please enter credit card number to continue at a rate of $15 per question.
22:21SegFaultAXSo I finally have a case where I need to introduce a concrete type (well multiple, for different implementations of a protocol). What's the current accepted standard? deftype, defrecord, gen-class?
22:21coventryYou can get your classpath by running "DEBUG=true lein repl" or with pomegranate.
22:22callenSegFaultAX: I'm dubious you needed a protocol to begin with. >:)
22:22SegFaultAXcallen: Why?
22:23callenalmost nobody ever does and would be better served with multimethods.
22:23SegFaultAXWell in this case it's more like an interface. multimethod isn't a good fit.
22:23callenthat's what multimethods are for too.
22:24SegFaultAXCool
22:24SegFaultAXAnyway, what's the current best practice. I seem to recall defrecord not being popular anymore or something...
22:25callenstructs are deprecated, not records.
22:25SegFaultAXAh ok, that's right.
22:25callenrecords aren't maps and don't share structure.
22:26SegFaultAXI thought the whole point of records is that they are persistent maps.
22:26`cbpdefrecord if you wanna have map compatibility, deftype otherwise i guess
22:26callendefrecord is preferred in the "general" case.
22:26callen`cbp: the map compatibility is superficial, they do not share structure the way maps do.
22:26callendeftype is more barebones than defrecord. If it looks and smells like a map, you want defrecord.
22:27SegFaultAXI don't know if "superficial" is the right word. It implements all the right interfaces, the fact that it doesn't use structural sharing is an implementation detail.
22:27SegFaultAXWhich is mostly irrelevant.
22:28callenwell, churn some records in a loop and see how irrelevant it is :)
22:28callenhttp://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
22:28callenyou should note that this is specifically for defining a type in Clojure, not for defining interfaces.
22:29callenif all you're doing is defining an interface, not a type associated with a protocol, then you don't necessarily need protocols.
22:29SegFaultAX1 protocol. 3 distinct implementations.
22:30SegFaultAXcallen: Are you thinking definterface?
22:30callenno :(
22:30callenI'm thinking Clojure code that doesn't give a damn about Java crap.
22:31SegFaultAXNo Java interop required.
22:31callenthen why are you using protocolsssssss
22:31callenI never thought having used CLOS in Common Lisp would be superseded by a situation where I'm telling people YAGNI. I thought CLOS was the ultimate flouting of YAGNI, but it has been overcome.
22:32callenSegFaultAX: protocols are explicitly about dispatching on type and only type. If types and the associated Java-ness aren't an important part of what you're doing...then don't make an interface that dispatches on type...
22:33callenthe only other reason to use protocols is "performance"
22:33Apage43beh, this is reminding me I have some code I should be using multimethods on
22:33callenand I swear to god I am going to start going after people that claim that as an excuse without a benchmark showing dispatch was a non-trivial part of the runtime.
22:34Apage43right now its covered in functions that are nothing but a big-assed (cond)
22:34callenApage43: lol. I applaud you for your restraint though.
22:35callenpremature multimethods/protocols is worse than having a cond.
22:35SegFaultAXAs I said, in this case it's more about documenting the interface.
22:35Apage43the only reason I really want to do it is to make it easier to read
22:36callenSegFaultAX: can't write docs unless it's prefaced with a defprotocol? Do you have a prescription for that?
22:37bjacallen: refactoring tends to flow from if->cond->multimethods
22:37bjawith a correlation to people requesting more features
22:37SegFaultAXcallen: More like "if you want to implement a new one of these thingies, this is the minimum interface you need to adhere to"
22:38SegFaultAXProtocols are a good in-code form of documentation for that.
22:38callenbja: me gusta
22:38callenSegFaultAX: orrrrr multimethods.
22:39callenI want you to swallow your insanity for the whole 30 minutes it would take to just do it in multimethods just so you see how it feels.
22:39SegFaultAXcallen: Yes, I understand your opinion on multimethods.
22:39bjamultimethods are like slingshot. best used in small doses, lest I remember that throw+ is just a super convenient multi-level-escape-capable flow-control method
22:40Apage43I've only ever used slingshot with clj-http, to catch some HTTP errors but not others
22:41bjaand the last time I did that I lost several hours refactoring the resulting "slingshot-enabled" code to be readable in the following days/weeks/months
22:41callenbja: multimethods are not dangerous the way slingshot is.
22:41callenthey're simpler than protocols half the time.
22:42bjaI figured out how to log the namespace in my console.log messages from clojurescript today
22:42bjathat was actually pretty exciting
22:43callenbja: black triangle?
22:44ambrosebsis there a good reason why Clojurescript cannot be AOT compiled?
22:44SegFaultAXcallen: While I don't need Java interop, type based dispatch is /exactly/ what I'm after.
22:45bjaambrosebs: isn't that basically what happens? you AOT compile it to javascript instead of .class files
22:45SegFaultAXIf I used multimethods, I'd just invent something like dispatching on type anyway.
22:45ambrosebsbja: I mean cljs.compiler.
22:46SegFaultAXcallen: Generally I agree with you, but in this case protocols does actually seem warranted.
22:46callenSegFaultAX: then go forth with my blessing, but know that it'll fuck with your REPL anyway.
22:46callenand if they're mappy data structures, use defrecord.
22:46SegFaultAXcallen: How so? I thought defrecords and deftypes can be freely re-eval'd?
22:46callenyou'll be torn limb from limb if you use defstruct.
22:47Apage43SegFaultAX: they can
22:47callenSegFaultAX: they can
22:47Apage43but you wind up with two classes with the same name
22:47Apage43which is Fun (TM)
22:47SegFaultAXActually in this case deftype is sufficient.
22:47callenDOdl;kfhmklnflhknf
22:47callendon't.
22:47bjacallen: no. the black triangle was a couple months ago. this just improves my debuggering immensely. Since I can now write (??? interesting-value) and end up with something like "my.first.namespace: (foo (bar baz))" in the console log
22:47bjaerr, debugging
22:47callendebuggering? are you oppressing homosexuals?
22:47SegFaultAXcallen: No no, definitely not using defstruct.
22:47callenbja: very illiberal of you :|
22:48callenSegFaultAX: use defrecord anyway >:)
22:48xeqiambrosebs: you mean compiled and distributed as a library?
22:48danielszmulewi-1Just use tools.namespace and read the warnings: https://github.com/clojure/tools.namespace#warnings-for-protocols
22:48SegFaultAXWhat if I only /ever/ have like 3 fields, you reckon the overhead is worth it?
22:48Apage43(you'll have things like instances of the pre-reeval class and the post-reeval class behaving differently, and such)
22:48bjaSegFaultAX: I find it to be
22:48Apage43and not being considered to be the same type
22:48ambrosebsxeqi: Basically. I'm jumping through hoops to get Clojurescript working with my AOT code.
22:48Apage43or .equals to each other
22:49callenSegFaultAX: you should use defrecord by default. deftype is for when you need the chainsaw.
22:49SegFaultAXUnderstood.
22:49callenie, your name is aphyr.
22:49SegFaultAXcallen: Thanks!
22:49SegFaultAXAnd the rest of you, thanks! :)
22:49xeqiambrosebs: ack, I was thinking you meant your own code, not the compiler.. hmm
22:49ambrosebsxeqi: sorry. I only use the compiler ;)
22:51callenSegFaultAX: pretty sure Stuart Sierra's workflow handles how to manage things like protocols cleanly in a REPL workflow.
22:51SegFaultAXcallen: Ok thanks. I pretty much just looked at the flowchart, I'll give the article a closer read.
22:52Apage43the main thing is you just gotta be careful with old instances hangin around
22:52Apage43if you make sure you don't do that, you're pretty much alright
22:52SegFaultAXApage43: Was that to me?
22:53Apage43in general, about the topic of protocols and REPLs
22:53Apage43to whoever cares :)
22:53SegFaultAXWhy would objects just arbitrarily hang around?
22:54Apage43I personally have scratch names all over the place when I'm REPLing
22:54SegFaultAXApage43: Memory is cheap. ;)
22:54Apage43I might reload a protocol and forget the instance I created of it earlier and gave a name to was from before I reloaded it
22:55Apage43or you might have a "on-app start" function in your app that builds its initial state, and if that instantiates some things and you *don't* rerun it after you reload a protocol definition
22:56Apage43it could get hairy
22:58danielszmulewi-1Apage43: at which point you restart a new REPL...
22:59SegFaultAXdanielszmulewi-1: Like... ew
23:00danielszmulewi-1SegFaultAX: exactly... anathema
23:11chordanyone here?
23:13akurilinAm I correctly understanding that a maybe monad would be one decent way to solve the issue of having a lot of conditionals in my ring handlers that make sure the result of each subsequent operation isn't nil?
23:17weavejesterakurilin: In Clojure 1.5, there is the some-> function that fulfils a similar role.
23:17chordjust use haskell
23:18akurilinweavejester, awesome, thanks for the tip. I always forget about those as I'm always on clojuredocs. That github wiki from the google groups seems to have it though.
23:26marco1for clojurescript, what's the equivalent of: someObj["func"]() ?
23:27gfredericks((aget someObj "func")) last time I used cljs
23:29marco1Thanks!
23:31danielszmulewiczweavejester: you nightbird :-)
23:31weavejesterdanielszmulewicz: I code better at night, but I'm just about getting to bed :)
23:32danielszmulewiczweavejester: same here, my friend
23:32danielszmulewiczweavejester: already in bed :-)
23:32RaynesOwl.
23:37john2x"((aget someObj "func"))" it's not possible to do ((:func someObj)) in cljs?
23:46chordlets make a game with clojure ok