#clojure logs

2013-09-15

00:02elifreyhello all. I've got a program I'm writing in elm, but the ecosystem is very young so I'm thinking of rewriting it in clojurescript
00:02tomjackcool
00:03elifreythe three things I really need are a parser combinator library, an FRP library, and a graphics library. I was wondering if anyone had some experience in these areas and could make some suggestions
00:04elifreyI saw several Parser combinator libraries, but many of them looked un-maintaned
00:05Foxboron"parser combinator", i am not exactly sure if i know what that is, but instaparse?
00:05elifreyparser combinators just reify parsers so you can write functions from parsers to parsers or other fun things
00:05tomjackI don't know of any FRP libraries for clojurescript yet
00:06callenelifrey: Instaparse
00:06tomjackoh, javelin is clojurescript
00:06callenwhich is a terrible name for a CLJS library, given that Javelin was already a JS library.
00:06callenI wish people would at least google first :|
00:07lgs32aelifrey: can you give me an example who i would write functions from parsers to parsers?
00:07elifreylgs32a: there are many reasons, here are a couple
00:07lgs32ahow i mean
00:08elifreyoh
00:08callenlgs32a: https://github.com/Engelberg/instaparse
00:08elifreydo you mean how would you write a parser combinator library, or how would you write a parser using parser combinators?
00:08lgs32anah i think i understand the concept
00:09lgs32ai was just curious what you mean by write functions from parsers to parsers
00:09tomjackin elm, do you have to be careful not to get bitten by a lack of referential transparency?
00:10elifreytomjack: not at all. All of your interactions with the "real world" are managed by FRP. It's quite nice, I just started finding too many bugs in the compiler :(
00:10tomjackso e.g. the slideshare I found by googling "frp clojurescript" uses Rx
00:11tomjackin which you do have to be careful
00:11elifreytomjack: sure
00:11tomjackand I believe you have to be careful in all attempts known to me, both in clj and cljs
00:11muhoo,frp
00:11clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: frp in this context, compiling:(NO_SOURCE_PATH:0:0)>
00:11muhoo~frp
00:11clojurebotfrp is functional reactive programming, or fiberglass reinforced plastic
00:12elifreyin <dynamic language> you have no way to prove you arn't performing effects inside of your event streams
00:12tomjackI don't think it's just about effects there
00:13tomjackthe problem is that you can't pass an(y) observable around and always get consistent answers out of it
00:13elifreytomjack: if your code is pure and without effects, it is referentially transpent (for some value of referential transparancy)
00:14tomjackbut Rx code is never pure
00:15elifreyis it a situation that you might, say, map an impure function over an observable, or is the implementation of observables themselves break their denotation?
00:15tomjacke.g., say I do a selectMany where the function passed always returns the same hot observable
00:15tomjackthe latter
00:16tomjacksome cold observables may work
00:16elifreyI have not used Rx, only Reactive Banana, elm, and Bacon.js
00:16elifreywhat are hot/cold observables?
00:17tomjacka cold observable is basically a relatively pure (fn subscribe [callback] ...)
00:18tomjacklike interval, which emits messages at fixed intervals
00:18tomjackevery time you subscribe it starts at the beginning
00:18tomjackIIRC?
00:18tomjackhot is like a mouse event stream or something
00:18tomjackevery time you subscribe, you just start listening from now on to the same thing everyone else is subscribed to
00:19elifreyah, yes, there is a funny business to do with when you start observing
00:19tomjackI think elm just bans the behavior monad?
00:19tomjackI never looked closely enough at elm
00:19elifreyyeah, that was another problem I was having with elm, you can't join nested "signals"
00:20tomjackso that means no selectMany
00:20tomjack/ mapcat ?
00:20elifreymapcat, bind, flatmap, whatever you want to call it
00:21elifreyin Reactive Banana they weild the fact that FRP is the curry-howard corespondance to temporal logic to statically guarantee away the kinds of errors you are talking about
00:21tomjackwow I never knew
00:21tomjackI have been reading "LTL Types FRP"
00:21muhooreactive..... banana?
00:21tomjackI assumed you needed dependent types
00:22elifreytomjack: oh thank goodness no
00:22callenelifrey: er...you can do that without dependent types?
00:22elifreycallen: yeppers
00:22callenoh, but it is Haskell
00:23tomjackdoes it amount to using extensions as hacks to get some dependent-type-like features?
00:23elifreywhat you end up doing is "trimming" your event streams to a new start time whenever you join
00:23elifreynope
00:24elifreythis perticular part of the lib is Haskell98 I think
00:24elifreytho internally it uses a GADT somewhere
00:24callentomjack: I was equally suspicious but took them at their word.
00:25tomjackthat's the behavior comonad?
00:25tomjack..i.e. □ ?
00:26elifreytomjack: hmm? I can't tell if your joking or asking a question?
00:26dissipate_does anyone have some examples/tutorials of the threading macro: http://richhickey.github.io/clojure/clojure.core-api.html#clojure.core/-&gt;&gt; ? the explanation in 'Clojure Programming' is terribly terse.
00:27tomjack(□ A) t = ∀ {u} → t ≤ u → A u
00:27callenelifrey: http://hackage.haskell.org/packages/archive/reactive/0.11.5/doc/html/src/FRP-Reactive-Behavior.html
00:28tomjackbut that only makes sense with dependent types, hmm
00:30elifreycallen: ReactiveBanana, not reactive
00:31elifreyreactive is Conal Elliots pure vision baby child that doesn't actually work on GHC do to what he would call a bug
00:31elifreyhttp://hackage.haskell.org/packages/archive/reactive-banana/0.7.1.3/doc/html/Reactive-Banana-Combinators.html
00:33tomjackI was reading the Model, doesn't make much sense yet
00:34tomjackI'd like to see a clojure library where you didn't have to be careful
00:35elifreytomjack core.typed?
00:35tomjack:(
00:36elifreyI don't think you can get around this one statically without... static checking
00:36uvtcdissipate_, re. `->>`, did you have a look at the examples at <http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E&gt;?
00:36tomjackhmm, I figured you could
00:37tomjackwith elm, does the static checking and no join allow it to compile out to a really fast impure implementation?
00:38elifreyit's all CPS and settimeout under the hood, so I assume, but I'm not sure
00:38tomjackit seems like it should definitely be at least possible to implement referentially transparent signals. maybe making it efficient is difficult?
00:39elifreyah, yes, the efficiency. so you're talking about, how do do something other than "sample the value at intervals"
00:40elifreyConals dream is to do to event based programming what vector graphics did to graphical programming
00:41elifreyby which I mean, allow you to work on continuous values
00:41elifreythis is very tricky to do efficiently
00:41elifreywhat most libraries do is to completely ignore the denotation of a behavior as a time-varying function, and just give you combinators to wire up an event graph
00:42elifreyonce you have the event graph, you can just have everything be event-driven under the hood and performance is not a problem
00:43tomjackdo you get referential transparency for an event stream merged from two others?
00:44elifreyyes and no
00:44tomjackI remembered 'future seqs' have been attempted at least a couple times in clojure
00:44tomjackwhich pass some transparency tests Rx etc fail
00:44tomjackbut fail on merge
00:44elifreyreferential transparency is a funny fraise
00:44elifreybecause really it only cares about transparency with respect to a given denotation
00:45elifreyerr
00:45elifreysorry
00:45elifreysemantics
00:45elifreys/denotation/semantics/
00:45elifreyif you can provide a semantics that make the given sentence referentially transparent, your golden
00:45elifreythis is often trivial given the right operational semantics
00:46elifreyconsider
00:46elifreyx = x++
00:46elifreytypically we do not consider the ebove expression to be referentially transparent
00:46elifreybecause we are not able to give a /denotative/ semantics to it
00:47elifreybut we are perfectly capable of giving a /operational/ semantics
00:47elifreyso, under our interpretation of FRP as wiring up an event graph, we can give a reasonable operational semantics to the event graph and referential transparency is restored
00:48elifreywould we say that we still, as humans, have the same ability to reason about the semantics?
00:48elifreyI would argue no
00:50tomjackI guess merge is no problem without join?
00:51elifreyabsolutely
00:51elifreyjoin introduces non-determinism
00:52elifreythis is a fundamental atribute of monads, they make some "future" expression dependent on "past" expressions
00:52tomjackso using a library like Rx safely basically means making sure you don't accidentally implement a (broken) join?
00:53tomjackwell they already implemented it for you I guess
00:55elifreyI am not confident enough to say yes, but probably :)
01:03tomjackI've been trying to think how core.async fits in
01:03elifreytomjack: to frp?
01:04tomjackI found it interesting that the implementation in "LTL Types FRP" is async and that causal functions are modelled as processes
01:04tomjackyeah
01:04tomjackbut I don't think a core.async 'process' is the same kind of process..
01:05elifreyI actually have not read that paper, when people press me abuot the corespondence I just hand wave :(
01:08tomjackit looks like a causal function is (implemented as) either a function which takes an interval of input to a new causal function, or an interval of output with the next causal function, or it's done
01:09dissipate_uvtc, i don't see what the threading thing buys you. it just looks like it reverses the order of things.
01:09tomjackwhich sounds vaguely reminiscent of core.async's channels
01:09tomjackbut they are no help I think
01:09elifreydoes causal function mean Behavior?
01:10elifreyis an interval an interval of time?
01:10tomjackyeah
01:10uvtcdissipate_, Right. I suppose there are some circumstances where it might make things more readable, depending upon the reader. :)
01:10tomjackto the second question
01:10tomjacka causal function is a function from behavior to behavior with.. certain restrictions
01:11dissipate_uvtc, is it a replacement for using 'partial'?
01:11callennot really.
01:12uvtcdissipate_, No, I don't think so. I think `->>` is just a convenience thing, if you like reading things from top to bottom. :)
01:12callenchaining an initial piece of data through functions in Clojure is...quite common. Especially if the code is well written.
01:12callenhaving sugar for that makes a ton of sense.
01:13SegFaultAXIt isn't really a Clojure thing, it's a programming thing.
01:14elifreycallen: I think this is one of the things that makes idiomatic clojure much more readable than idiomatic <other lisp>
01:14SegFaultAXx = foo(1); y = bar(x); z = baz(y); return quux(z)
01:14SegFaultAXelifrey: It would be trivial to implement a threading macro in most other lisps.
01:15callenelifrey: the threading macros are the least of it.
01:15dissipate_uvtc, what is the idiomatic thing to do?
01:15elifreySegFaultAX: yes but they don't, that's why I said idiomatic
01:15callenarity regularity makes it useful/non-painful to begin with. Lisp-1, and a bunch of other stuff too.
01:15callenSegFaultAX: seen any golang or C code recently?
01:15SegFaultAXcallen: Yes?
01:15callenyou can't just "do" something and chain results. You have to play mother-may-I with the computer.
01:15callennothx
01:16SegFaultAXelifrey: Macros are idiomatic in Lisp.
01:16dissipate_callen, were you referring to the ->> macro?
01:16uvtcdissipate_, Personal preference, IMO. Personally, I'm not crazy about using `->` and `->>`, and generally find them a tad less readable than doing this the usual way, but please take that with a grain of salt. :)
01:17uvtcs/doing this/doing things/ ^^
01:17elifreySegFaultAX: yes, but it is not idiomatic to use a threading macro in other lisps. If you just started doing it willy nilly, people unfamiliar with your code would think you're bonkers
01:17dissipate_elifrey, is it idiomatic for clojure?
01:18elifreydissipate: I certainly see it in lots of code
01:18SegFaultAXelifrey: Doubt it. As with any new syntax, it might take some time to get used to it at worst.
01:18dissipate_uvtc, do you see how this is frustrating for someone trying to lean clojure? :(
01:19dissipate_elifrey, what's the rule for when to use it?
01:20SegFaultAXdissipate_: The same for any syntax: if it makes the code and the intent clear.
01:20benkay(+ 1 (2 3 4))
01:20uvtcdissipate_, For now, I suggest you skip using `->` and `->>`. Then at some point later on you might run into a case where `->` and/or `->>` will be more convenient. :)
01:20benkay,(+ 1 (2 3 4))
01:20clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
01:20SegFaultAXx = foo(1); y = bar(x); z = baz(y); return quux(z) <=> quux(baz(bar(foo(1)))) but the latter might be too hard to understand.
01:21elifreydissipate: (f (g (k (v x)))) to (-> x v k g f)
01:21SegFaultAX(-> 1 foo bar baz quux) expands to a let form that is similar to the first case.
01:21uvtcdissipate_, Oh, almost forgot. Regarding what's idiomatic or not, have a look at the [Clojure Style Guide](https://github.com/bbatsov/clojure-style-guide).
01:25s4mueldissipate_: a good general case for -> is ring handlers 'in sequence'. (-> handler apply_this_mw then_this then_this_one return_handler) is a lot more readable than the alternative IMO
01:25SegFaultAXs4muel: Funny you should mention that, because -> is actually the opposite in that case.
01:25elifreySegFaultAX: huh?
01:26SegFaultAXelifrey: Handlers are run in reverse order.
01:26elifreyah
01:26elifreydissipate: any time you want to send something through a "pipeline"
01:26s4muelHe's right for the ring case, (oops) but semantically I thought it was a good example
01:27elifreycat log | cut -f1 | sort | uniq | head -n1
01:30uvtcRegarding Emacs and repl integration, I'm trying to understand which pieces talk to which. Does nrepl.el take care of whipping up a repl and then connecting to it?
01:30s4mueluvtc: Yes, it runs lein repl :headless and connects (assuming you're talking about nrepl-jack-in)
01:30dissipate_elifrey, i thought all of clojure was 'pipelines', applying in sequence forms to data structures?
01:31elifreydissipate: thus I would find -> indispensible :P
01:32dissipate_uvtc, i didn't see that before, thanks!
01:32dissipate_elifrey, i don't see what it buys you really though. to me it just seems to reverse the order of evaluation.
01:32uvtcs4muel, Ah, thanks. What is the difference between M-x run-lisp and M-x nrepl-jack-in?
01:32uvtcWhich should I use?
01:32dissipate_elifrey, although, i can see in some cases it is easier to read if things are in the reverse order
01:33uvtcdissipate_, y/w. :)
01:33s4mueluvtc: I think the former just kicks off the generic 'inferior lisp', but I'm not sure.
01:33elifreydissipate: I'm just not so big on parens
01:33s4mueluvtc: in terms of integration with clojure, 99% of the time, you want nrepl-jack-in
01:33uvtc60% of the time, nrepl-jack-in works every time.
01:34uvtche he {cough, sputter, cough} Sorry. :)
01:34elifreydissipate: clojure's syntax gets rid of many parens, but -> helps you for one of the most agregious offendors IMHO
01:34uvtcs4muel, Ok, will try nrepl-jack-in. I'd seen mention of M-x run-lisp at <https://github.com/clojure-emacs/clojure-mode&gt;.
01:35s4mueluvtc: You might have a better overall experience using something like emacs-live. I don't know how 'invested' you are in your current emacs config. :)
01:37uvtc<https://github.com/clojure/tools.nrepl/&gt; indicates that nREPL (aka tools.nrepl) provides both a server *and* a client. But it seems to me that, when integrating with Emacs, nrepl.el is the client (and so whatever client nREPL provides goes unused). Does that sound about right?
01:37dissipate_elifrey, what is the worst offender?
01:38elifreydissipate: nested function calls
01:38dissipate_elifrey, i see. i'll definitely keep that in mind.
01:39uvtcs4muel, Thanks. I don't know what emacs-live provides. I tend to prefer a simple from-scratch setup, and don't do a lot of heavy customization.
01:40lgs32auvtc: emacs pure is fine
01:40lgs32auvtc: if you are new to emacs, a guy just made an insanely great video tutorial series on youtube
01:41uvtcI just want to understand the simplest way to configure Emacs + nREPL + nrepl.el, but don't completely yet get how all the parts fit together.
01:41uvtclgs32a, I wrote up my basic Emacs config at <http://www.unexpected-vortices.com/clojure/10-minute-emacs-for-clojure.html&gt;.
01:42lgs32ayou don't really need to do a whole lot
01:42uvtcSo far it looks like I just need to "M-x package install RET nrepl RET" and then "M-x nrepl-jack-in". :)
01:42lgs32afor nrepl
01:42lgs32ayes
01:42lgs32aexactly
01:42lgs32aideally have a buffer with a current project open
01:42uvtcTrying it now ...
01:43elifreylgs32a: does it automagically hook into lein?
01:43lgs32ayou can either connect to an existing server or let it create one
01:44lgs32asometimes you need to set the shell command for lein, but if it's on the path and you are on gnu, everything should be fine
01:44elifreycool
01:44lgs32auvtc: if you need auto-completion, here is what needs to be added to the emacs.nl (given auto-complete is installed) http://stackoverflow.com/questions/18259113/emacs-clojure-autocompletion-data-from-all-source-files-in-project/18263522#18263522
01:44callendid anyone else notice a hammock company is sponsoring Clojure Cup?
01:45lgs32aits ac-nrepl
01:45lgs32aemacs.el ofc
01:45lgs32acallen: lol!
01:46uvtcNot using ac-nrepl at the moment. Just focusing on getting nrepl.el/nREPL working.
01:46uvtclgs32a, ^^
01:54uvtcSo, after I create `lein new app my-proj` and open my-proj/src/my_proj/core.clj, and then run "M-x nrepl-jack-in" and get a "user>" repl, how can I call my `main-`?
01:55uvtc(main-) fails. Can't find it.
01:55s4mueluvtc: Load the file containing main with C-c C-k.
01:56s4mueluvtc: Then, switch to the file's namespace with C-c M-n, should reflect in the repl.
01:56callenuvtc: http://www.infoq.com/presentations/Clojure-Namespaces-Vars-Symbols
01:57uvtcs4muel, there we go. Thanks!
01:57callenuvtc: watch the video.
01:57callens4muel: when you toss them morsels that quickly, they never learn to cook steak.
01:57uvtccallen, will do. Thanks for the link.
01:58callens4muel: better to just understand namespaces, symbols, and vars - and never be confused for bad reasons again.
01:58uvtcI want to learn to cook the steak.
01:58callenuvtc: then you'll do fine. Just watch the video, best resource I know for the subject. I don't even usually like A/V content.
01:58callenCraig did a great job.
02:23s4muelcallen: Ah, yeah, I agree. Just thought he was asking for nrepl help, missed the larger context :)
02:25callenwhat is good in life? To drink, listen to Rich Hickey interviews, crush your bugs, see them driven before you, and hear the lamentations of their exception classes.
02:25callenTo drink tea*
02:25uvtcs4muel, I understand a good bit about symbols, vars, and namespaces, but there's room for improvement, and the video is good so far (though almost nothing yet about how to cook a steak!).
02:31s4muelcallen: I appreciate a good conan reference
02:32uvtcHeh. That one reaches back into the archives. :)
03:34ambrosebsAnyone seen this implemented in Clojure? http://docs.racket-lang.org/reference/parametric-contracts.html#(form._((lib._racket/contract/parametric..rkt)._parametric-~3e/c))
03:35callenambrosebs: conditions + multimethods?
03:36ambrosebscallen: I don't know. I'll dig into the Racket impl.
03:37ambrosebsI didn't realise contracts could be parameterised like this. Nice.
03:39dcunit3dis there a good way to run my lein tests and then enter a debugger if they fail?
03:39dcunit3di've tried running them via emacs with C-c C-, but it doesn't resolve methods from other files
03:41dcunit3dand is there anything like spork for clojure? so when i run my tests it connects to an initialized JVM with my code loaded?
03:41callenambrosebs: my point is it seems like :pre and :post in Clojure.
03:41callenI can't tell what would otherwise be missing from the Clojure impl
03:42ambrosebscallen: the first example on that page has a contract (parametric->/c [X] (boolean? X . -> . X)) for some X
03:43ambrosebscallen: that's what I'm interesting in.
03:43uvtccallen, thanks again. Learned some things from Craig's talk. :)
03:45ambrosebscallen: it looks like it has a little type system in the contracts syntax.
03:45callenuvtc: good good :)
03:45callenambrosebs: Clojure conditions are more like multimethods. You just do whatever you want.
03:46callen(fn [arg1 arg2] (boolean? arg1))
03:46callenambrosebs: ^^
03:47ambrosebscallen: no, the X is a variable. The return value must match the 2nd argument.
03:48ambrosebscallen: it seems beyond any current contracts library for Clojure.
03:48TEttingerambrosebs, couldn't you ensure that with :post ?
03:49callenwhich is my point
03:50callenthat's why I'm saying conditions because it's pre and post. Not just preconditions.
03:50callennothing is beyond pre/post conditions in Clojure because they happen at runtime and are just functions that can do anything
03:50ambrosebsI should clarify, I'm looking for a way to convert a core.typed type to a contract.
03:51callenconvert them to :pre/:post conditions.
03:52callenI'm not sure what the advantage of that would be though - just pushes compile-time out to runtime.
03:54callenthe advantage of :pre/:post to a type system are that you have the full extent of the language available at runtime.
03:56callenambrosebs: is it not enough that core.typed does one thing well, and :pre/:post do one thing well? :)
03:56ambrosebscallen: I don't see how pre/post conditions are powerful enough to implement the parameterise-c example.
03:57ambrosebscallen: core.typed works just fine with pre/post conditions anyway.
03:57ambrosebscallen: this is about generating contracts at typed/untyped boundarise to conserve type soundness to runtime.
03:57ambrosebs*boundaries
03:58callenreally? you don't see how you run boolean? on arguments and outputs from a function with :pre and :post?
03:58callencould run*
04:00ambrosebscallen: read the example on the parameterised contracts page.
04:02ambrosebscallen: I'm sure there are more complicated examples that use lots of type variables.
04:02callenambrosebs: I understand it just fine. it's a cond/case in the :pre or :post
04:03callenbecause again... :pre and :post are just functions and have the whole language as well as data at runtime.
04:04callenand like I said earlier, :pre/:post + multimethods let you dispatch without writing a big branch if you don't want to
04:04ambrosebscallen: right. Obviously the only limitation is that you can't share scope between a pre/post. I guess you could do constraint inference in the :post to make sure the X's match up.
04:04callenI feel like I should've been less subtle in the point I made earlier about mm + conditions.
04:05callenshare scope between :pre and :post? That's a macro away from happening :)
04:05callenrealistically? part out the logic.
04:05callencompositional assertions -> contracts
04:11dobry-denHow would you get console output behavior like: "Loading... Done." where there's a long wait between Loading... and Done.?
04:11callendon't print a newline
04:11Ember-,(println "Loading...") #_(long-running-stuff) (println "Done")
04:11clojurebotLoading...\n
04:12Ember-?
04:12callenyou printed a newline :|
04:12Ember-and yeah, if you want them on the same line, then use just print
04:12Ember-callen: didn't realize he wanted them to be on the same line :)
04:12Ember-until you said that
04:13TEttinger##(do (print "Loading...") #(Thread/sleep 2000) (print " Done"))
04:13lazybot⇒ Loading... Donenil
04:14TEttingerhm how do you make lazybot properly wait... I use overtone's at-at lib for this
04:14TEttinger`google overtone at-at
04:14TEttinger$google overtone at-at
04:14lazybot[overtone/at-at · GitHub] https://github.com/overtone/at-at
04:14callenat-at is great :)
04:15dobry-den(do (print "Loading...") (Thread/sleep 3000) (println "Done.")) still makes the whole line wait until 3000ms passes to flush whole line
04:15TEttingerdobry-den, I think it's the do
04:15TEttingerbut there's no way... wait
04:15TEttinger##[(print "Loading...") #(Thread/sleep 2000) (print " Done")]
04:15lazybot⇒ Loading... Done[nil #<sandbox5671$eval11656$fn__11657 sandbox5671$eval11656$fn__11657@896efd> nil]
04:15TEttingergod...
04:15callenwas that the original problem?
04:15dobry-denyou don't need #
04:15TEttingeroh.
04:15TEttingerdarnit
04:15callenthat it buffered the output?
04:16dobry-denBasically i'd like it to work like (print "Loading...") (flush) (Thread/sleep 3000) (println "Done.")
04:16dobry-denbut flush makes newline
04:17TEttingerdobry-den, this will work ##((fn [] (print "Loading...") (Thread/sleep 2000) (print " Done"))) but lazybot's preview will need to eval the whole thing first
04:17lazybot⇒ Loading... Donenil
04:17TEttingernote the timestamps, waited 2000 ms
04:17TEttingerat least
04:17TEttingerI think it will work
04:18dobry-denit still waits 2000 before flushing anything at all
04:19dobry-denI guess for now I will settle for "Loading...*wait*\nDone."
04:20dobry-denBut that's not the badass aesthetics i had in my head
04:20TEttingerdobry-den, hm
04:21TEttingerthere's futures
04:21callenyou do not need futures for this :|
04:22TEttingercallen, I think the problem is the waiting, not the printing
04:22callendobry-den: it worked perfectly for me
04:22callenTEttinger: what?
04:22callenTEttinger: he was complaining about the aesthetics and there being an extra new line.
04:23callenI have it all one line, working fine.
04:23TEttingerdobry-den, can you tell us if you are having trouble making it wait or having trouble printing on one line?
04:23dobry-denThe problem is that (do (print "Loading...") (Thread/sleep 1000) (println "Done.")) doesn't print "Loading..." until after the 1000ms wait
04:24callenI added (flush) and it worked fine.
04:25TEttingeryep, that works
04:25dobry-dencallen: i tried in regular repl and it works. weird - it doesnt work in nrepl
04:25dobry-denalrighty then
04:25callenemacs nrepl isn't intended, by any means, to be perfectly representative of stdout/stdin behavior
04:26callenthat's true of emacs buffers in general.
04:26callenthey're an editing environment, not a terminal one.
04:26dobry-denright, i just didn't think about it
04:26lgs32ais it impossible to define varadic methods for a protocol?
04:27callenfor one thing, you shouldn't really be defaulting to using protocols for everything
04:27callenI really wish people would stop doing that. It's unnecessary and pins you down.
04:28lgs32ai don't why would you think so?
04:29callenthey're not going to support destructuring in defprotocols.
04:29callenif you need destructuring, you're using protocols incorrectly.
04:30callenStop using protocols for everything.
04:30callenUse multimethods.
04:31wei_does anyone use vim + nrepl, and have vim freeze one out of every six times you try to evaluate the buffer?
04:36wei_it's like coding russian roulette
04:38rhgYup
04:38callenlol vim :)
04:56wei_considering switching to emacs just for the clojure integration, but it seems to have a high activation energy..
05:00augustlwei_: I don't want to use emacs but its features gives me no choice
05:01wei_that's how I'm starting to feel too. btw thanks for your help over at datomic
05:01lgs32athere is only one true editor
05:01wei_(inc augustl)
05:01lazybot⇒ 2
05:06TEttingerI like lighttable
05:11augustlwei_: no probs :)
05:20RaynesI like darktable.
05:20RaynesTIL http://en.wikipedia.org/wiki/Darktable exists.
05:54quazimodohay hay
06:11ambrosebsclojure-contracts supports parametric contracts, for those interested. See Dependant Contracts http://t.co/ssZbKrDL8E
06:13squidzambrosebs: how is the progress on typed clojurescript?
06:13ambrosebssquidz: better than 2 months ago!
06:13ambrosebssquidz: basically I need to annotate the DOM now.
06:13squidzright now i'm using schema but I can't wait to have it for clojurescript
06:13ambrosebssquidz: cool!
06:14ambrosebssquidz: it's not ready yet, but it's fun to hack around with.
06:14squidzthere isn't much out on the web yet on it right?
06:14ambrosebssquidz: I think there is literally nothing :)
06:15ambrosebssquidz: but the good news is that it's the same as Clojure support, except replace clojure.core.typed with cljs.core.typed
06:17squidzambrosebs: what do you mean?
06:19ambrosebssquidz: so CLJS support is basically a bunch of macros in the cljs.core.typed namespace. You should replace (:require [clojure.core.typed :as t]) with (:require-macros [cljs.core.typed :as t]) and most of the type system semantics are identical.
06:20ambrosebssquidz: then run the Clojure macro (cljs.core.typed/check-ns 'my-ns) in a Clojure REPL to check a CLJS namespace.
06:20squidzokay and that works for all of the javascript interop types too?
06:21ambrosebssquidz: the types are slightly different.
06:21ambrosebssquidz: eg. there are string and number primitive types. Also things like Seqable are slightly different. clojure.lang.Seqable vs cljs.core/ISeqable.
06:22ambrosebssquidz: I intend to include more type aliases to save rewriting the types for CLJ/CLJS.
06:23ambroseb_squidz: I'll get an example.
06:24squidzambroseb_: okay you should document it so that more people know about it
06:26squidzthere's a lot of stuff for clojure but nothing for clojurescript. I know it isn't really ready but people might still play around with it
06:27ambroseb_squidz: yes, you're right.
06:27ambroseb_squidz: https://github.com/clojure/core.typed/blob/master/src/test/cljs/cljs/core/typed/test/dnolen/utils/dom.cljs
06:28ambroseb_squidz: to check, run (cljs.core.typed/check-ns 'cljs.core.typed.test.dnolen.utils.dom)
06:29squidzambroseb_: thanks
06:29ambroseb_squidz: I think if the Clojurescript *ns* is pointing to the desired ns, (check-ns) should also work
06:29supersymambroseb_: ahhh... nice. I'm really getting warmed up for Cljs, this 'll fit in nicely
06:30ambroseb_supersym: :)
06:30ambroseb_bug reports for CLJS are very welcome.
06:31ambroseb_even if you get a NYI error :)
06:31ambroseb_should help smooth out things, even at this early stage.
06:32ambroseb_to here: http://dev.clojure.org/jira/browse/CTYP
06:32supersymambroseb_: Checking arbitrary expressions: yeah somehow I knew that but never really use :pre :post that way... fun
06:32supersymbtw typo there : standart
06:33supersym(sorry)
06:33ambroseb_supersym: where?
06:36supersymambroseb_: http://t.co/ssZbKrDL8E -> Checking arbitrary expressions.
06:36supersym"clojure's standart mechanism of "
06:38ambroseb_supersym: ah. Not my library.
06:39supersymoh sorry I thought it was :)
06:39ambroseb_supersym: I wish! :)
06:54ddellacostais there a way to use clojure.repl/doc in CLJS repl?
07:13supersymddellacosta: I don't think so. http://goo.gl/jz0RPG It seems this would be the cljs equivalent but I'm far from expert on this, david nolen would know
07:15ddellacostasupersym: thanks. Yeah, I don't care so much, as there are plenty of places to look up functions, but it would be handy. Ah well.
07:15supersymyup
07:15supersymI can imagine that too
09:11squidzis there way to do async tests with clojurescript.test? I tried wrapping a go block around my deftest form, but am getting the error: nth not supported for this type:Symbol. Anybody have any ideas?
09:35javaxhttp://groups.google.com/group/clojure
11:30yuryHi everyone!
11:30yurycould someone give me quick tip on filtering?
11:32scottjyury: use the correct predicate
11:33yurysuppose I have list of records and one record, I need to get records from list with specified fields equal to that of record
11:35yuryfor one field this is pretty straightforward function
11:35seangrovednolen: Attached the patch to http://dev.clojure.org/jira/browse/CLJS-547
11:37scottjyury: with any or all of the specified fiels equal to that of record?
11:37arrdemyury: you want to use every, map and =
11:37yurywith some fields
11:39AimHereIsn't this just a job for filter?
11:40AimHereSomething like (filter #(and (= (:foo X) (:foo %)) (= (:bar X) (:bar %)) recordlist) ?
11:42hyPiRion(filter #(apply = (map (partial select-keys :foo :bar) [X %])) recordlist)
11:42hyPiRionurgh, wrong order on that select-keys, but oh well
11:44arrdemyury: https://www.refheap.com/18687
11:45arrdemtested for records having a superset of the keys in the template
11:45arrdemwill fail for records having a subset of the keys in the template
11:56yurythanks a lot, select-keys was just what I've needed
12:25fredyrDoes hiccup work for generating any xml, or just for html?
12:31AimHerefredyr, I think properly formatted hiccup input spits out something you can use for xml
12:31AimHerefredyr, not sure how well it supports generating doctype declarations and such
12:32fredyrRight, might be better to stick to the xml libs
12:34supersymsigh...sometimes I wonder if Java exceptions could possibly be any more vague than they are now
12:35supersymah..found it :P
12:39hyPiRionwell, they could just return "Segfault"
12:40supersymoh.. thats true
12:40Chousukeit's most fun when you have Java servers in production/test environments producing 7GB of debug logs per day because logging is good, right? :P
12:41supersymyeah I dont envy that at all
12:43Chousukeit's completely useless to log that much. no-one is ever going to read something like that.
12:48hyPiRiondepends. You can aggregate it
12:48dcolish7G seems like a misconfiguration, but logging is really useful when things go wrong and I can't figure out how.
13:01Caballeroanybody alive?
13:02hyPiRionyes
13:02Caballeroneed help with clojure, beginner here
13:03hyPiRion~anyone
13:03clojurebotanyone is anybody
13:03hyPiRion~anybody
13:03clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
13:03Caballerofair enough
13:04Caballerohow do I bind console input to a variable?
13:04CaballeroI'm working in eclipse - counterclockwise
13:06hyPiRionHmm, I've not used CCW, but (read-line) will read a line from the console
13:07hyPiRionIf you want to automagically convert it to things other than strings, I'd recommend using clojure.edn/read
13:10Caballerosurely there must be a simple way of doing this, like (def input(read-line))
13:10Caballerothis doesn't work, obviously
13:12hyPiRionWell, in the main function, you can do (let [input (read-line)] do-things-with-input)
13:15CaballeroI've tried that, but I'm struggling with concept of "let". How would I put it into a function?
13:17mtpby putting it in a function
13:17mtp"let" mostly means "bind variables"
13:17seangrov`,(defn my-fn [x] (let [y 10] (+ x y)))
13:17clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
13:17seangrov`,((fn my-fn [x] (let [y 10] (+ x y))))
13:17clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox$eval55$my-fn>
13:17seangrov`,((fn my-fn [x] (let [y 10] (+ x y))) 10)
13:17clojurebot20
13:17seangrov`There we go
13:23Caballero,(defn foo [] (let [input (read-line)]) (println input))
13:23Caballero(foo [])
13:23clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
13:23Caballerothis gives me nil
13:24mtpyes
13:24mtpit does
13:25mtpwhat does println return? consequently, what does the let form return, and finally, what does your function return?
13:27Caballeroeverything seems to evaluate to "#<Namespace user>"
13:27Caballerois this maybe the wrong place to ask newbe questions?
13:28seangrov`Caballero: No, it's fine, mtp's questions are appropriate for you though
13:28seangrov`,(doc println)
13:28clojurebot"([& more]); Same as print followed by (newline)"
13:28lunkhow can I set a public var on an instance object?
13:28seangrov`,(println "this returns nil")
13:28clojurebotthis returns nil\n
13:28seangrov`Weird
13:29seangrov`Didn't know clojurebot also captures stdout
13:29hyPiRion,(do (println "this returns nil"))
13:29clojurebotthis returns nil\n
13:29sontekIs there a place that describes what the implementation behind a vector is? I come from a python background where the "vector" is called a list and its implemented as an array behind the scenes
13:29sontekwhich means appending things to the beginning are extremely slow
13:29sontekI guess this isn't the case with clojure since its all immutable, so it just returns new vectors?
13:30seangrov`sontek: Yes, there are performance implications for the data structures you choose
13:31Caballeroin eclipse, what's the difference between "REPL" and "Console"?
13:31seangrov`For example, peek
13:36sontekseangrov`: is there documentation on this anywhere?
13:37mpenetsontek: not really docs but still: http://www.innoq.com/blog/st/2010/04/clojure_performance_guarantees.html
13:43sontekmpenet: thanks
13:48seangrovednolen: Should this ticket be closed, or am I missing something with goog.json and clj->js, etc.?
13:51yuryis there any guidelines about placement of different kinds of arguments?
13:52yuryf/e I have function with two arguments: one list of records and another record. which should come first?
13:54AimHereThe two considerations I can think of is variable argument lists and other similar functions of the same type
13:54rlbyury: I'd say nothing you've mentioned so far would argue either way.
13:54AimHereIf you have a family of similar functions, it probably helps to be consistent
13:54rlb^
13:55AimHereAnd if you want to generalise to more arguments of one or other of those two types, put the 'multiple argument type' last
14:25hadronzooWhen two namespaces require each other in clojurescript, it causes the compiler to crash. Is there a way to just import one ref from another namespace without using require or use?
14:26muhoothis seems... like ugly code to me that could be made less so: https://www.refheap.com/18689
14:26Bronsahadronzoo: circular dependencies are not supported in clojure or clojurescript
14:27hadronzooBronsa: I see. Thanks.
14:28hadronzooBronsa: If I explicitly prefix the namespace in clojurescript, it actually works, but it doesn't work in Clojure.
14:29Bronsahadronzoo: it's proabably an implementation detail that it works in clojurescript, I don't think you should rely on that
14:30hadronzooBronsa: Right, I'll refactor.
14:50yuryhow to use function with two arguments (one 'constant' and one being 'current' from list) in "apply"?
14:52joef_yury: `partial`?
14:52yurydunno. I have list to which I want to apply some F with two arguments
14:53ucb,(doc partial)
14:53clojurebot"([f] [f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & ...]); Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args."
14:53ucbyury: ^
15:02yury(defn f-one [some-list some-record] (...))
15:02yury(defn f-two [list-one list-two] ("here I need to consecutively f-one(list-two, each-record-from-list-one")))
15:03yuryhow to implement what between quotes?
15:03yuryfor function with single arg it's pretty straightforward with apply
15:03yuryand what to do with two args?
15:04borkdudewhat was the leiningen plugin again to host a directory on a simple http webserver?
15:04dnolenseangrove: thanks for the source map patch applying!
15:05joef_yury: like this? (defn f-two [list-one list-two] (apply (partial f-one list-two) list-one))
15:05joef_(urm, and some sort map/doseq, i guess?)
15:06jeborkdude: I believe you are thinking of lein-simpleton
15:06borkdudeje that's the one, thanks
15:06jeborkdude: np :)
15:07yojimbo_Hi - I am playing around with async http lib for scraping (I am using org.httpkit.client) what is the standard way of dealing with the issue that: in the repl async code works fine as the repl waits for the callback. But in a "lein run" the main just ends without the callback completing?
15:16joef_yury: (defn f-two [list-one list-two] (map (partial f-one list-two) list-one))
15:21yuryyeah, thanks, that seems did the trick. completely forgot about the map. shame on me :) and I'll will blame 1AM :)
15:23mayhewHey guys, I'm trying to get readline support in the Clojure REPL. I have clojure and jline installed on Fedora, but when I type "clojure" jline isn't being loaded.
15:27rcgmayhew, if you are on linux i'd go with rlwrap
15:27mayhewrcg: works perfect, thanks!
15:28rcghttp://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Enhancing_Clojure_REPL_with_rlwrap
15:28rcgmayhew, ^
15:28rcgthat should give you much more nice features :)
15:29mayhewrcg: cheers
15:30rcgyw :)
15:31tufflaxI'm using robert.hooke to add some logging wrappers to my functions. But I want to print the thread name in the log, since some functions are shared among several threads. I read that set! can change the thread-local binding of a var, so I tried (def thread-name nil) (set! thread-name "server") but got "Can't change/establish root binding of: thread-name with set", why? Also, is what I'm doing a go
15:31tufflaxod idea?
15:42coventry`Are there situations where it would make more sense to use lein simpleton than python's SimpleHTTPServer?
15:53coventry`tufflax: Are you trying to set custom names for your threads? Why not do it at creation time? http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#Thread(java.lang.Runnable, java.lang.String)
15:55gfrederickstufflax: you can't set! the thread-local value if the var doesn't have one
15:56gfrederickstufflax: can you wrap each thread's entry point with (binding [thread-name "..."] (do-everything-for-this-thread))?
15:57tufflaxgfredericks: about the var not having a value: i thought i gave it a value when i used def
15:57tufflaxno? :P
16:04tomjackRaynes: what should I do about https://github.com/Raynes/laser/issues/30 ?
16:08gdevtufflax, so when you do (.. Thread currentThread getName) it doesn't give you the correct name?
16:09tufflaxgdev: I have not tried, but I don't think so, because I used future to start it, and future does not take a name
16:09gfrederickstufflax: you gave it a thread local value
16:10gfredericksI mean a root value, sorry
16:10tufflaxoh, so it needs a thread-local first? So I need to use binding?
16:12tufflaxcoventry`: Thanks. I'll think about it
16:12Raynestomjack: I can't reproduce this problem.
16:15tomjackthanks
16:15tomjackthat led me directly to the problem
16:15tufflaxgfredericks: ah yes, you said that already. But I mean is binding the only way to set a thread-local binding?
16:15tomjackclj-http 0.7.6 transitively requires a different jsoup
16:16callentufflax: you can set a thread-local var in a variety of ways, binding is just a scoping mechanism.
16:16tomjackthrough crouton
16:16tufflaxcallen: ok... I'll try to read up on this a little bit more, let's see
16:17callentufflax: have you read clojurebook.com ?
16:17callenRaynes: this would be easier if I could just directly link a portion of an online book.
16:18tufflaxcallen: no. I read programming clojure and the joy of clojure a while back
16:18gdev (defn thread-inc [x] (let [t (.. Thread currentThread getName)] [(inc x) t])
16:18gdevcall pmap with that
16:23callenpedagogy-in-motion
16:23coventry`Why do you want to log the thread, if you're running in a future? Do you mean the thread which delegated the future?
16:24callencoventry`: I think the point is to demonstrate the behavior.
16:25coventry`callen: I'm confused by "I want to print the thread name in the log, since
16:25coventry` some functions are shared among several threads." vs "I used future
16:25coventry` to start it, and future does not take a name"
16:26callencoventry`: I think the newer people get hung up on unnecessary "place-ness"
16:29gdevplace oriented programmer is still rampant in the newbie community, sorry
16:29dakronetomjack: you should be able to exclude it from clj-http (if you haven't already solved your problem)
16:29tomjackyeah, thanks, I noticed that's in the clj-http readme for other reasons
16:29tomjackI actually think I don't need laser anyway, two tiny clojure.data.zip.xml exprs have got me almost entirely what I need :)
16:30dakronecool
16:45tufflaxcoventry` gdev oh didn't realize you were speaking to me :p
16:46tufflaxcoventry`: "Why do you want to log the thread, if you're running in a future?" Why not? The future is one of the threads I want to log :P
16:46coventry`How will knowing the thread the future is running in elucidate the operation of your program?
16:50tufflaxcoventry`: Hm, maybe I'm confused, but: I have a few threads, started with future. And I want to print the output of a function called process-network-msgs, for example. But that function is shared. So I want to print like "output of process-network-msgs (thread: server): some output"
16:50tufflaxas opposed to (thread: client)
16:50coventry`So (thread: server) is the thread from which the future is delegated, not the thread the future is run in, right?
16:51tufflaxIt's the thread that runs the future, i.e. the whole server runs in the future
16:52coventry`That sounds like an abuse of futures. Who do you return the result of the server's execution to?
16:53tufflaxcoventry`: No one, I just use futures as an easy way to start new threads.
16:54coventry`Don't do that, then. :-)
16:54coventry`"Easy." :-) http://www.infoq.com/presentations/Simple-Made-Easy
16:55tufflaxYes, easy
16:55tufflaxI've seen that :p
16:55tufflaxcoventry`: What are the downsides of my use of futures?
16:57coventry`You're running into this limitation because you're using futures for something they're not designed for. No one needs to know the name of the thread running a future the way it's supposed to be used.
16:58tufflaxOk, are there any other problems, besides the names thing?
16:58callentufflax: stop getting involved in place-ness.
16:58callenjust perform computation, do not worry where it happens.
16:58callenif it's truly impossible to approach it thusly, futures aren't your bag.
16:59tufflaxcallen: Maybe I'm abusing futures, but about place-ness: I want to know where things happen for debugging, is that wrong? :p
17:00coventry`Placeness is a total red herring here.
17:16tufflaxAnyway, thanks callen coventry` gdev. I appreciate all the advice I get.
17:18coventry`No problem. Just change your non-returning futures to named threads and use getName and you'll be set.
17:18tufflax:)
17:19gdevtufflax, no problem, good luck
17:57dnolenholy crap source maps in CLJS actually work!
18:03supersymoh thats pretty cool actually
18:04TimMc!
18:49akurilin2I'm curious, does anybody out there with a Ring app do a params validation pass before passing the request further to the controller's handler? Seems like it might reduce the cyclomatic complexity of the handler which might be pretty beefy already.
18:53brehautakurilin2: I think one of the service API tools might do that? (webmachine based ones)
18:54akurilin2brehaut, interesting, not familiar with that one at all
18:54brehautakurilin2: i'll try ot find it. one moment
18:56akurilin2This is probably part of my odyssey of rolling my own until I discover someone else has solved it much more elegantly :)
18:57brehautakurilin2: http://clojure-liberator.github.io/liberator/
18:58akurilin2brehaut, awesome, thannks for digging it out!
18:58akurilin2know of anybody on here who might have used it?
18:58brehauttheres also https://github.com/cmiles74/bishop but i think liberator has grabbed the most mindeshare
18:58brehautno idea sorry
18:58brehautakurilin2: keep in mind i think its for service endpoints rather than 'pages'
18:59akurilin2brehaut, not sure I'm following that last statement.
19:00brehautakurilin2: it serves up JSON, XML, EDN etc structured data for restful services for consumption by programs, rather than serving up HTML etc for consumption by browsers/humans
19:00brehaut(i think)
19:01akurilin2brehaut, is the implication that it would be non-trivial to jam some HTML templating in there?
19:01brehautpass
19:02akurilin2Ok!
19:03akurilin2Thanks for pointing me in that direction though.
19:12supersymakurilin2: you know pedestal.io? not sure what you were looking for exactly, but that is more for pages (also services though)
19:12dnolenhow to enable source maps in CLJS 1889 http://swannodette.github.io/2013/09/15/source-maps/
19:12akurilin2supersym, I think I was looking more for good design patterns for that specific situation rather than a framework.
19:13brehautakurilin2: re:patterns, i think you are on the right track re:middleware
19:13brehautakurilin2: theres nothing at all wrong with using a middleware around a single handler in ring
19:13supersymah ok... hehe, I have that a lot as well, not being sure what I'm looking for :)
19:14supersymdnolen: thanks!
19:27sontekI saw this earlier today for sourcemaps as well: http://beandipper.github.io/
19:28danielszmulewiczI have a lazy sequence containing maps and strings. I want only the maps. What would be the most idiomatic way to filter the collection?
19:29dobry-dendanielszmulewicz: (filter map? coll)
19:29danielszmulewiczdobry-den: Nice. Thanks!
19:30dobry-dendanielszmulewicz: http://clojure.org/cheatsheet
19:31danielszmulewiczdobry-den: I always forget about the cheat sheet. (I should install the emacs add-on) Thanks!
19:32brehautalways useful ##(apropos #"\?$")
19:32lazybotjava.lang.RuntimeException: Unable to resolve symbol: apropos in this context
19:32brehaut&(use '[clojure.repl :only [apropos]])
19:32lazybot⇒ nil
19:32brehaut&(apropos #"\?$")
19:33lazybot⇒ (superset? subset? i? absolute-path? indexing-reader? enabled? single? include? prefix-of? zipper? attr? leftmost? auto? rightmost? number-literal? opt? empty-coll? leftmost? auto? rightmost? is-command? ignore-message? seqable? connection? db-ref? collection-exists?... https://www.refheap.com/18703
19:33brehautie, list all the predicates available
19:33danielszmulewiczbrehaut: cool!
19:33brehautapropos also takes strings and symbols
19:34brehaut&(apropos 'map)
19:34lazybot⇒ (map-invert encode-map generate-map map-nth multi-map map-vals map-vals-with-keys map-keys map-to ordering-map map-keys-and-vals into-map mapcat-chain build-request-map map-entry mapcat-chain cmd-map map-reduce write-concern-map query-option-map sorted-map ns-unmap z... https://www.refheap.com/18704
19:35danielszmulewiczbrehaut: very nice.
19:36dobry-denyeah, getting some way to quickly sort functions really helps in clojure. like typing in 'pred' and learning cool fn like 'every-pred'.
19:36dobry-deni use Dash on OSX for quick lookups
19:36arrdembrehaut: mother of god what are you doing to the bot
19:37brehautarrdem: get it to find functions with names similar to various expressions
19:38danielszmulewiczbrehaut: where is map-vals defined?
19:38brehautdanielszmulewicz: at a guess, clojure.set ?
19:38danielszmulewiczbrehaut: oh
19:39brehautoh
19:39brehautno its in useful
19:39brehaut&(use '[clojure.repl :only [find-doc]]
19:39lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
19:39brehaut&(use '[clojure.repl :only [find-doc]])
19:39lazybot⇒ nil
19:39brehaut&(find-doc "map-vals")
19:39lazybot⇒ ------------------------- useful.map/map-vals ([m f & args]) Create a new map from m by calling function f on each value to get a new value. ------------------------- useful.map/map-vals-with-keys ([m f & args]) Create a new map from m by calling function f, with... https://www.refheap.com/18706
19:39brehautarrdem: sorry!
19:40brehautit would be nice is apropos spat out qualified names
19:40arrdemhaha
19:41arrdemit's cool I just keep forgetting about apropos
19:41brehautapropos: its almost as cool as juxt
19:42danielszmulewiczthis is helpful too: https://github.com/krisajenkins/clojure-cheatsheet
19:42brehautarrdem: its really easy. it juxtaposes (puts side by side) the results of some functions on the same input
19:42brehautarrdem: the only trick is that it creates a new function.
19:43brehautarrdem: (juxt inc dec) == (fn [x] [(inc x) (dec x)])
19:44brehaut,((juxt inc dec) 1)
19:44clojurebot[2 0]
19:44brehaut,((fn [x] [(inc x) (dec x)]) 1) ; arrdem
19:44clojurebot[2 0]
19:45Aciohow would you do assoc-in for transients maps? a direct translation doesn't work since you can't get a key out...
19:46arrdem,(symbol? 'foo)
19:46clojurebottrue
19:47arrdem,#word
19:47clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
19:50gdev,#+
19:50clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
19:50gdev,#'+
19:50clojurebot#'clojure.core/+
19:53gdevAcio, have you found your answer yet?
19:53Aciogdev: nope! googling off and on
19:55gdevAcio, I think you would have to call persistent!
19:55gdevfor a good example look at the source of frequencies
19:56Acioyeah that seems to be the only answer I have so far, which I might as well use the non transient maps since the majority of that work is assoc-in
19:56gdevAcio, sorry for tossing in a red herring, but why are you using a transient? performance?
19:57Aciomostly learning. i think the persistent version is fast enough, but i was wondering how i would retrofit the block of code to be completely transient
19:58Aciobasically i'm taking timeseries and merge them into a map by date... something liek group-by
19:58Acioseveral timeseries*
19:58SegFaultAXAcio: Neat, why not just use group-by though?
19:59Aciothe maps are created on the fly instead of having them pregenerated
20:00Acioits funny (and maybe its me as i'm still newbie) that i can spend 30 minutes and then end up with 8 lines of clojure
20:00Aciobut that still beats anything i could have done in java typing the entire time
20:00gdevAcio, can you post a link to the code?
20:00Acio30 mintues thinking*
20:01Aciocant sorry, employer rules
20:05Rayneslol
20:06RaynesIf it is impossible to come up with an example demonstrating your problem then you're probably not going to have a whole lot of luck getting help.
20:06Raynes:(
20:06SegFaultAXIt's too bad Clojure doesn't have sum built in.
20:06RaynesSure it does! :D
20:07Raynes&(reduce + (range 100))
20:07lazybot⇒ 4950
20:07SegFaultAX,(apply + (range 100))
20:07RaynesThat's pretty darn built in :p
20:07clojurebot4950
20:07SegFaultAXBut that's not built in. :)
20:07RaynesHigher order functions, man.
20:08SegFaultAXRaynes: That's why I want it, to make an even cooler looking fib.
20:08hyPiRionsum is very specific. It's almost like having a standard deviation function
20:08gdevRaynes, I'm the kind of person that buys the pre-themed legos, not the generic bag of blox ;D lol jk
20:08SegFaultAX(iterate (juxt second sum) [0 1])
20:08Raynes<3
20:08SegFaultAXhyPiRion: Nah, it isn't.
20:09SegFaultAXMany languages provide sum. It's common enough I think.
20:10hyPiRionMany?
20:10BronsaSegFaultAX: clojure provides far more important built-ins than sum :)
20:11SegFaultAXI'm not bent out of shape about it. Just sayin...
20:11hyPiRionThe only one I really know of is Python
20:12gdevnot even java's math library has sum in it
20:12SegFaultAXhyPiRion: Haskell.
20:12brehauthyPiRion: with the inclusion of sum, python doesnt need reduce!
20:12rhg(def sum (partial apply +))
20:12SegFaultAXbrehaut: Funny thing about Python's functional built ins...
20:12SegFaultAXThey are sort of an accident in history.
20:12brehautSegFaultAX: pythons functional stuff just makes me angry
20:13SegFaultAXbrehaut: Heh, tell me about it! :)
20:13brehautSegFaultAX: im just glad i can jam partial into the global jinja template context and partially apply 'macros'
20:13SegFaultAXbrehaut: Yea, functools is handy.
20:14SegFaultAXAlso, why don't they just call them partials like every other template language?
20:14SegFaultAXDamn you mitsuhiko!
20:15hyPiRionbrehaut: With the inclusion of the for loop, Golang doesn't need functional programming!
20:16brehauthyPiRion: i was snarkilly paraphrasing guido :(
20:16hyPiRionWhat's the need of sum, when you can just do `sum := 0; for _, v := range coll { sum += v }` ?
20:16hyPiRionyeah, I know
20:18SegFaultAXGo has some really interesting features, but I'm not sure I could use it for a serious project.
20:19SegFaultAXNot that everything /must/ be functional for me, but I don't even have the option in Go. The structure of the language doesn't really seem to allow it.
20:21tomjackhttps://www.refheap.com/66892428082d890fc32deff89
20:21tomjackright when I was about to hit enter, I understood why..
20:22SegFaultAXAnd tomjack was enlightened.
20:23benkayi'm trying to work with my first java interop stuff, and i'm running up against a wall. in project.clj, i say ":java-source-paths [["src/main/java"]]...)", and in that directory i have org/quantlib/awholebunchofdifferentfiles.java
20:23gdevnamespaces: enemy of the noob
20:23gdevnot say you're noob, tomjack =o
20:24benkaywhen i run lein repl (or jack in from emacs), it blows up with Exception in thread "Thread-2" java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.lang.PersistentVector
20:24benkayobviously i am derp on this.
20:24benkayideas?
20:25gdevbenkay, error message seems pretty clear
20:25benkayoh whoa. a single vector instead of a vector of vectors works just dandy.
20:25benkaygdev: I suppose i was referring to too many internets saying that l2 takes a vector of vectors for java source paths.
20:27gdevbenkay, wouldn't know without looking at the codez
20:33gdevand even then, my advice is still suspect at best =D
20:51muhoodear lazyirc, is there some way to start a repl :connect with a given namespace and some injections, from the command line?
20:51muhooi.e. lein repl :connect 7777 :injections (some-forms....) ?
20:52muhooor :init, maybe, hmm.
21:18dobry-denIf you run `lein repl :headless` on your remote server and then Tramp in to a your remote clojure project, how do you connect to the headless repl? I would have assumed `M-x nrepl` with localhost and port
21:28coventry`dobry-den: If you're tramping in, you've got the wrong localhost. You would need to do "lein repl :headless :host FQDN :port port, and connect your repl to the FQDN, but I've never tried that, and it might not be a very good idea froma security standpoint.
21:35scottjdobry-den: I think you want to use ssh tunnelling, like "ssh user@remotemachine.com -N -L 41726:localhost:41726", and then localhost and 41726, where 41726 is whatever port lein repl :headless says
21:35scottjwith that ssh command executed on your dev machine
21:40dobry-denscottj: huge. thanks
21:42Pupnik_are there any instructions anywhere for setting up clojurebot? the readme is very brief
21:55benkayworking on my first interop stuff with QuantLib (i know, i know, don't bite off too much, kid...), and I've run into the UnsatisfiedLinkError as mentioned here: http://www.bnikolic.co.uk/blog/ql-java-clojure-loader.html
21:56benkaythe suggested solution is to add a simple class to the jar, but as I'm using the SWIG compiled java wrapper, I just wrote that wrapper as a file in the same directory (I have zero experience with Java development - trying to hack my way to competence over here), but then I run into another UnsatisfiedLinkError, no QuantLibJNI in java.library.path.
21:57benkayquestion is: is there a subtlety to adding in new java classes to a set of files vs. a jar?
21:57benkay(I spent 4 hours this morning trying to compile the SWIG wrapper into a jar, but as mentioned, Java ain't my hometown)
22:00Apage43benkay: http://stackoverflow.com/questions/7511789/clojure-lein-how-do-i-include-a-java-file-in-my-project see the answer here
22:01Apage43basically if you want to mix java & clojure, just add a :java-source-paths to your project.clj and lein will take care of getting stuff compiled for you (and included in any jars spit out by lein jar or lein uberjar)
22:01Apage43https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L238
22:01benkayheh Apage43 if you look at the bottom of that page you'll see my contribution to the :java-source-paths question
22:01Apage43oh
22:02Apage43herp derp :D
22:02benkayyeah this is a silly thing
22:02Apage43well, that + your original link should kind of do the trick
22:02benkaywell, i'm a silly thing playing with tools beyond my comprehension
22:02benkayso, loading the files is not the problem
22:02Apage43build a java class with a static initializer and import it before you try to use the bits that depend on the native library
22:03benkaylike this: http://pastebin.com/EPKC0nPP ?
22:04Apage43yeah.. or
22:04Apage43you might be able to use https://github.com/flatland/classlojure
22:06Apage43and do (with-classloader (.getClassLoader SomeClassFromQuantLib) (System/loadLibrary "QuantLibJNI"))
22:06benkayso the static loader works just fine, I think I need to start digging around to find QuantLibJNI
22:07Apage43ah
22:07Apage43that'll be looking for QuantLibJNI.so, or .dylib, or .dll, depending in some directory on your java.library.path
22:07benkay'cause what I see when i load my core.clj file in my repl is "UnsatisfiedLinkError no QuantLibJNI in java.library.path..."
22:08benkaycool!
22:08Apage43that's the JVM opt -Djava.library.path=/path/to/place
22:08benkaynow that java.library.path is *not* going to be the same as the :java-source-paths in project.clj correct?
22:08Apage43correct
22:09benkay(thanks for bearing with my *complete* unfamiliarity with the Java ecosystem)
22:09Apage43you can make leiningen pass the the -Djava.library.path=/whatever/ flag though: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L225
22:10benkayhuh.
22:10Apage43benkay: *however* a lot of java libs have their native parts in a jar
22:10Apage43which leiningen should be able to automatically pick up if you've got it pulling down their right dependency
22:10Apage43it'll usually be something like projectname-natives
22:11Apage43possibly pronjectname-natives-{linux,macosx,windows}
22:11benkayi had to derp the *.java files into a directory and then point Leiningen at them in my project.clj
22:12benkayApage43: and leiningen will be looking in Clojars and Maven for these native jars?
22:12Apage43if it's something you installed with your OS package manager and aren't pulling down with the java dependency mechanism though, that wouldn't be the case
22:12Apage43benkay: yeah
22:13benkayApage43: actually, I just downloaded the whole thing from quantlib.org - it had SWIG-generated Java files
22:13Apage43http://search.maven.org/#search%7Cga%7C1%7Cjogl%20natives
22:13Apage43example for JOGL
22:14Apage43ah
22:14Apage43it's not playing with the maven-y ecosystem then
22:14benkayi doubt it.
22:14Apage43so you'll have to figure out where QuantLibJNI lives and put it on your java.library.path :/
22:14benkayyup
22:14Apage43or maybe QuantLibJNI is something you need to build? Dunno.
22:14benkaymoar research.
22:15Apage43good luck :)
22:15benkaythanks :)
22:15benkayjust as I gain a baseline of competence with Clojure i bite off a project that entails learning the Java stack.
22:17bjaI figured out how to win an obfuscated javascript contest: write cljs passing partial functions around core.async channels
22:23benkayApage43: it turns out that QuantLibJNI.java exists in the same directory as the BKLoader.java I wrote. how do I point System.loadLibrary("...") at that file?
22:23Apage43Actually that doesn't correspond to the thing you want to load
22:23benkayoh :(
22:23Apage43QuantLibJNI is the Java side, and that'll get built for you
22:24Apage43that builds a .class though
22:24Apage43loadLibrary is looking for a .so (linux, other *nix), .dylib (OSX), or .dll (Windows)
22:24benkayah
22:24Apage43which will be build from some C or C++ code
22:24benkaygot it!
22:25benkayso when I compiled QuantLib earlier today that was actually a necessary step
22:25Apage43yeah
22:25benkaybecause these *.java files are the java bindings to interact with that binary
22:25Apage43and if the SWIG bindings also generated some C/C++ code in addition to the .java files
22:25benkaynah they came down in toto
22:25benkayno compiling
22:25Apage43ah
22:25benkayawesome
22:26benkayi learned a lot today! and you put the last piece in place! yay!
22:26Apage43well there should be *some* C or C++ lying around you need to build to get QuantLibJNI.something
22:26benkayyeah, I built that.
22:26benkayand then deleted it out of frustration because derp
23:14seancorf`ld
23:37benkayping Apage43
23:38Apage43Her
23:38Apage43Hey
23:38benkaydah nevermind
23:38benkaystill hacking
23:39Apage43K
23:39callenhow's everyone's Sunday going?
23:39benkaywell actually if I have your attention...
23:40benkayApage43: we were talking about passing in the java.library.path option via Leiningen
23:41benkayis that going to be looking at the OS path? or should I be passing that the path to the .dylib I want loaded?
23:46grandynew to clojure, trying to figure out if there is a simple way to convert the nested vector output of instaparse into a map or something along those lines
23:47benkay(musing aloud in hopes that someone corrects me), according to (http://stackoverflow.com/questions/10558795/using-lwjgl-in-leiningen-clojure), apparently I could reference `native/linux` (or in my case, native/osx). so i'm going to copy the dylibs in my homebrew folder to native/osx and point Leiningen at them.
23:47callengrandy: you want a nested map instead of a nested vector?
23:47callendoes that really win you much?
23:48grandycallen, hmm, maybe not, i guess i'd like to avoid having to use integer indexes
23:49grandycallen: was thinking i could adapt the instaparse parser to return something more flat
23:49grandycallen: all this may be stupid "new to clojure" reasoning
23:49callengrandy: if you want something flat, then you need to learn to use zippers more than likely.
23:50grandycallen: ahh ok, i guess maybe i can destructure the nested vector
23:51callenbut parsers are naturally a nested "thing"
23:51coventry`He means these. They're worth a look. http://clojure.org/other_libraries#Other%20included%20Libraries-Zippers%20-%20Functional%20Tree%20Editing%20(clojure.zip)
23:51callenwhether your data structured is zipped or not, the data *will* be nested fundamentally.
23:52grandyahh cool thanks to both of you, yes true