#clojure logs

2013-06-29

00:01derek_cDoes Leiningen support all maven repos?
00:06gt`Hi all, I am on ubuntu want to get clojure read MS SQL data using unixodbc. UnixODBC is setup and working already with MS SQL i just need to know how i could get clojure to read data using any useful library . Appreciate any help
00:07technomancyderek_c: it should, yeah
00:17dnolen_bbloom: what do you mean?
00:17dnolen_bbloom: they certainly aren't a problem the way large methods are on the JVM
00:18bbloomdnolen_: i was just wondering what would happen if i compiled a gigantic switch statement in a single big function
00:18bbloomdnolen_: something like what parser generators output
00:19dnolen_bbloom: never benchmarks such a thing, but I would imagine not a problem
00:19dnolen_benchmarked
00:19bbloomdnolen_: even on firefox? i thought firefox was a method jit instead of a tracing jit
00:19dnolen_bbloom: dunno, I kinda ignore FF as it's performance is often dismal
00:19bbloomheh
00:23dnolen_bbloom: my main complaint with FF is GC, they are working on it, it seems
00:24dnolen_recent JavaScriptCore is amazing, so I expect FF will get there too
00:24dnolen_bbloom: still, as far as big fns, I just don't see why that would be a problem given modules in JS are giant closures
00:25bbloomah, good point
00:25bbloomalthough i guess modules are only ever really loaded once :-P
00:40bbloomdnolen_: in your dbounce example, could you just initialize with (js/Date. 0) to avoid the nil check ?
02:05ozzloyhow do you unit test functions that return functions? i did (expect #() #()) which didn't work
02:05ozzloy(using expectations)
02:06ozzloya quick answer i can think of is to test that applying the returned function to some values gives the desired output
02:06ozzloybut that's not the same as testing whether the returned function is what you expected
02:07bbloomozzloy: functions use reference equality
02:07bbloom,(= #() #())
02:07clojurebotfalse
02:07bbloom,(let [f #()] (= f f))
02:07clojurebottrue
02:07bbloomyou can't test the shape of a function at all
02:28SegFaultAXDoes something other than Friend exist yet?
02:30amalloySegFaultAX: infinitely many such things
02:30SegFaultAXamalloy: Something that is already a thing, and that doesn't suck?
02:31amalloySegFaultAX: i was introducing levity by pointing out that you didn't limit your scope: so far cupcakes fit the bill under all three of your requirements
02:31SegFaultAXamalloy: Cupcakes already do authentication?
02:32SegFaultAXDoes something that does what friend is supposed to do, but in a considerably less shitty way already exist?
02:37tomjackwhat is friend supposed to do?
02:37SegFaultAXtomjack: Warden-like authentication.
02:38tomjack"already" threw me off
02:42RaynesSegFaultAX: In case you didn't totally get amalloy's joke, he was taking advantage of the fact that the scope you were limiting to includes every single quark in the universe that doesn't make up Friend.
02:43SegFaultAXRaynes: Yea, but I'm genuinely curious about this pedantry aside.
02:46pepijndevosAre go block generally preferred over threads in core.async?
02:46pepijndevos(on JVM)
02:47tomjackthey're complementary
02:48tomjacka decent rule of thumb (I think) is to use thread when the body may block
02:49tomjacka go body should do its stuff quickly, not block on IO or whatever, maybe parking on a channel op
02:50tomjackif not, you'll potentially stop up everything since you only have a fixed pool for go blocks
02:50tomjacknot sure what fork/join would mean in relation to this
02:50SegFaultAXtomjack: I thought go blocks will automatically park?
02:51tomjackI wouldn't call it automatic
02:51tomjackif you use <!! in a go block, that's bad
02:51tomjackif you use <! you're saying "park if necessary"
02:51tomjack(and <! cannot mean anything else)
02:51pepijndevosIs core.async in any repo? lein doesn;t find it
02:51SegFaultAX"go is a macro that takes its body and examines it for any channel operations. It will turn the body into a state machine. Upon reaching any blocking operation, the state machine will be 'parked' and the actual thread of control will be released. "
02:52tomjackno, it hasn't been released
02:52tomjackSegFaultAX: that's maybe misleading in this context
02:52tomjackit's not like gevent's insane monkeypatching or whatever
02:52SegFaultAXtomjack: Just repeating what the author wrote.
02:52SegFaultAXrhickey in this case.
02:52tomjack"blocking operation" there means <! or >!
02:52tomjack(or alt!/alts!)
02:53tomjackif you deref a future or do syncronous IO or whatever it can't automatically make that async
02:55SegFaultAXtomjack: I'm still wrapping my mind around core.async. Haven't looked at it deeply enough yet.
02:55ozzloybbloom, oh, bummer
02:56bbloomozzloy: consider the complexity of that for a moment…. are (fn [x] x) and (fn [y] y) equal?
02:56ozzloybbloom, sorry, i left pretty quickly because i thought the channel was sleeping
02:56amalloybbloom: well, that one's not a great example because they'll generate identical bytecode
02:56ozzloybbloom, i'm aware that it would be complex
02:56ozzloyin general
02:56bbloomamalloy: shhh you :-P
02:56amalloybut, eg, #(+ % %) #(* % 2)
02:57amalloyozzloy: it's provably impossible, in general
02:58r0bgleesonare many of you working with clojure in a day job?
02:58ozzloywell... provably impossible to determine if two functions will give the same output for all input
02:59ozzloybut if they have the same form but different identifiers or something
02:59ozzloyanyways, the answer is no, so i'll move on to my next question: how do people in here unit test functions that return functions
03:00tomjackpretty much the same way you test a function
03:00ozzloykk
03:00tomjackit's just the same problem again
03:00ozzloywell kinda
03:01amalloyall you can do is call the function with some inputs and verify you get out what you wanted
03:01SegFaultAXHaskell explicitly guards against this problem.
03:01SegFaultAXWell, optionally.
03:01amalloySegFaultAX: you mean by not having an Eq instance for functions?
03:01SegFaultAXamalloy: Yes.
03:02amalloyexcept you can add one, if you're a maniac
03:02SegFaultAXThat's the optionally part.
03:02SegFaultAXThere's also some caveats to overloading functions due to the no monomorphism restrictions.
03:02SegFaultAXAlso optionally.
03:03SegFaultAXBut that's more of a failing of the type system.
03:03amalloyi recently learned what that means, although i don't see what it has to do with function equality
03:04SegFaultAXamalloy: Oh it doesn't. It merely places restrictions on expressions without explicity type information.
03:04SegFaultAXExplicit, even.
03:05ozzloyexplicity is a fun word
03:05ozzloysounds like a value of how explicit something is
03:06ozzloyg'night. thanks for the help
03:06SegFaultAXSo are most people just rolling their own authentication then?
03:07callenSegFaultAX: that or Friend, yeah.
03:08SegFaultAXBummer.
03:08Raynescallen: hi
03:08callenRaynes: hey
03:08callenSegFaultAX: part of the problem is that while there's a common surface area in Ring, there isn't an agreed upon framework so it's hard to write something everybody can use and that will 'just work'
03:09Raynescallen: I met muhoo tonight. We had a blast. RAWK n ROLL'd like crazy.
03:09callenRing middleware can realistically only go so far unless you stash a lot of paranoid state somewhere.
03:09RaynesAwesome fellow.
03:09callenRaynes: yeah I had a good time bumming around SF with him. Very nice guy.
03:09amalloyinstance Eq (a->b) where (==) x y = True -- muahahaha, what have you done, SegFaultAX????
03:09SegFaultAXamalloy: Haha, wut. :)
03:10callenSegFaultAX: so until the community decides it's okay with having a Rails/Django'ish solution somewhere, people will keep rolling their own over and over.
03:10SegFaultAXWarden does a decent job of providing a solution for this built purely on rack middleware.
03:10amalloySegFaultAX: well, there are only two plausible definitions of such an operator, and False seemed like it wouldn't have caused as much chaos
03:11callenSegFaultAX: then use Warden
03:11SegFaultAXAnd lots of the most popular authentication frameworks are built on warden.
03:11callenI prefer to write my own middleware because I like using the request context.
03:12SegFaultAXFriend seems to be heavily influenced by warden and it says as much in the documentation. But the implementation is... rough.
03:12callensounds like you know what you want.
03:13pepijndevosI'm having trouble mapping CSP onto core.async.
03:14SegFaultAXWhat interests (and perhaps confuses) me is that this doesn't seem to be a more well explored area than I would have anticipated.
03:15SegFaultAXLots of (most?) apps require some form of authentication or another.
03:15callenSegFaultAX: User-facing applications that are more likely to have auth aren't the most common use of Clojure at the moment.
03:15callenSegFaultAX: lots of people will have a Clojure API hiding behind a Rails app.
03:15callenI'm not happy about this, but again, that's why I have my own bag of tricks for this nonsense.
03:16pepijndevosIn core.async there are clearly senders and receivers, while in CSP there is just "stuff happening"
03:17tomjackare you reading hoare?
03:17pepijndevosyea
03:17tomjackit's like hundreds of pages in iirc before channel-like things are introduced
03:17pepijndevosTrying to imagine a vending machine with multiple customers
03:18pepijndevosah
03:18pepijndevosok, more reading....
03:18tomjackI think in CSP you just say that an event can be a pair of a channel and message
03:18tomjackthe way it's formulated you don't have to distinguish between send/receive
03:19pepijndevos?
03:19pepijndevosokay...
03:20tomjackbecause the alphabet is defined such that a sent message could only be sent
03:20tomjacke.g. if the vending machine has a channel, you could say products will always be received and coins always sent
03:21pepijndevosyea, that makes sense
03:21tomjackand in the formalism 'sent' and 'received' are just meaningless
03:21pepijndevoslike so? https://www.refheap.com/16190
03:21tomjackjust us dirty operational dynamic folks need to care about that nasty stuff :)
03:21pepijndevoslol
03:22pepijndevosSo that works with one customer, but with 2 it gets strange
03:23tomjackwhy strange?
03:23pepijndevoscoin -> choc ||| coin -> choc ||| coin -> choc, I think in CSP that would do one coin -> choc, but with channels that would do 2, in undetermined order.
03:24tomjacksorry what's |||
03:24pepijndevosthat lockstep concurrent thig I think.
03:25SegFaultAXWhoa netsplit?
03:26tomjackVEND = (slot.coin) -> (tray.choc) -> VEND ?
03:28tomjackI don't understand the mapping well either
03:28pepijndevosyes
03:29tomjackVEND and BUY look exactly the same, though, right?
03:29SegFaultAXIf you need some comedy in your life, open up the local computer gigs page on craigslist and see the ridiculous things people want for completely insane prices (often free)
03:29tomjackBUY = (slot.coin) -> (tray.choc) -> BUY ?
03:29SegFaultAX"I want to build a facebook/amazon clone"
03:30pepijndevostomjack, exactly
03:30SegFaultAXPrice: $250 - $500 depending on how long it will take
03:30tomjackbecause VEND and BUY are tied in a circle, so slot.coin and tray.choc are in the alphabets of both
03:30tomjackthen VEND || BUY || BUY
03:30tomjackanyway I think your code should work fine as long as state is an unbuffered channel
03:30pepijndevosyes, so if you run the in parallel, they execute coin and choc synchronously.
03:31tomjackas you'd get from (chan)
03:31tomjackthe vending machine won't accept a second coin until the first choc has been received
03:31pepijndevosright, but now add another customer
03:32tomjackand a customer can't get a choc until it's put a coin in
03:32tomjackwhat's the problem?
03:32pepijndevoswell, that should work with the code, but I think that's different from what CSP does. But maybe I'mwrong
03:33tomjackoh, I must have misunderstood you
03:34pepijndevosSo in Clojure coin -> choc ||| coin -> choc ||| coin -> choc would give each customer a choc.
03:35pepijndevosBut in CSP it's more like 2 people and a mchine together insert a coin and get one choc back
03:35tomjackhmm
03:35tomjackVEND and BUY above are wrong I think
03:37tomjackV = (vin . coin) -> (bout . choc) -> V
03:38tomjackB = (vout . coin) -> (bin . choc) -> B
03:38tomjack?
03:39tomjackthen let vc = (vin,vout), you could instead write
03:39tomjackV = (<! vc coin) -> (>! bc choc) -> V
03:39tomjackB = (>! vc coin) -> (<! bc choc) -> B
03:39tomjack?
03:39pepijndevosthat's a confusing syntaxt crosover :P le me parse that
03:40tomjack(= (<! (vin,vout) coin) (vin . coin))
03:40tomjack(= (>! (vin,vout) coin) (vout . coin))
03:41tomjackbut I think you may be right about the problem with multiple consumers
03:41pepijndevosyea, it's betetr explained with a different example. I want to program a choir
03:42tomjackI think a channel endpoint in CSP should only be read/written by one process
03:43tomjackif you have multiple consumers you have multiple endpoints
03:43pepijndevosthere is a conductor C = (>! swing) -> (<! note) -> C
03:43pepijndevosand there are singers S = (<! swing) -> (>! note) -> S
03:43tomjack(I was going to mention I never did a thorough read of hoare so take everything I say with a grain of salt)
03:44pepijndevosI can;t think of a way to write a program that keeps a choir in sync
03:45tomjackC = (>! flute swing) -> (>! tuba swing) -> (<! flute note) -> (<! tuba note) -> C
03:45tomjackas for a program.. hmm :)
03:46tomjack(for completeness, F = (<! flute swing) -> (>! flute note) -> F)
03:53tomjackpepijndevos: this didn't work
03:53tomjackhttps://www.refheap.com/19c63f1624e70614e2de1309f
03:53tomjackbut maybe it will give you some ideas
03:54tomjackoh I see the problem
03:54tomjackproblems
03:55pepijndevosso you let the players ad themselves?
03:55tomjackhttps://www.refheap.com/22501c69cab3472136ef54f2a
03:56tomjackI think rich indicated once in here that something like this is the solution to this kind of problem
03:56tomjacknot sure about the best way to formulate it, the design space with channels/processes in core.async is frighteningly open to me
03:56tomjackdon't understand yet how to best organize things
03:56tomjackbut I think any solution will be basically isomorphic to this
03:57tomjackyou could just pass a coll of player channels to the conductor
03:57tomjackI think? if you know all the players ahead of time
03:58tomjackthen the weird subscription stuff goes away
03:58tomjackand passing a coll of player channels seems to map nicely onto the C above
03:58tomjack[flute tuba]
03:59tomjackin retrospect my refheap is quite silly
03:59tomjackI remembered an approach like that for some other thing I tried once
04:00blz37I am not asking much. I have em.raynes/conch in my :dependencies. I want to add one more to play around with. Please suggest one.
04:04tomjackpepijndevos: https://www.refheap.com/ac1b667140848032ff6b8f642 ?
04:05pepijndevosI ned to catch up, was reading hoar
04:05tomjackI almost feel like I would rather have ports be the primitive instead of channels
04:06tomjackI guess channels have to be the primitive, but I feel like I want ports
04:06tomjackI'm too stupid to use channels correctly :)
04:08pepijndevostomjack, that works, but no way you can keep 1000 players in sync that way, if you "sync" them sequentially.
04:09tomjackI bet you could
04:09pepijndevoshm…
04:09tomjacklight/sound waves are very fast compared to neural impluses and muscle movements :)
04:10pepijndevos...
04:10tomjackif you had some broadcast-like channel hiding the doseq from you, what else could it do but a doseq internally?
04:10tomjackif you have so many consumers that doseq'ing them is a problem, I think you're fucked anyway
04:11pepijndevoslol
04:11tomjackin addition core.async tends to be more useful if there is some inherent delay
04:11tomjackand often these delays are long enough that doseq'ing 10000 consumers or whatever probably won't matter
04:12pepijndevosI'm just going to read the book...
04:12tomjackgood luck, unfortunately understanding CSP is no longer part of my job description :(
04:12tomjackbut I don't think you will find implementation tips in hoare
04:17pepijndevostomjack, it was before?
04:18pepijndevosI want to understand CSP, and then understand core.async.
04:19tomjackplease give a talk or something when you're done :)
04:21pepijndevoslol, I'll at least write a blog post
04:22pepijndevosan event as an action without duration, whose occurrence may require simultaneous participation by more than one independently described process.
04:22pepijndevosThat's the part i don't see in core.async
04:23tomjackthat's in CSP?
04:23tomjackI remember looking for something like that and CSP and not being able to find it
04:23pepijndevosMaybe this part is orthogonal to channels, and some fancy concurrent state machine might be devised to handle it
04:23tomjackbut I didn't look very hard
04:24tomjackmy impression was that the C in CSP is always one-to-one
04:24tomjack(like in core.async)
04:24pepijndevosfull quote: In previous chapters we have introduced and illustrated a general concept of an event as an action without duration, whose occurrence may require simul- taneous participation by more than one independently described process.
04:24pepijndevosthat's in chapter 5 or so
04:25tomjackhmm
04:25tomjack'but..'?
04:26pepijndevosah P || Q means P in parallel with Q
04:28pepijndevosas I understand it, if aP = {foo bar} and aQ = (bar baz} then they will together do bar
04:29tomjack"We shall observe the convention that channels are used for communication in only one direction and between only two processes."
04:29tomjackI hadn't thought about the fact that without the convention you get broadcasting channels
04:30tomjackif that's a fact
04:31pepijndevosright, so channels are just what channels are in CSP
04:31pepijndevosbut core.async just doesn;t have the events described in the first chapter.
04:31pepijndevos"All the operations introduced in this chapter can be defined in terms of the more primitive concepts introduced in earlier chapters, and most of the laws are just special cases of previously familiar laws. "
04:32pepijndevosThat leads me to think channels are an abstraction over events?
04:33tomjackconsider the hypothetical V || B || B
04:34tomjackhow is it different from V || B
04:35tomjackI think events are the abstraction
04:35tomjackyou can implement core.async-style channels inside that abstraction
04:35tomjackbut you can't implement events in anything remotely resembling core.async, it just doesn't make sense
04:36tomjack(and you can't really implement core.async-style channels inside the abstraction. you can implement something which is a good model for them?)
04:38pepijndevos..
04:40pepijndevostomjack, are you saying CSP and core.async are entirely different things?
04:41tomjackin some sense, yes, absolutely
04:41tomjackprocesses in CSP are mathematical objects
04:41tomjackprocesses in core.async are presumably clojure functions
04:42tomjackthe whole 'events as actions whose occurrence may require..' makes sense in a mathematical model
04:42tomjackI don't think it makes sense in a clojure program, at least not in something remotely like core.async
04:45pepijndevosI think it makes a lot of sense in clojure programs, but it's just not implemented in core.async.
04:46pepijndevosI would like to see a dining philosophers impl in core.async.
04:47pepijndevosThey do that in CSP, and it looks almost trivial.
04:52tomjackI could see maybe a core.logic-alike which lets you define process equations
04:53tomjackbut really, I don't understand CSP much at all, I hope you enlighten me someday
04:54pepijndevosA communication is an event that is described by a pair c.v where c is the name of the channel on which the communication takes place and v is the value of the message which passes.
04:57pepijndevosbut ye , one to one only,, while events can involve many
04:58pepijndevosyea, i think some sort of state machine could implement this stuff
05:00tomjackis A == A || A ?
05:44tomjackdependencies in this pom.xml with no version specified
05:44tomjackmvn should throw an error :(
06:04samratis doing this: https://www.refheap.com/16195 a bad idea? I want to send an HTTP request every minute for a specific three hour interval a day only.
07:07Mohshihi
07:08Mohshiwhen i do (context "/:id" [id] some-routes) how can i access id in some-routes?
07:09Mohshicompojure ^
08:38jtoy_what is the point of var?
08:39jtoy_this is the definition: The symbol must resolve to a var, and the Var object itself (not its value) is returned. The reader macro #'x expands to (var x).
08:39jtoy_but im not sure why its used
08:48callenjtoy_: vars are foundational.
08:48Okasujtoy_: http://pramode.net/clojure/2010/05/13/story-of-clojure-vars-part-1/
08:49_atojtoy_: as for why you might want to get a reference to one, try (meta (var first))
08:50jtoy_thats useful info!
08:53EiXhello
08:55EiXwhat will happen if i'll make middleware and will set current-user atom to something in that middleware depending on request?
08:55EiXis it safe?
09:01jtoy_im still not sure why one would want to use var though, i see it being used here : https://github.com/korma/Korma/blob/master/src/korma/core.clj#L581
09:18EiXguys?
09:28xpeI'd like to make a custom exception class. Is http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#Exception_Handling a good way to go? I don't see `gen-and-load-class` in clojure.core
09:37dark_elementxpe looks like :gen-class would do the trick
09:47xpedark_element: that works, but it involves a manual compile step, which is part of the reason why people suggest using the alternatives
09:47dark_elementxpe what are the alternatives?
09:48xpedark_element: they are listed in that SO post. slingshot is probably the best "all in one" solution from what I can tell. ex-info can help too
09:50dark_elementxpe ohh ok i thought there are alternatives to defining the usual java exception without compile step. yes slingshot and ex-info are great alternatives.
09:50dark_elementxpe ex-info is more preferred i guess since it comes with clojure
09:51xpedark_element: I don't know of any alternatives to defining the usual java exception without a compile step. luckily I don't think a recompile is needed very often
09:52dark_elementxpe all right
09:52gfredericksI imagine there's no reason not to use core.async to do database queries in core
09:52dark_elementxpe go for ex-info if you can
09:52gfrederickss/core/java.jdbc/
09:52xpedark_element: thanks
09:53gfredericksgotta be careful about resource cleanup though :/
09:54gfredericksI'm also curious about channels as ring responses
09:54gfredericksor requests too?
09:59dark_elementgfredericks http-kit uses channels for the streaming response and websockets
10:01dark_elementgfredericks though the same channels you are talking about but the same concept. I wonder if they will be replaced by core.async channels in future
10:01dark_elementnot the same*
10:06gfredericksdark_element: what does this replace? jetty?
10:07gfredericksha yes that's what the website says
10:08dark_elementgfredericks didn't get you?
10:08gfrederickshuh?
10:08gfredericksI'm fine, just reading about http-kit
10:08gfredericksthanks for pointing it out
10:10dark_elementgfredericks I was saying replacing channel primitives written in http-kit with core.async will be a good idea
10:10dark_elementgfredericks that is a very good question indeed
10:10gfredericksHTTP 3.0 will let us put the status at the end :)
10:10gfrederickser...1.3?
10:10gfrederickswhatever
10:11dnolen_pepijndevos: not sure what you are asking
10:11dark_elementgfredericks interesting
10:11dark_elementgfredericks TIL, thanks
10:12gfredericksdark_element: it was a joke
10:12gfredericksvery little of what I say is constructive
10:12dark_elementgfredericks and i already googled for it and wonder what i did wrong
10:12pepijndevosdnolen_: I was reading the CSP book, and only in chapter 4 or so does it talk about channels, which seems to be what core.async does.
10:13pepijndevosBefore that it's just events, and I don't see those in core.async
10:13hyPiRiongfredericks: oh nono, I think our research on Swearjure is very constructive
10:13gfrederickshyPiRion: swearjure is certainly not most of what I say :P
10:14hyPiRiongfredericks: Hum, well, but logic programming!
10:14gfredericksditto
10:14gfrederickswhy does lazybot not have a random sample command that we can use to actually check this claim
10:14hyPiRionoh what, you're talking about all these cool things you do @ miniKandren
10:14hyPiRionminiKanren*
10:15gfredericksI'm not talking about those I'm just spouting nonsense
10:15hyPiRionoh okay, fine. Here I am trying to make you feel valuable, and you spoil everything
10:15hyPiRion:p
10:15dnolen_pepijndevos: it's not clear to me whether events are just part of the formalism
10:15dnolen_pepijndevos: the CSP book is really about formalism not a concrete implementation
10:16dnolen_about the formalism
10:16pepijndevosn previous chapters we have introduced and illustrated a general concept of an event as an action without duration, whose occurrence may require simultaneous participation by more than one independently described process
10:16gfrederickshyPiRion: being valuable is different from the majority of my statements being valuable :P
10:17dnolen_pepijndevos: core.async approach doesn't seem that different from how CSP has actually been implemented in the past
10:17pepijndevosdnolen_: the important part about events compared to messages is that more than 2 parties can be involved
10:17dnolen_pepijndevos: most of the improvements are just good taste
10:17dnolen_pepijndevos: sure you can model that with primitives
10:18dnolen_with the primitives
10:18hyPiRionargh, but there is usually a correlation sir.
10:18pepijndevosdnolen_: which primitives?
10:18dnolen_pepijndevos: the core.async primitives, writing a broadcast channel is easy
10:19pepijndevosI should look at the code...
10:20pepijndevosI'm not sure a broadcast channel is what I want though
10:21pepijndevosItn would be really intreresting to see the dining philosophers from the book translated to core.sync, I think.
10:21dnolen_pepijndevos: just try it, I'm sure you'll figure it out, it isn't hard to use
10:21pepijndevosok
10:21dnolen_I've started going through various JS UI patterns
10:22dnolen_it simplifies things in incredible ways so far
10:22dnolen_because you can break apart complected code into independent communicating processes
10:22pepijndevoshmhm
10:22dnolen_honestly prior to core.async, FP + UI programming was a serious joke in my opinion for me.
10:23pepijndevosI would mostly agree, although I never really tried anyway.
10:24dnolen_this is what a FRP game looks like https://github.com/raimohanska/worzone/blob/master/worzone.js
10:24dnolen_JUST SAY NO
10:25dnolen_pepijndevos: yeah having done UI programming for the last 8 years, core.async just makes sense to me
10:25dnolen_stuff I've used in JS, Obj-C, Java, C, C++ - just different flavors of awful
10:25pepijndevosIt makes a lot of sense, I'm just missing the first half of the book, which alse makes a lot of sense to me\
10:27dnolen_pepijndevos: you should read this http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.102.9787
10:27pepijndevosdnolen_: modelling an orchestra or a choir would be really easy with events instead of channels
10:27dnolen_I'm sure the Hoare stuff is good, but ^ pdf made things a lot more clear how things work in practice
10:28dnolen_pepijndevos: you can keep talking or you can try it ;)
10:28pepijndevoshaha, ok ok
10:45tjb1982anyone using korma who knows how to defentity a schema in postgres that's not public?
10:50tjb1982e.g. something like "select * from a_schema.a_table;" I tried to set it in defdb, as well, but it's only looking for the db part and fails saying "a_database.a_schema" doesn't exist.
11:14callentjb1982: grant perms yo.
11:20tjb1982callen: both schemmata have the same owner
11:21tjb1982*schemata
11:21callentjb1982: why doesn't the owner have access to its own schema?
11:22tjb1982it's not that it doesn't have access, it's that it can't figure out how to access the schema because of the dot
11:22tjb1982in postgres you have db.schema.table
11:22tjb1982defdb needs db
11:22tjb1982defentity needs table
11:23tjb1982"public" schema is assumed
11:23tjb1982but if you have other schemata it doesn't work
11:23tjb1982I can't (defentity schema.table)
11:24tjb1982and I can't (defdb db (postgres {:db "db.schema" ...})
11:24tjb1982neither works
12:11kmicuFirst example with alts!! https://www.refheap.com/16197 prints nothing, but next one with alts! is ok.
12:13kmicuhttps://github.com/clojure/core.async/blob/master/examples/walkthrough.clj
13:17igorwhas anyone written an EBNF for edn? keywords are more complex than ":$symbol"
13:18bbloomigorw: i just asked the creator of instaparse about that the other day
13:18bbloomhe said he didn't know of anyone
13:19bbloomigorw: i'd love to have a pair of robust grammars for EDN and CLJ forms, so let me know if you tackle that
13:32igorwbbloom: too bad. I have regex based lexing which is a good starting point, but I'm sure there's lots of unhandled edge cases.
13:33bbloomigorw: luckily, clojure's reader is LL(1)
13:36hyPiRionigorw: You could probably have a look at https://github.com/hyPiRion/astyx/blob/master/src/astyx.clj, though note that I know of multiple cases where symbol and keyword is wrongly defined.
13:36hyPiRionAlso, ugly regexes. I just patched and patched and ended up with that mess.
13:37bbloomit's also worth noting that clojure itself might not correctly implement it's own grammar....
13:37bbloomie being more or less permissive unintentionally
13:42tomjackbbloom: I was wondering, might you implement a reader, analyzer, compiler, in ascribe?
13:43tomjack(I mean not _you_, I'm asking about the problem space ascribe addresses, not your plans)
13:48igorwhyPiRion: interesting. but looks like it is not able to read :#foo as a symbol
13:49bbloomtomjack: i started to implement a cljs analyzer :-) but it's a pretty low low low priority project & ascribe is *no where near* feature complete enough to really tackle the task
13:49bbloomtomjack: check out the cljs branch
13:49bbloomin the test directory
13:50hyPiRionigorw: yeah, exactly. It's messy for symbols and kws
13:50Okasu>(\\\\\
13:50OkasuOh c'mon.
13:52tomjackso if you did this presumably the thing you end up with would be more extensible than the clojure reader/analyzer/compiler
13:52tomjackI wonder if it's equivalent in power to CPS'ing them
13:53bbloomtomjack: my initial target was ~2X as slow as the existing cljs analyzer prior to goog advanced optimizations
13:53bbloomtomjack: the longer term goal is roughly the same speed as google closure compiler's advanced mode, but doing the same type of optimizations at the clojure level, prior to javascript
13:54bbloomtomjack: an alternative/simultaneous long term goal would be to create an analyzer that supports in-memory incremental "changes" with efficient dependency tracking, cache invalidation, etc. such that being slower wouldn't really matter unless you change the entire repository at once
13:55tomjackinteresting
13:57bbloombut it's a pretty low priority for me, since i've learned the key things i wanted to learn from building the ascribe experiment :-P
13:58bbloomso many project ideas, so little time….
14:36supersymbbloom... I think I know that feeling, but additionally, don't fully master the language myself yet - all in due time I guess
14:37bbloomsupersym: just start making things :-) you'll be an expert in no time that way
14:37supersymBtw, I could use some advice, I was thinking about adding zipcode lookup for visitors on a site, fill in your post code and it looks up the street + city....
14:37supersymits 326000 lines of CSV though... and I intend to use it in a cljs/Luminus built site...
14:38supersymshould I put these in a db? serialize? put them in a trie? I really wouldn't know the best option
14:38bbloomsupersym: what's wrong with a map?
14:40supersymNothing...thats what I did with the taxes on vehicles lookup it was considerably smaller in size though.
14:41bbloom$ du -h zip.csv
14:43bbloomsupersym: that was a query for you :-)
14:44supersymyeah :) I know du... just that I'm not a CS major and not shitgiggles about optimization and when stuff starts to break...
14:44supersymI guess one way to find out is try :)
14:44bbloomalways a good way
14:45bbloomis the file what? 20 megabytes?
14:45supersymclojure csv reading/querying data seems easy enough... prolly beats the effort of trying to be smart
14:45supersymgood guess :)
14:45supersym21M
14:46bbloomwas an educated guess based on the number of rows & the nature of the data
14:46supersymover 12 files, 1 per province...
14:46supersymyeah
14:46bbloomthat's probably what? 30 or 40 megs in memory
14:46bbloommaybe less
14:46supersymk
14:47bbloom40 megs top, could even be smaller than 20 megs in memory, since there are no quotes and numbers aren't encoded as text
14:47bbloomread the CSV in line by line, use (into {} …) to build up a map, stick that in a var & you're good
14:47bbloom:-P
14:47supersymreally.. that easy huh :)
14:48supersymcool... I should also stop second guessing myself all the time
14:48supersymseems to be INTP trait
14:48bbloomthe curse of the skilled intermediate programmer
14:48supersymreally annoying though,... much appreciated, thanks
14:49bbloomtakes longer to fret over it than it does to just try it
14:50supersymwell it has a lot of text "Unknown" strings, and geolocs
14:50supersymI can trim all that bloat out, saves about half I guess
14:50bbloomsupersym: sounds like a job for awk :-P
14:50supersymgood thing I recently (finally) learned the syntax
14:54tomjackcan a macro expand to something that does defs in another namespace?
14:54nooga(/j coffee
14:54noogaoops
14:55bbloomtomjack: not without some hackery at the var level
14:55bbloomtomjack: or i guess hackery at the ns form level
14:55tomjackI may be OK with hackery
14:55bbloomin theory you could push/pop a ns with try/finally
14:55bbloomand in-ns
14:55tomjackI'd just use intern but there's some code only accessible via a def* macro
14:55bbloommake a with-ns macro :-)
14:56tomjackhmm
14:56tomjackI tried this (do (let [ns (ns-name *ns*)] (in-ns 'foo) (def bar 42) (in-ns ns)))
14:56tomjackno luck
14:56tomjackneeds moar hack?
14:56bbloom(eval '(def bar 42))
14:56bbloom?
14:56bbloomheh
14:57tomjackconfusing, so I need my macro to expand to an eval call to a quoted macro call..
14:57tomjackthanks
14:58bbloomdef is weird
14:58tomjackI think I vaguely understand the reason
14:58bbloomit's a side effect, but it's quasi analyzed statically, but it's also one of the few remaining interpreted primitives in clojure
14:58bbloomit's a mess :-P
14:58bbloombut it's also a repl-lovers dream
14:58bbloomso wutchagonna do
14:58tomjackif the macro could expand out to multiple top-level forms it could work?
14:58tomjackwithout hacks
14:58bbloomtomjack: i think so...
14:59bbloom"the top level is hopeless"
14:59tomjackactually, fuck it
14:59tomjackI'll just macroexpand my def* calls and use intern
15:07wastrelrazmataz
15:21QStevencore.logic question: this program returns (_0) while I'm expecting (3). Something must be wrong with pluso but I don't know what
15:21QStevenhttps://gist.github.com/devijvers/5892294
15:24tomjackQSteven: what about false true false?
15:24QSteventomjack, that's handled by :else
15:25tomjackexactly
15:25tomjackthe :else doesn't do any logic so you just get _0
15:25QSteventomjack, that's what I was thinking too, but how do I solve this?
15:26tomjackany reason you're not just using fd? this is pedagogical?
15:26QSteventomjack, what's fd?
15:27tomjack(:require [clojure.core.logic.fd :as fd])
15:27tomjackpluso is fd/+
15:28tomjackonly thing is, you have to assign domains to variables like (fd/in x (fd/interval 0 100))
15:28tomjackand it only works with non-negative integers
15:28tomjackI think what you're trying to do would be solved by "constraints and modes" which is not implemented yet
15:28bbloomhmm presumably it could be made to work w/ negative integers using a slack variable, no?
15:28tomjackyou'd have to write a constraint
15:29bbloomdnolen_: might know ^^
15:29tomjackbbloom: (to be clear, wasn't responding to you)
15:29bbloomhttp://en.wikipedia.org/wiki/Slack_variable
15:29hyPiRionwell, non-negativity can just be flipped around
15:30QSteventomjack, I'd like to get pluso working, indeed for pedagogical purposes
15:30hyPiRionx + y = -z --> x + y + z = 0
15:30bbloomyeah, essentially, you just have two magnitude variables & then a constraint that implies one of them must be zero
15:30QSteventomjack, but thanks for the fd reference, I'll look into that too
15:30tomjackI think you'll have to look into constraint internals then
15:31tomjackgrep the sources for IConstraintStep
15:31tomjackactually
15:31tomjackmaybe you don't need to
15:31bbloomx = y | y > 0 can be expressed: xpos - xneg = y | y > 0, xpos >= 0, xneg >= 0
15:31tomjackmaybe you can just defer to a constraint that's in core when things aren't ground enough, like maybe predc?
15:32tomjack:else (l/predc [x y s] (fn [[x y s]] (= (+ x y) s))) or something ?
15:32tomjack:else (l/predc [x y s] (fn [[x y s]] (= (+ x y) s))) or something ?
15:33tomjackwhoops. (l/predc [x y s] (fn [[x y s]] (= (+ x y) s)) `pluso)
15:34QSteventomjack, shouldn't I call pluso in the predicate?
15:35tomjackwell
15:35tomjackpredc doesn't seem like it will work anyway
15:35tomjackunless only one var is unground?
15:35QSteventomjack, because (= (+ x y) s) won't work when one of them is an lvar
15:35tomjackI was hoping (predc [x y s] ...) would wait until x, y and s become ground to run the pred
15:36tomjackbut at worst, following e.g. predc's example, you should be able to come up with something I think
15:36QSteventomjack, IllegalArgumentException No implementation of method: :bind of protocol: #'clojure.core.logic.protocols/IBind found for class: clojure.core.logic$cgoal$reify__3741 clojure.core/-cache-protocol-fn (core_deftype.clj:541)
15:36QSteventomjack, I'll have a look at predc
15:36tomjackyou need to call it with the substitution, (a in your code, I think?)
15:37tomjackbut it won't work anyway afaict
15:37r0bgleeson'found for class:', is that java leaking through?
15:37QSteventomjack, where would I pass the substitution?
15:38tomjackpredc returns a goal, so if you're inside a goal (fn [a] ...) you'd do (fn [a] ... ((predc ...) a))
15:38QSteventomjack, actually, what I want to return is *something* so that core.logic skips to the next line (== a 7) and then tries the pluso call again
15:38QSteventomjack, right
15:39tomjackyes, that's essentially what constraints are for
15:39QSteventomjack, you're right, predc doesn't seem to have an impact, still (_0)
15:39tomjackI'd try a -plusc closely following predc
15:40tomjackinstead of just x you have three args
15:40tomjackand you don't need p/pform
15:41tomjackoh and you'll have to do something predc doesn't in the cases where you're able to infer a value
15:41tomjackext-run-cs/ext-run-csg I think to set the inferred value
15:42tomjackgood luck, if you are stuck I may have some time later to help, but gotta get back to work
15:43QSteventomjack, thanks for you help, unfortunately none of this is intuitive :(
15:43tomjackyeah it took me a very long time to get the rudimentary understanding of core.logic I have now
15:44tomjackthough if you are more diligent it could take less time :)
15:45tomjackin the back of my mind has been the problem of a more friendly interface for defining constraints
15:46tomjackcan't help wondering why a constraint can't just be a fn
15:46tomjackguess there are probably good reasons for all the protocols though
15:48QSteventomjack, if only there would be more documentation :)
15:52Apage43grumble grumble
15:53Apage43sublime text totally failed at highlighting here :/
16:00FoxboronApage43: i have been considering throwing up a own syntax file in my Enhanced Clojure package for ST, if i recall, it dosn't hilight correctly if you type 1000N and so on
16:17gfrederickscore.async's README still has the "don't use this" disclaimer which is contradicted by rich's blag
16:17technomancygfredericks: you should submit a pull request
16:19gfrederickstechnomancy: is this your new long term sabotage strategy?
16:19gfredericksfirst you infect contrib with project.clj files, then you bombard them with PRs
16:19technomancygfredericks: war of attrition
16:20BronsaTBH I see nowhere written that contribs cannot accept pull requests
16:20hyPiRionoh no, we may get productive
16:20gfredericksis the next phase to snail-mail-DDOS them with CAs?
16:20technomancygfredericks: actually snail-mailing printed patch files would be awesome
16:22gfredericksI wonder if snail-mail-DDOS is illegal...
16:22bbloomillegal? it's the USPS' business model!
16:23metellusyeah, you pay postage
16:23technomancythis is such a good idea that I'm wracking my brain trying to think of a patch to send.
16:23bbloomtechnomancy: surely there is a typo in a doc string somewhere
16:24gfredericksbbloom: spam and DDOS are kind of complementary things
16:25benkay_does anyone recommend resources other than the o'reilly book for learning clojurescript + ecosystem?
16:25hyPiRiontechnomancy: I can give you all rights to http://dev.clojure.org/jira/browse/CLJ-1134
16:25hyPiRionI'll send you a snail mail with my signature on a paper you can send with it
16:25gfredericksso core.async isn't in maven yet? folk just installing the snapshot locally?
16:26technomancyhyPiRion: haha; no, it should be something that's not in jira yet
16:26hyPiRionoh okay
16:26bbloomgfredericks: afaict
16:27QStevencore.logic: is -inc a thunk wrapper?
16:27gfredericksQSteven: yep
16:27gfredericksit stands for "incomplete"
16:27gfredericksI just found out
16:27tomjackoh!
16:27tomjackI always thought it was some pun on mplus
16:27QStevengfredericks, and what does this "incompleteness" do?
16:27gfredericksI always thought it was just unknowable
16:27gfredericksQSteven: lets you "pause" computation
16:27gfredericksso it can try other branches if available
16:28QStevengfredericks, but pauzing only makes sense with branches, right?
16:28gfredericksI think so
16:28gfrederickswell
16:28gfredericksmaybe it's also a general laziness mechanism
16:29gfredericksI was going to say for when there are infinite results, but that implies branching as well
16:29bbloomhave you guys re-read out of the tar pit lately?
16:29QStevengfredericks, I currently have the situation where I'm in an AND chaining of goals and in some circumstances I want to skip the current goal, go ahead with other goals and later try again
16:29bbloomi'm pretty sure rich just implemented this paper & called it datomic :-P
16:29bbloomi know it's an explicit influence, but damn it's entertainingly similar
16:30QStevenbbloom, rich mentions "the tar pit" in one of his recorded datomic talks
16:30bbloomyup
16:30gfredericksQSteven: this sounds like some sort of fair conjunction
16:30bbloomi'm re-reading it now b/c i'm particularly interested in derived values
16:30QStevengfredericks, fair?
16:30gfredericks$google fair conjunction status report
16:30lazybot[Clojure and me » Fair conjunction: status report] http://clj-me.cgrand.net/2012/04/06/fair-conjunction-status-report/
16:31bbloomsomething datomic does well w/ rules, but is tuned for database use cases
16:31gfredericksQSteven: ^
16:31gfredericksbbloom: datomic has "rules"?
16:31bbloomgfredericks: yeah, for disjunction & arbitrary predicate code
16:32bbloomsearch rules on here: http://docs.datomic.com/query.html
16:32QStevengfredericks, so no luck with sanctioned core.logic?
16:32gfredericksbbloom: how have I missed this?
16:32bbloomsee also http://docs.datomic.com/database-functions.html which discusses "transaction functions" in depth, but non-transaction functions are usable from rules
16:33gfredericksQSteven: I imagine not
16:33bbloomgfredericks: i dunno :-P
16:33bbloomthe more i play with datomic, the more i agree w/ fogus' initial review: "ufo appearing over the national mall"
16:34QStevengfredericks, ok, thanks, I'm going to play with bind for a while, maybe that will work
16:34tomjackbbloom: is that a positive or negative review? :)
16:34bbloomtomjack: positive. it's advanced alien technology
16:35tomjackgood way to put it
16:35technomancyhttps://www.zazzle.com/rlv/lisp_made_with_secret_alien_technology_t_shirt-r6820c892f43a4ee295b7316f83372e68_804gs_512.jpg
16:35bbloomtechnomancy: awesome.
16:35gfredericksbbloom: I LIKE THIS thanks
16:36bbloomgfredericks: indeed.
16:36gfredericksyeah I have a hard time summarizing datomic to people in a sentence without leaving out at least 80% of the interesting bits
16:37bbloomi feel so conflicted about the closed source nature of it, however. on 1 hand, i'm a big believer in "pay me for my high quality software" and all the people involved with datomic deserve to be filthy stinking wealthy for their hard work
16:37tomjack"alien" gets at its inscrutability and conjures an image of people fleeing in fear
16:37tomjackwell the "national mall" bit anyway
16:37bbloomon the other hand, i've seen first hand what reliance on proprietary databases can do to your budgets....
16:37bbloomon the other other hand, the pricing is relatively reasonable
16:37gfredericksbbloom: agreed; I wish there were reasonable/feasible ways to pay people for making digital things.
16:38gfredericksbbloom: at my company I'm less worried about budgets and more about what the situation might be like in 5 years
16:38bbloomon the other other other other hand, i really like to have the source to things i rely on
16:38bbloomyeah.
16:38gfredericksin terms of support; also having the source is nice
16:38gfredericksfixing bugs, forking when you need to
16:38tomjackthe path is clear, create more alien technology
16:38bbloomi kinda wish there was some middle ground :-/
16:38QStevengfredericks, the blessing & curse of Datomic is that the competition sucks
16:39bbloomis this where we laugh at mongodb agan?
16:39bbloomlolerskates, mongodb
16:40bbloomi guess if you're a large enough client, you can probably negotiate source code escrow or something
16:40bbloombut for a little startup, that's not really feasible
16:40tomjackfor e.g. security audits maybe?
16:41QStevengfredericks, the only thing -inc seems to do in a bind-chain is create an endless loop
16:41bbloommore like: we have a support contract & if we can prove that you can't meet your end of the deal, this escrow company releases the source to us so that we aren't fucked
16:42bbloomhttps://en.wikipedia.org/wiki/Source_code_escrow
16:44QStevenit's funny, all important bits in core.logic are grouped in ~60 consecutive lines
16:44gfredericksQSteven: that sounds a bit weird. but it takes me forever to wrap my head around core.logic code so I don't think I can help in short order
16:44QStevenmakes it easier to browse, not easier to understand
16:44bbloomQSteven: heh, yes. reading the literature first would certainly help :-)
16:45xpeI'm looking for a way to unbind a dynamic var. Mostly for testing. (ns-unmap 'a 'foo) isn't quite what I want.
16:45xpeIf I ns-unmap then I'll need to do `def` again. I want to get the var back to where it says #<Unbound Unbound: in the REPL
16:45QStevenxpe, (binding [myvar nil] ) ?
16:45tomjackxpe: (.unbindRoot var)
16:46xpeQSteven thanks. tomjack : that might be it!
16:47QStevengfredericks, it's not -inc, it's my crazy thunk that's creating the infinite loop
16:47gfredericksQSteven: you're doing your own thunk?
16:48xpe,(find-doc "unbind")
16:48clojurebotnil
16:48QStevengfredericks, I'm trying to convince core.logic to skip this goal for now and continue to the next goal, I'll do anything that works, so far no luck
16:49gfredericksQSteven: you'll probably have to mess with the innards of bind at least; I can't imagine it being easy
16:50gfredericksif you don't understand the impl of minikanren then it _definitely_ won't be easy
16:50xpetomjack: I haven't figured out where unbindRoot comes from
16:50gfredericksxpe: it's a method on Var
16:52tomjackQSteven: you really want constraints
16:52QSteventomjack, my kingdom for a constraint
16:52Erghi'm making a game and i want to decouple the GUI from the gameplay. im thinking i should send events between them, so they dont have to know about each other (well, the gui might still have to read some things from gameplay for rendering). like the GUI receives a mouseclick and sends a move-to event to the gameplay or the gameplay send a "combat"-event so the gui switched to another screen. any tips on what i could use to do that in c
16:52xpe,(do (def x 1) (.unbindRoot #'x))
16:52clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:52xpetomjack: I think that ^^ will work
16:53gfredericksI'm surprised it does
16:53gfrederickswhat about technomancy's geribaldi paradox?
16:54tomjackclojure has its own hack for that
16:54gozalacane anyone explain or point to a docs that explain what "&" prefixed arguments are ?
16:54technomancyplease, it's "gilardi scenario"
16:54gfrederickstechnomancy: that's what I said
16:54gfredericksgozala: you mean &env and &form?
16:54gozalagfredericks: yes
16:54gfredericksgozala: those are magical arguments to macros
16:55gozalaaha
16:55gfredericks&env has info about locals; &form is the entire macro-call form
16:55lazybotjava.lang.RuntimeException: Unable to resolve symbol: env in this context
16:55gozalagfredericks: are they documented anywhere ?
16:55gozalaI have a feeling that's what I need too
16:56hyPiRiongfredericks: Closest I can give you is Garibaldi: http://en.wikipedia.org/wiki/Giuseppe_Garibaldi
16:56gfrederickshyPiRion: I think that's what I was trying to spell
16:57gfredericksgozala: I can't find any
16:57hyPiRionoh
16:57hyPiRionHe looks like some logo for a project management tool though, so no wonder
16:57gozalagfredericks: so is that just those two names that are special
16:57gfredericksgozala: yep; you can see them in the impl of defmacro
16:57gozalaor any & prefixed args are special ?
16:57gfredericksI don't know of anything else prefixed by &
16:58gfredericksI think it's a fun idea to use the prefix for anaphoric locals
16:58technomancyyeah &env and &form are secret compiler features
16:59gfredericksthe next macro I make will wrap its output in (let [&& '&] ...)
16:59technomancyyou monster
16:59bbloom(&& this that)
16:59bbloom;; if you miss C
17:00gfrederickssomebody at the local meetup asked why not= instead of != and my only guess was something about lisp traditions
17:00technomancythere's no single function that's (comp vals ns-publics) is there?
17:00technomancygfredericks: isn't it more a lack of C traditions?
17:01technomancyhttps://lh3.ggpht.com/-O2VRBGn3-xE/UUoH6dzgg1I/AAAAAAAAA0A/yIN6zoyrNOM/s400/English-Mother-Fucker.jpeg
17:01bbloomand ! means something else in clojure....
17:01gfrederickswhat does it mean?
17:01hyPiRionmutation
17:01gfrederickswat
17:01hyPiRionor side-effects
17:01Foxborongfredericks: set!
17:02hyPiRionwell, usually. it's not anything you're enforced to do though
17:02gfredericksFoxboron: send
17:02amalloygfredericks: because C can't afford to have any of its operators contain letters, and clojure doesn't need any operators
17:02gfredericksalter-var-root
17:02gfredericksif you cared about marking mutation I thin you'd start with that one
17:03bbloomamalloy: doesn't NEED, but it does HAVE some…. all of them unary/prefix :-)
17:03konr``Can a program in run time import a .jar and use functionalities from it?
17:03technomancyhey-pay-attention-the-var-root-is-gonna-be-altered!
17:03technomancykonr``: jar files are just zip files
17:03gfredericksquick quick (defn alter-var-leaf ...)
17:03amalloybbloom: oh, you mean reader macros like quote? good point
17:03amalloyi guess those are basically like operators
17:03technomancykonr``: and the compiler is available at runtime
17:03hyPiRionI would've expected not= to be /=, then I realized why it isn't.
17:03bbloomamalloy: yeah. the most obvious one is @ for deref
17:04bbloomthat's strictly sugar
17:04gfrederickshyPiRion: haha that'd be another special case in the reader
17:04amalloy*nod*
17:04amalloyclojure.core//= :(
17:04gfredericksalso there's the in-ary ** operator that makes a var dynamic
17:04hyPiRionThen I had the idea that you could do \= but then I realized that's also not possible
17:04bbloomheh
17:04hyPiRionand then I gave up
17:04bbloomi don't think clojure has any infix or postfix operators....
17:04gfrederickshyPiRion: sure it is just make \equal for the "=" character
17:04amalloygfredericks: it's not prefix, postfix, or infix. it's like...outfix?
17:05gfredericksamalloy: yeah I was struggling with the word too
17:05bbloomunless you consider ; to be the infix comment operator
17:05hyPiRiongfredericks: makes perfect sense!
17:05amalloyextrafix
17:05gfredericksI like outfix
17:05bbloommatchfix
17:05bbloommixfix
17:05bbloom^^ actual things
17:05gfredericks() is the outfix call operator
17:05QStevencore.logic: what's the difference between choice & conde?
17:05hyPiRionmastermix
17:06gfredericksQSteven: choice is an impl detail
17:06gfredericksrepresenting a solution and a function to look for alternatives
17:06konr``technomancy: but in the case there is only compiled stuff in the jar, can I somehow use it from the running program?
17:07QStevengfredericks, but isn't that what conde does as well?
17:07bbloomoh, you know what…. & is basically an infix operator
17:07gfredericksomg the macroexpansion of (go) is 63 lines
17:07technomancykonr``: oh, in that case you need to use a classloader. it's more complicated but still possible.
17:07gfredericksQSteven: at a much higher level; conde uses choice
17:08gfredericksif it finds a solution at some point
17:08bbloombinds to the left, so an arg list is parsed: [x y z & more] as (varargs [x y z] more)
17:08bbloomer i mean binds to the rigth
17:09gfredericksbbloom: is midje a pile of operators?
17:09bbloomi've avoided looking at midje
17:09technomancygfredericks: it's more of a pit than a pile
17:09gfrederickslook at that steaming pit of operators with limbs hanging out
17:10konr``technomancy: interesting! Thanks!
17:10hyPiRiontechnomancy: tar pit?
17:10technomancyhyPiRion: maaaaaybe
17:10hyPiRionhehe
17:10QStevenbbloom, why? midje is good fun
17:10amalloybbloom: you mean & for varargs? that's surely prefix
17:11bbloomQSteven: b/c i'm just not interested in test frameworks much & people bitch about it a lot
17:11gfredericksmidje bitchers
17:12QStevenmidje bites midjes bitchers
17:12bbloomamalloy: if you were creating an AST node for that, you'd basically have two kinds: FixedArity[x, y, z] and VariableArity[x, y, z, more]
17:12bbloomin mathematica notation :-P
17:13bbloomthe & changes the meaning of it's predecessors/parent ast node
17:13bbloommeaning it's a binary relation, not a unary one
17:14bbloomin theory, you could represent it ArgList[Arg[x], Arg[y], Arg[z], Args[more]]
17:14bbloombut that would imply you could have something like ArgList[Arg[left], Args[middle], Arg[right]]
17:14bbloomwhich clojure can't do
17:15bbloomalthough center splats would be nice in some cases…. but doesn't play nice w/ lazy apply
17:15bbloombut that would allow multiple variadic Args, which basically gets you into full on lexing/parsing of an arg list :-P
17:16bbloomyou could have SplatArgs[{left}, more, {right}] which would only allow you a single splat position :-)
17:17bbloomwhich is what i think coffeescript does in their AST
17:21QStevencore.logic: in a bind-chain, when a goal returns an IBind object, the bind method on the object will be called next, correct?
17:22gfredericksuh
17:23danneuincredible how easy it is to work with bytes when you can just (map int bytes)
17:24danneuall day
17:25gfredericks,(time (count (map (fn [_] (Thread/sleep 5)) (range 100))))
17:25clojurebot"Elapsed time: 516.994697 msecs"\n100
17:25gfredericks&(time (count (map (fn [_] (Thread/sleep 5)) (range 100))))
17:25lazybot⇒ "Elapsed time: 593.318556 msecs" 100
17:26gfredericksI guess Thread/sleep is not very precise
17:26gfredericksnot sure why I would expect it to be
17:27seangroveWhat is `alts!` short for?
17:27tomjackmy guess is "alternatives"
17:27seangroveThat's what I thought, but I'm not clear on how that applies to what it does
17:27seangroveI'll continue reading along...
17:28gfrederickstakes the first available option from several alternatives?
17:29bbloom(inc gfredericks)
17:29lazybot⇒ 27
17:29danneuthis pattern shows up all over my code when i want map->map transformation: (into {} (map (fn [[_ v]] [_ (f v)]) pair)) — is there an even more succinct way to map f over k/v and get a map back out?
17:30hyPiRion(into {} (for [[k v] old-map] [k (f v)]))
17:30danneucan you find a way to incorporate juxt?
17:30danneui don't mind if it's 2x longer
17:30amalloydanneu: juxt doesn't work very well for that
17:30amalloyit'd be more than 2x longer
17:31danneuyeah, lame joke
17:31bbloom(into {} (map (juxt identity f) old-map))
17:31bbloomor no
17:31bbloom(comp f val)
17:31gfredericksI meant to cue amalloy for something different from juxt
17:31amalloybut i wrote knit: (defn knit [f g] (fn [[a b]] [(f a) (g b)])), (into {} (map (knit identity f) m))
17:31bbloom(juxt key (comp f val))
17:31bbloomyeah mess :-P
17:31seangrovedanneu: Prismatic has a similar function in their plumbing lib: https://github.com/Prismatic/plumbing/blob/master/src/plumbing/core.clj#L32-L37
17:32danneuknit looks hot
17:32tomjackI quite like (juxt key (comp f val))
17:34danneuthanks folks
17:35seangroveAh, and the core.async article falls off of the front page of hn...
17:35danneui like to add a few layers of indirection to my code to counterbalance all the simplicity
17:36elephantTechnoWhat's the cleanest way to design sorted stacks ? I think I could embed a PersistentList in a new type with a keyfn and a comparator (like with sorted-map-by), but I'm afraid I'd have to reimplement each functions of the list datatype and delegate them to the embedded list.
17:37bbloomelephantTechno: a sorted stack?
17:37bbloomdo you mean a priority queue?
17:37elephantTechnoYes that's what I mean, but sith only one end and not two unlike regular queues
17:38gfrederickswhy is my channel-based pmap hanging?
17:38bbloomelephantTechno: http://en.wikipedia.org/wiki/Priority_queue
17:38bbloomthere isn't really "ends" to a priority queue
17:38bbloomyou insert somewhere in the middle and pop off the front only
17:38gfrederickshttps://www.refheap.com/16201
17:39elephantTechnoAnother implementation I'v thought of is with a map, having priorities as keys and list of values as values.
17:39hyPiRionelephantTechno: could there be multiple equal elements in the priorityqueue?
17:40elephantTechnoAbsolutely
17:40danneuwhat's the name of the concept on macros that forces you to use the octothorpe: (defmacro java-fn [f] `(fn [o#] (~f o#)))
17:40elephantTechnoIt's meant to be used in implementing a branch and bound knapsack solver
17:40elephantTechnoGensym ?
17:41danneuthanks
17:41gfredericksdanneu: hygiene?
17:41danneuwhat's the simple description of why gensym is necessary
17:41elephantTechnoactually I think o# expands to (gensym 'o)
17:41bbloomdanneu: symbol capture
17:41danneuah
17:41bbloomhttp://dunsmor.com/lisp/onlisp/onlisp_13.html
17:42danneugreat, thanks!
17:42hyPiRion,`o#
17:42clojureboto__29__auto__
17:42seangroveAh, hilarious memories of mistakes with non-hygenic macros...
17:42bbloomthe gensyming isn't part of the expansion result, it's part of the expanding process
17:43danneunow i can stop faking it til i make it with macros i think
17:44gfredericksoh I know why; hah.
17:44gfredericksasync is hard
17:44hyPiRionelephantTechno: I would probably use sorted-map-by and let the keys in the map describe the amount of elements with this value
17:45bbloomgfredericks: yes, yes it is.
17:45hyPiRionunless elements can be equal but different of course.
17:46bbloomgfredericks: but somewhere, there is a C hacker who is going NUTS about Golang, but when he encounters some use of higher order functions, he is thinking "functional programming is hard" :-P
17:49gfredericksyeah well that guy is wrong.
17:49gfredericksbut about something unrelated. just because it's hard to not be wrong about at least something.
17:51elephantTechnohyPiRion: Ok then I'll try to solve my problem this way. Thank you.
17:51musicalchairhmm. is there something funky about document.write? if I eval '(.write js/document "hey") from a cljs.repl.browser, it never returns.
17:52bprmusicalchair: maybe your browser isn't connected? try refreshing?
17:52bprbeyond that, i have no idea
17:52musicalchairit's connected. before evaling that I eval js/alert, +
17:52bprok
17:52musicalchairbpr: hmm ok
17:58musicalchairit kind of looks like things hang on the browser side. when I do a '(.write js/document "hey") from my cljs repl, it hangs (as I mentioned before). If I force quit the repl, the browser doesn't notice (normally if the cljs repl is exited the browser will complain about e.g. a failed 'POST' request)
18:00musicalchairwith '((fn [] (js/alert "1") (.write js/document "hey") (js/alert "2"))) I see both alerts (and the write) but control is never returned to the repl
18:06defntechnomancy: Syme is having some issues. I'm
18:07defnIn a cab so I can't check it out.
18:08defntechnomancy*
18:38ejbsWould you call '(1 2 3) a "symbol" in Clojure-land?
18:38ejbsOr is it (quote (1 2 3)) which returns the list (1 2 3)?
18:40hyPiRionit's not a symbol
18:40SegFaultAXejbs: It's just a list.
18:40hyPiRion,(symbol? '(1 2 3))
18:40clojurebotfalse
18:40danneu(class '(1 2 3)), (class (quote (1 2 3))), (class (list 1 2 3)) - all PersistentList
18:41ejbsYeah, that's what I thought, thanks.
18:42SegFaultAXejbs: Just remember that we have to quote lists in particular since the (...) form is most often used for function application.
18:42SegFaultAXEg ##(+ 1 2)
18:42lazybot⇒ 3
18:43SegFaultAXBut if I quote that form, I can get a list that contains those elements: ##'(+ 1 2)
18:43lazybot⇒ (+ 1 2)
18:43SegFaultAXPerhaps a little clearer: ##`(+ 1 2)
18:43lazybot⇒ (clojure.core/+ 1 2)
18:43SegFaultAXclojure.core/+ is the fully qualified symbol.
18:44jro_any suggestions for Trie-library for clojure?
18:44ejbsSegFaultAX: Oh yeah, I know. I was just reading this page: http://learnxinyminutes.com/docs/clojure/ and I was on my way to issue an issue on Github about it but I just wanted to make sure that you don't call that a symbol in Clojure (which, IMHO, would be totally weird of you to do)
18:46ejbsThanks for all the help!!!
18:46SegFaultAXejbs: Well I assumed you asked if it was a symbol because of the ', which is obviously incorrect so I was trying to clarify. :)
18:47ejbsSegFaultAX: Dude, I'm not complaining, you're awesome for helping out :). I'm just clarifying why I'm asking
18:48SegFaultAXejbs: Sweet! Good luck.
18:48ejbsThanks!
19:02musicalchairif I have a protocol P where P is extended to (java) interfaces A and B, how does clojure dispatch if I have an object implementing both A and B?
19:20arohnermusicalchair: I'm not sure, but it wouldn't surprise me if that follows Java's rules for dispatch
19:24r0bgleesonhow do Java classes map in clojure?
19:25ptn777r0bgleeson: what do you mean by map? do you mean how do you call a java class from a clojure program?
19:25r0bgleesonptn777: kind of, i assume clojure doesn't have a notion of a 'class' in clojure itself, so im just curious how that works
19:27r0bgleesonfor example can i create a java class from clojure?
19:29r0bgleesonmaybe my thinking is totally dumb, but my comparison is jruby, where concepts map between java + ruby
19:30ptn777r0bgleeson: did you read this? http://clojure.org/jvm_hosted
19:30ptn777that's a clojure program using swing stuff
19:31callenr0bgleeson: but if you actually want to use swing, please use seesaw
19:33SegFaultAXr0bgleeson: There are a great many things in clojure that will generate a new class, gen-class not the least of them.
19:34r0bgleesonptn777: didnt see that, great read though, i had seen the dot notation and not really understood it
21:23horofox_can somebody help? http://pastie.org/8095755
21:23horofox_the question is: why does when I hardcode number as "0000000001" works
21:24horofox_and when I use let it doesn't work
21:37bbloomhorofox_: your problem isn't a datomic one, it's a clojure/lisp one
21:37horofox_so, help me :D
21:37bbloomconsider: ,(let [x 5] 'x)
21:37bbloom,(let [x 5] 'x)
21:37clojurebotx
21:37bbloomquoting prevents evaluation
21:37bbloomnotice you get a symbol, not a number
21:38bbloomwhat you're doing is comparing to see if the field is equal to the symbol 'number
21:38bbloomyou need to add parameters as a data source: http://docs.datomic.com/query.html
21:39horofox_bbloom: so, in my example, how it would be?
21:39horofox_the right way
21:40bbloomhorofox_: you need to add a :in clause and then add another argument to the q call. see the docs
21:41horofox_i can't get it how to use a data source...
21:41bbloomhorofox_: think of it like template parameters
21:41bbloom(render-template the-template the-template-parameters)
21:42bbloomsearch that page for "Peer.q" and for ":in"
21:42horofox_how do i set the number variable in my case to be $number?
21:43horofox_i feel very dumb reading those docs trying to do something practical :(
21:43bbloomare you *reading* them? or are you skimming/scanning them to find the answer to your question?
21:43bbloomthe datomic docs are extremely dense
21:43bbloomthey are meant to be read top to bottom
21:44bbloomjumping in at any particular spot will have insufficient context to help you
21:44horofox_i'm trying to do the simplest thing ever...
21:44bbloomwhich is plainly demonstraited on that page in several places that i pointed out to you....
21:44bbloomteach a man to fish and all that...
21:45horofox_i'm trying to find a entity where a key matches a value...
22:02horofox_bbloom: thanks
22:02horofox_bbloom: it worked
22:02bbloomhorofox_: hopefully you learned a few other good things while you were in there reading
22:02bbloomhappy to help
22:06horofox_btw
22:07horofox_datomic is awesome :)
22:08horofox_is there any startup that uses diatomic in production?
22:08horofox_datomic*
22:13echo-areahorofox_: How much capacity can datomic provide? I mean the data-size/QPS etc
22:13horofox_echo-area: i don't know, i'm just studying the technology.
22:13echo-areahorofox_: Is it suitable for the "Big Data"? (I quote because I don't quite like the term)
22:14echo-areaOkay
22:57horofox_question, i see maps with keys like :user/name, does the / means something or is it just coding style?
22:58tbaldridgehorofox_: it's the namespace of the keyword. It really doesn't do much, except allow you to have multiple :???/name keywords that are not equal
22:58horofox_i see
22:58tbaldridgebtw, if I am in the namespace (ns myproject.core) then the following are true:
22:59tbaldridge(identical? ::name :myproject.core/name)
22:59tbaldridgeand if I (:require [clojure.string :as s]) then the following is true:
23:00tbaldridge(identical? ::s/name :clojure.string/name)
23:00tbaldridgehorofox_: anyway, that's just some random info about keywords :-)
23:01horofox_this is good :)