#clojure logs

2012-11-03

00:00brainproxythe idea being that for dev purposes, it can help you to think more carefully about what you're putting together
00:00Sgeobrainproxy, so basically a run-time check that the programmer is using things correctly? Cool
00:01brainproxySgeo: yep. https://github.com/michaelsbradleyjr/protocol-monads/blob/examples/src/monads/core.clj
00:01brainproxysee the fns check-return-type and wrap-check
00:01brainproxynot all the monads implement it yet
00:02brainproxyalso, the warning message / exception thing could use some work, it probably doesn't agrue w/ "best practices" for that kind of thing
00:02amalloyAtKaaZ: the question doesn't make sense, and it's not clear whether it would start making sense with more context
00:03AtKaaZamalloy: https://www.refheap.com/paste/6363
00:03Sgeobrainproxy, haven't looked too closely, but the argument list of check-return-type could use some work, I think. Haven't thought about it beyond that
00:04brainproxySgeo: it's a bit long, however, because of laziness it seems best to "catpure" the value of the dynamic vars
00:04brainproxyan easy way to do that is to pass them as arguments
00:05brainproxyalso, it's not a user-facing function, so...
00:05brainproxyin which case, I can make it a defn-
00:05SgeoOh, I see, check-return-type is private
00:05SgeoDidn't realize that at first. Yeah, make that clear.
00:05brainproxyyep
00:05amalloyAtKaaZ: you should try writing out, long-hand, what you expect a particular call to your macro to expand to. it looks like you're just flailing wildly at the moment, and that will give you some focus
00:06AtKaaZamalloy: I will do that
00:07brainproxySgeo: the other thing I learned, from working through the lib's test suite and source is that it's not lazy enough
00:08brainproxybut I have plans to take apart `plus` and a few other helper functions, and reimplement as macros which carve the pieces up and wrap them in thunks
00:09SgeoHmm, I feel like I don't entirely follow, but why do you need macros? Oh, to thunkify?
00:09brainproxyyeah, because clojure is strict
00:09brainproxyexcept for macros
00:10brainproxyand a few other special cases like `if`
00:10brainproxySgeo: see https://github.com/jduey/protocol-monads/blob/master/test/monads/test/core.clj#L269
00:11brainproxythe author's note on that test isn't quite right; the monad isn't the problem, it's that `plus` isn't lazy enough
00:12SgeoHmm
00:12brainproxythe only way to work around the problem is to make `plus` a macro, thunkify, and and then rewrite the various plus-step methods to evaluate sequence member as it chews along
00:12SgeoDo consider that you might confuse people if you're excessively lazy
00:12brainproxywell, maybe there's another way, your input will be welcome
00:13brainproxySgeo: true...
00:13brainproxyI guess it seems like laziness would be the "right thing" for the maybe monad
00:13brainproxywhat do you think?
00:13SgeoHmm, what happens if...
00:14SgeoLemme paste something
00:14brainproxyk
00:15SgeoOh, I see, I misunderstood the test
00:16SgeoWait, oh, I see
00:16SgeoIs the exception thrown from do?
00:16SgeoErm, m/do?
00:16brainproxyyes
00:17brainproxybecause the arguments to plus are fully evaluated
00:17brainproxybefore that fn even gets anywhere
00:17SgeoBut should m/do evaluate to maybe-zero-val or throw an exception, outside of m/plus?
00:18brainproxyoutside of m/plus it would throw an exception
00:18ivanjust discovered https://github.com/semperos/webdriver-logic
00:18brainproxybut the definition of m/plus suggests that m/do should just be ignored
00:19Sgeobrainproxy, not sure why it should be ignored?
00:19SgeoI imagine it should be ignored in this case https://gist.github.com/4005862
00:19brainproxyplus returns the first monadic value that isn't maybe-zero-val
00:19SgeoAh
00:21SgeoI do wish to note that macroifying plus would severely limit where it could be used.
00:21brainproxyhmm
00:22SgeoNot sure if there's a good solution other than some way to do some sort of pervasive lazy thing in Clojure
00:22brainproxycan you give an example of a use case?
00:22SgeoHmm. Honestly, no examples off the top of my head.
00:23brainproxybut you're right, if it's a macro then you can't do certain things with it
00:23SgeoIt's the reason and and or are macros :/
00:23SgeoMaybe a macro and non-macro version? I think this is unsatisfying somehow though
00:24SgeoThe non-macro version that isn't lazy would still be semantically correct bar the issue of exceptions
00:24SgeoAnd infinite loops
00:24Sgeo(Basically, bottom, in Haskell terms)
00:24amalloy(map (partial apply m-plus) [[(just 1) nothing] [(just 2) (just 3)]]), right? something you can't do if it's a macro
00:25amalloyor even just (apply m-plus [...]) really
00:25SgeoCould fix the exception half of that if Clojure had a CL-style condition system
00:25lynaghk`I'm trying to be a good citizen and namespace my reader literals, but doing so causes reading errors (this is on clojure 1.4): java.lang.ClassNotFoundException
00:25SgeoSuch a system is ... fakable, to some extent, but it's been a while since I thought about that, so don't know if that would help
00:25brainproxyamalloy: yeah, except the argument to plus is expected to be a vector/list/etc
00:26lynaghk`I've tried setting up the symbols in *data-literals* both with (symbol "full/name") and (symbol "full" "name")
00:26Sgeobrainproxy, so, trying to refer to something such as a var that names a vector, rather than the literal vector, would break it?
00:26amalloylynaghk`it's just full/name. i don't think that file is evaluated
00:26brainproxySgeo: not sure
00:27lynaghk`amalloy: I'm trying to do it within a (binding [*data-readers* {}] ...) form, not using data-readers.clj
00:27brainproxySgeo: if it's a macro, i guss so
00:27SgeoIf there's a macro version, there might not be much of a point to accepting a literal vector
00:28SgeoRather than just taking multiple arguments
00:28amalloypaste your actual binding form, lynaghk`? seems like it should work like any other var
00:28brainproxySgeo: there is inasmuch as you can still take apart the vector literal
00:28brainproxybut I think I get your point
00:29brainproxySgeo: okay, let me ask something else; in your opinion should *warn-on-mismatch* and *throw-on-mismatch* both default to false?
00:29lynaghk`amalloy: https://www.refheap.com/paste/6365
00:30brainproxyor would you want the *warn...* to default to true
00:30brainproxyi'm thinking both defaulting to false is the correct thing, with the return checker being completely opt-in
00:31lynaghk`amalloy: actually, you want this one: https://www.refheap.com/paste/6366
00:31SgeoWait, does the return checker need to be explicitely used, or is it used in your library somewhere
00:31SgeoLet me check
00:31lynaghk`amalloy: using prn blows up because nil is returned.
00:31SgeoAh, you're building in wrap-check to stuff
00:31brainproxySgeo: you would use it like this (binding [m/*throw-on-mismatch* true] (m/do ...))
00:32brainproxythough I think in that branch I have *warn...* defaulting to true
00:32SgeoWell, warnings aren't fatal, and it is a rather bad thing to have a mismatch
00:32brainproxyand yes, it's by way of wrap-check that the monadic function gets setup to have its return value checked
00:33SgeoSo, I think *warn-on-mismatch* true by default does seem reasonable
00:33brainproxySgeo: well in some cases it's not too bad, e.g. (m/do list [x (range 5) y (range 3)] (+ x y))
00:34brainproxyto pass the return checker you would actually do...
00:34brainproxy(m/do list [x (into '() (range 5)) y (into '() (range 3))] (+ x y))
00:34Sgeobrainproxy, I think in that case it probably should pass the return checker, so make the return checker work with that.
00:35brainproxywell ... actualy, I'm thinking the stricter the better, w/ the idea being that once you're satisfied that you're monadic funcs are doing what they should
00:35brainproxythen you can relax the checker
00:35tomojlpvb: I haven't, but I think it would be interesting
00:35brainproxyeven if technically the monadic func is mismatching
00:35tomojplan to try it but don't have time right now
00:36Sgeobrainproxy, the list monad isn't really about lists, per se, but about having a monad that captures the idea of returning 0 or more values.
00:36amalloylynaghk`: your tag name can't have . in it. not sure if that's a bug or a feature
00:36brainproxySgeo: i know
00:38lynaghk`amalloy: I checked the EDN spec, nothing about that: "# followed immediately by a symbol starting with an alphabetic character "
00:38lynaghk`amalloy: so it sounds like a bug to me. I'll try with 1.5 and file a report if it's still borked.
00:38amalloylynaghk`: EDN's spec is a joke though, right? it's fully of holes
00:39brainproxySgeo: consider this one... (m/do hash-set [x (into #{} (range 5) y (range 3)] (+ x y))
00:39brainproxyignore my checker thing for a sec
00:39brainproxyand just consider that even though that example is messed up
00:39brainproxyyou won't get a compiler or runtime error
00:40brainproxysince bind for hash-set uses clojure.set/union, which works just fine w/ non hash-sets
00:40lynaghk`amalloy: *shrug*. It's a bug with data-literals then.
00:40lynaghk`amalloy: clojure's reader lets me put as many slashes in there as I want though
00:40lynaghk`amalloy: but that is definitely against the EDN spec.
00:40tomojare there associative emtyables besides vectors which may throw errors depending on what you (partial assoc (empty coll))?
00:41brainproxySgeo: so what we're really facing is the fact that w/o some kind of way to keep straight the type of the protocol-monad vs the type of the monadic fn's return values
00:41brainproxyyou can get really hard to debug things going on
00:42amalloytomoj: the set of associatives and emptyables are both open, so yes
00:42brainproxyso a really strict (even silly strict) checker mechanism
00:42brainproxycan help you not shoot yourself in the foot
00:42tomojamalloy: I want a constructive proof :)
00:42tomojwell
00:42tomojthat's easy
00:42amalloyindeed. it's just a reify
00:43lynaghk`oh, right. Clojure 1.5 blows up swank. great.
00:43Sgeobrainproxy, I'm not entirely focused on this, so not entirely processing.
00:43tomojI have a function that takes a map or vector and returns the same
00:43brainproxySgeo: no problem, sorry to jump all over you with this stuff
00:43tomojbut if I get another associative emptyable, it may fail
00:43amalloylynaghk`: only the latest alphas, right?
00:43lynaghk`amalloy: only the ones I've tried
00:43tomojjust wondering if there are other interesting cases to worry about
00:43lynaghk`4 and 7
00:44brainproxySgeo: anyway, maybe some other time we can look at it together
00:44amalloyi haven't tried since 2 or 3
00:44Sgeobrainproxy, ok
00:44brainproxySgeo: I do appreciate your input thus far, and it's good to see you back online
00:44lynaghk`amalloy: yep, the extra dots are still a problem in clojure 1.5
00:44Sgeobrainproxy, you're welcome, and thank you :)
00:44SgeoIt
00:44SgeoIt's good to be back online lol
00:45amalloylynaghk`: it's easy to find the code that makes them break
00:45amalloyclojure.lang.LispReader$CtorReader checks for the presence of . in a #foo tag, and decides it's a defrecord literal if it finds one, or a tagged literal otherwise
00:46amalloyso it's clearly something rich did on purpose
00:47amalloyor...maybe not? all that code was checked in by stuart sierra
00:47lynaghk`amalloy: There's java class reader syntax. I still think it's a bug; it should check if it's in *data-readers* first. If not, then try to init a java class.
00:47amalloyi agree
00:48lynaghk`amalloy: you have a file and line number where this code is?
00:49amalloysure. 1171 of LispReader
00:49lynaghk`amalloy: thanks.
00:50amalloygood luck with your jira ticket (i assume)
00:59brainproxywhere is *warn-on-reflection* implemented?
01:00amalloybrainproxy: find clojure-src -type f | xargs grep warn-on-reflection
01:01brainproxyamalloy: thanks
01:05tomojI presume datomic.db.Db#with gives index performance as good as for Db's acquired from storage?
03:14tomojyes, it seems Db#with is fast as expected :D
03:15tomojso you can just Db#with some extra schema for derived indices, then Db#with the data and get much faster queries than joining on the output of query fns
03:15shachafD-flat-sharp?
03:15tomoj:) datomic.db.Db, instance method 'with'
03:49caspercanyone got a tip for getting a clojurescript browser repl up and running? Seems no matter what I try the repl seems to hang, or not connect properly.
03:50caspercusing cljsbuild btw
03:51lpvbwhat is the difference between clojure-slim.jar and non-slim?
04:16wingywhat do people mean by redundant storage?
04:17Rayneshttps://www.refheap.com/paste/6380 Yay for first useful Haskell I've written in probably 3-4 years.
05:04luxbockhas anyone got 'comint' working with nrepl in Emacs?
05:05luxbockI used that with the Python shell and it worked fine, but I don't know how to enable it with nrepl, or if that's even possible
05:06luxbockor if there's any other way to cycle through previous inputs to the nrepl through keyboard schortcuts
05:34ivanluxbock: don't want to use nrepl.el?
05:34shachafhi ivan
05:34shachafAny lenses in your recent past or near future?
05:34ivanHaskell lenses?
05:35shachafOr any other kind.
08:18gensymvhello, i was searching for the actual version of the clojure.contrib complex-numbers module. a google/clojars search turned out nothing.
08:18gensymvdoes the module still exist?
08:24raekgensymv: it doesn't look like it has been "picked up" by anyone: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
08:30gensymvraek, so it's at best obsolete now?
08:34ejacksongensymv: in effect, yes.
08:36raekgensymv: it is a library that no one has touched for more than two years
08:39gensymvthanks folks.
08:53snake-johnHi , I wanted to play with clojure.core.reducers. my first try is (reduce + 0 (reducer [1 2 3 4] (map inc)))
08:53snake-johnbut I get a ClassCastException clojure.core.reducers$folder$reify__966 cannot be cast to clojure.lang.IFn clojure.core.protocols/fn--6051 (protocols.clj:98)
08:53snake-johnany hints on what I'm doing wrong?
08:56ejacksonsnake-john: on the whole you don't want to use reducer itself, but the sugar around it
08:57ejacksonso something like (r/fold + (r/map inc [1 2 3 4])) should do it
08:58snake-johnejackson : ok thank you that works!
08:59ejacksoncheck out the talk by rich on it. Its much clearer than the blog posts
09:00snake-johnthe one on infoq Reducers - A Library and Model for Collection Processing
09:01ejacksonis it an hour long ?
09:01ejacksonthat' the one you want
09:02ejacksonthat's the one. yeah
09:04snake-johnthank you! i get myself a coffee and listen to it!
09:07ejacksonenjoy - its quite a trip!
11:56hughfdjacksonto those that recommended clojurebook.com to me yesterday, thanks :D 1/4 of the way through using kindle's online reader, and it's great so far
12:01octagonis there a way to override private function defs in clojure?
12:01octagoni mean i want to be able to access a function defined using defn-
12:04technomancyoctagon: yeah, you can go through its var
12:05technomancy(#'whatever.ns/f ...)
12:06octagontechnomancy: that's interesting, thanks
12:28xeqihughfdjackson: awesome; you might consider tweeting @cemerick/@clojurebook that you're enjoying it
12:28hughfdjackson^^ grand idea
12:50clojure-newbhey guys, it was a little quiet on the datomic channel, so I thought I'd ask in here... is it possible to assign a new attribute value to all entities matching a given filter ?
12:50clojure-newbI've only seen updates that use entity id's so far
12:51clojure-newbor unique attributs values, and I have neither
12:51redline6561lein-noir doesn't seem to work with leiningen 2.*. Is there a simple workaround for this?
12:52redline6561Whoops. It's on the lein-noir github page. Nevermind me.
12:52technomancyredline6561: I think that plugin just handles skeleton generation?
12:53technomancy(apart from the obvious glib "use compojure" answer)
12:53redline6561That's correct. The lein-noir README addresses the issue, it's just not on the homepage.
12:53redline6561Is Compojure pretty dominant usage-wise?
12:53technomancyit's the best
12:54technomancynoir uses it anyway under the covers, so yeah, pretty much everyone uses it
12:54hughfdjackson"A zipper is not unlike Ariadne's thread; which helps Theseus to find his way out of the Labyrinth after having killed the Minotaur" <- aah, love it when books do that
12:58redline6561technomancy: Is there a preferred "here's the clojure web stack" resource?
12:58technomancyredline6561: sure, this is a bit old but pretty comprehensive: http://brehaut.net/blog/2011/ring_introduction
12:59redline6561Perfect. Thank you.
13:04hughfdjacksonzip has lift (e.g. z/vector-zip), return (z/root) and bind (or a sort, using generic 'piping' via the `->` macro)
13:04hughfdjackson:p would i be way off the mark if i said i smelled a monad?
13:09gfrederickshughfdjackson: written a lot of haskell?
13:10hughfdjacksonnup
13:10gfredericksnup = no * yup ?
13:10hughfdjacksonhaha
13:10hughfdjacksonsorry, no
13:10hughfdjacksoni've read up on it, and played around, but nothing beyond that
13:10hughfdjacksoni found it quite inpenetrable
13:11gfredericksah okay; my single datapoint is that doing something nontrivial in haskell brings the monads much closer
13:11hughfdjacksonclojure seemed a bit of an easier stepping stone to the dark side ;) (from js)
13:11gfredericksyeah that's probably true
13:12hughfdjackson:D searching around, it seems like i was wrong about zippers anyhow
13:12hughfdjackson(being monads)
13:17hughfdjackson:D even if they don't help me understand monads, they're awesome at least
13:21octagonis there a document somewhere describing the hooks available to a plugin in leiningen, and examples of using them?
13:21gfredericksI think all lein tasks are simple functions that you can wrap
13:22octagonthere is a section about "hooks" in the plugin guide, but i can't make heads or tails of it
13:23gfredericksin /doc/PLUGINS.md?
13:23octagoni'm having troubles with classpath issues in my leiningen plugin, and i think maybe i need to be hooking into a hook
13:23octagonyes, that one
13:24gfredericksso you're not trying to hook anything in particular, you're just thinking that will fix your classpath problems?
13:24octagongfredericks: the first thing would be to see which hooks i can hook into, and see if any of them look promising :)
13:25gfredericksall lein tasks
13:25gfrederickswhich `lein help` lists
13:26octagonah ok thanks
13:29xeqioctagon: you can hook any function
13:29xeqias an example, I'm hooking deep into a private method with lein-pedantic; https://github.com/xeqi/lein-pedantic/blob/master/src/lein_pedantic/plugin.clj#L76
13:29xeqinot recommended for private ones, but I think most public things in leiningen-core should be stable
13:30octagonxeqi: thanks that's interesting
13:32octagonxeqi: what's the purpose of that hook?
13:32xeqioctagon: best described in the example on https://github.com/xeqi/lein-pedantic
13:33octagonxeqi: cool thanks!
13:37xeqioctagon: I'm not sure a hook is the right spot for classpath issues in a plugin though. Most plugins that need another dependency in the project usually have a task that modifies the project
13:38xeqifor example, https://github.com/technomancy/swank-clojure/blob/master/lein-swank/src/leiningen/swank.clj#L68
13:39octagonxeqi: yeah i am still a little confused by the different environments in which code is evaluated in lein
13:40xeqioctagon: might take a look at https://github.com/sattvik/leinjacker as well
13:40octagonxeqi: i think i might actually have a simpler problem in my particular case, which looking at your link reminded me of: i have a overruled dependency issue actually
13:41octagonxeqi: leinjacker looks cool, thanks
13:42xeqiI've got to run, hope you can figure out your problem
13:42octagonxeqi: thanks for your help!
13:42xeqiyou could also ask in #leiningen, though I think most people there sit in here as well
13:57daniel__what could be causing this error when running lein repl? I/O exception (java.net.SocketException) caught when processing request: Connection reset
14:01daniel__i can launch a lein repl :headless and then connect to it from another window...
14:01daniel__any ideas whats the matter with lein repl anyone?
14:13RaynesI love Haskell. "recurseDir "/Users/raynes/code/fsutils" >>= mapM_ print"
14:13RaynesIt's like everything is (->> x y z)
14:14RaynesI forgot how much fun it was to write >>= and </> and such.
14:27muhooi sat in a clojure dojo on ztellman's team, and watched him do the whole program using ->> all the way through. i adopted the style immediately afterwards.
14:28muhoofelt comfy, like "ls | grep | sed | awk | tee | foo"
14:34daniel__what could be causing this error when running lein repl? I/O exception (java.net.SocketException) caught when processing request: Connection reset
14:34daniel__i can launch a lein repl :headless and then connect to it from another window...
14:42daniel__can i add a dependency to a project with a relative path? i have two separate projects /backend and /api and want them to talk to each other
14:48daniel__anyone here?
14:51raekdaniel__: you can't with "vanilla" leiningen
14:52raekare the projects two parts of the same application?
14:52daniel__yep raek
14:52raekI think it would be simpler to divide the code into two separate source directories instead
14:53raekeach project usually has its own release cycle
14:53raekand version numbers
14:53daniel__hmm ok
14:54raekI see some ways to split up the project:
14:54raek1) keep code in src/foo/backend src/foo/api (effectively one project)
14:55raek2) keep code in backend/src/foo/... and api/src/foo/... (and add :source-dirs ["backend/src" "api/src"] to the project.clj)
14:56raek3) actually make two separate projects and develop them in lockstep. use the "checkouts" feature so that uncommitted changes in one of the projects can be seen in the other
14:57raekdepencency names are not necessarily releated to any path structure
14:59raekdaniel__: there is also lein-sub (which I haven't tried myself)
15:00daniel__source-dirs looks like what i wanted, thanks
15:00daniel__i guess that can be a relative path like "../backend/src"
15:02devnmuhoo: do you have the program you're referring to hanging out in git somewhere? (the one you said zach did exclusively with ->>)
15:02devnid be curious to look at it
15:04daniel__i cant find source-dirs in the sample project.clj file, is it an old example? https://github.com/technomancy/leiningen/blob/master/sample.project.clj
15:05raekdaniel__: leiningen encourages repeatability and does therefore avoid paths pointing "out of the project" or to files "downloaded at the side". consider what happens if someone else needs to check out your code.
15:05raekif a project follows leiningen's approach then things will "just work"
15:05raekread more at: https://github.com/technomancy/leiningen/wiki/Repeatability
15:06raekdaniel__: which version of lein? the option was called ":source-dir" in leiningen 1.x
15:06daniel__lein 2
15:06raekdaniel__: oh, sorry. my bad. it should be :source-paths
15:06daniel__thanks
15:06daniel__ill consider all the options
15:07raekanyway, I would recommend 2)
15:07daniel__i dont think anyone will be checking out one project without the other, everything is inside a single git repo
15:07daniel__i also have a sinatra app living under frontend
15:07raekor perhaps not splitting it up at all
15:07daniel__i'd rather split them up in case i want to experiment with refactoring one component in another project/language
15:08daniel__its also seems like a much cleaner and intuitive directory structure
15:09daniel__maybe i will move the project.clj back to the parent dir though
15:09daniel__and configure that paths like that
15:24luxbockis there a way to disable nrepl from spewing the entire error trace when something goes wrong in Emacs? I could do with just a single line error when tinkering around with some stuff
15:34luxbockfound it, (setq nrepl-popup-stacktraces nil), seems to do the job
16:04xeqianyone have a prebuilt wrap-contexted-resource ?
16:07xeqisomething better than https://www.refheap.com/paste/6384
16:22twobitsp1itegood afternoon/etc
16:22twobitsp1iteso, I'm going through the clojure tutorial, and I'm a bit confused on the difference between let and binding... anyone mind helping me understand the difference?
16:24twobitsp1iteahh, nevermined... I should have just kept reading... :P
16:44schaeferhi. i'm trying my hand at the new core.logic domains. i want to find the largest value in a domain but am stumped. any help?
16:52dnolenschaefer: hmm, there's not really a way to do that.
16:53schaeferi think the thing i'm struggling with is the conceptual difference between intervals and regular lists/seqs.
16:53dnolenanybody tried CLJS w/ latest Closure Lib I think it's the only thing holding up a release.
16:54schaeferi want to do something like (membero q interval-lvar). from there, i think writing maxo is straightforward
16:54schaeferi suspect that there's no notion of membero for domains for some reason that i don't yet understand
16:55Bronsada quanto tempo ormai sappiamo che non fa per noi
16:55Bronsawrong chan again.
16:55dnolenschaefer: membero is implicit
16:55dnolenschaefer: and no domains are not like lists at all
16:56schaeferwhat does that mean "membero is implicit" ?
16:56dnolenschaefer: a var with a domain will range over it's domain
16:56technomancymuhoo: how does that work with having "teams" at a clojure dojo?
16:57technomancyis it like a competition where groups independently implement a given exercise?
16:58dnolenschaefer: I strongly recommend reading Finite Domain Constraint Programming In Oz, google for the pdf, it's free to download
16:59dnolenschaefer: it'll give you a conceptual model of how the domain functionality is intended to be used.
16:59schaeferdnolen: ah, that was going to be one of my next questions
17:00dnolenschaefer: be warned you'll likely encounter bugs, implementation details are still in flux and I'm going through that tutorial myself to verify core.logic's behavior.
17:00schaeferdnolen: cool.
17:01schaeferdnolen: i'm trying to write a logic program to compute the layout of cells in a table given constraints. a range of cell sizes is possible and, for aesthetic reasons, i want the program to maximize the cell size. right now, i'm expressing the cell sizes as intervals but, perhaps, that's the wrong approach
17:02dnolenschaefer: sounds reasonable - bin packing, Oz Tutorial covers it
17:02schaeferdnolen: excellent. looks like i've got some reading to do. thanks!
17:07tomojfor groups at a dojo, maybe something like speed dating?
17:07tomojless competitive, you get to work with a bunch of different people and see more of the various solutions people are coming up with
18:16daniel__anyone any idea why im ending up with \ characters? is this some weird conversion from Java?
18:16daniel__i mean, they aren't \n or \space, just \
18:19antares_clojure-doc.org now has a tutorial on VimClojure: http://clojure-doc.org/articles/tutorials/vim.html
18:21tomojdaniel__: give an example?
18:22amalloy&(char 4)
18:22lazybot⇒ \
18:22amalloycontrol characters may print oddly based on your terminal
18:32technomancymerged the latest nrepl stuff for clojure-test-mode; would appreciate feedback on it before I cut a release
18:46twobitspriteok, some I'm new to clojure and leiningen... but I'm trying to figure out how to get the lein repl command to include my core.clj definitions in the repl...
18:48twobitspriteI just have (def test 42) in my src/my-proj/core.clj, and I run lein repl from the base of the project tree, and I've tried "test", "my-proj/test" and "my-proj.core/test"... I also tried lein compile, but it says they're not marked AOT
18:48twobitspritethe lein tutorial doesn't say a whole lot about the repl
18:49arkxtwobitsprite: did you try to require that namespace in the REPL?
18:51amalloyyour file needs to be in my_proj/core.clj
18:51amalloyif you create a project with lein new, it names things right for you
18:53twobitspriteamalloy: I did create the project with lein, and it put it in src/my-proj/core.clj
18:53twobitspritearkx: I did... it gives me ClassNotFoundException
18:54amalloyi know for a fact the latest version of leiningen doesn't do that, and i doubt if any version in years has. regardless, you need to rename the directory
18:54raektwobitsprite: are you using an old version of lein? it should have created the file in my_proj, not in my-proj
18:54raekhyphens in namespace names are underscores in the path
18:55twobitspriteohh... well, it's not actually my-proj... it's something else, I'm just redacting... there are no hyphens or underscors in my project name
18:55raektwobitsprite: how does the require look like? (require 'my-proj.core)?
18:55raekthe error could be from a missing quote
18:56twobitspriteahhh, that's the problem, thanks :)
18:57amalloysuggestion: when asking for help about something you don't understand, don't redact: you probably don't know what's relevant and what isn't
18:58twobitspriteactually, I think I learned more by doing so :P i.e., I didn't previously know namespaces couldn't have hyphens :)
18:58arkxThey *can* have hyphens, and often do. :P
18:58amalloywell, they can. but the file/directory names mustn't
18:59twobitspriteahh, right
19:00twobitspriteand I was just thinking to myself that using underscores in symbol names seemed fairly un-lispy
19:00twobitsprite:P
19:02twobitspriteok, so next question... how do I get it to reload the source file? i.e., I edit the file, and want to see the changes in my repl?
19:02amalloy(require 'blah :reload)
19:02twobitspritesweet, thanks
19:03twobitspriteok, back to tutorial reading :)
19:26ForSparePartsSo, I have a namespace with a bunch of helper functions that I want the user of my library to have access to, but they assume that a certain function has been defined already -- something the user has to write in the file that'll use these helper functions.
19:27ForSparePartsI was just going to have a stand-in def'd to nil, but the compiler complains about collisions when I bring in the helper functions with use, and then try to override it
19:27ForSparePartsis there a good way to do what I'm trying to do here?
19:30SgeoSounds like you'e looking for declare, but also sounds like there's likely to be a better solution to your problem
19:30SgeoHave those functions refer to some dynamically-scoped variable, perhaps?
19:36ForSparePartsSgeo, I looked up dynamic scoping, and it seems like it'd do the trick.
19:36ForSparePartsIs that sufficiently Clojure-y, though?
19:36ForSparePartsI'm worried that I'm making my library too stateful.
19:38SgeoSeems more idiomatic than relying on the user to def at a certain name, but if you can find a way to not have the requirement, say, asking the user to pass in the function in question somewhere, that would probably be even more ideal, unless it would cause a lot of repitition perhaps
19:41ForSparePartsI think I may have made a mistake somewhere: how does dynamic scoping prevent me from requiring the user to def a specific name? I thought it was just a built-in way to allow a name to be re def'd?
19:47SgeoWell, yeah, it's to a specific name, but it's ... cleaner/less permanent
19:47Sgeo(binding [*some-dynamic* some-value] blah blah blah) outside of that form, *some-dynamic* will be back to its old value
19:47ForSparePartsOK.
20:06algernonsuppose I have a map, I want to remove one elment, and add another, which would be more idiomatic? using (assoc (dissoc foo :key) :new "bar") or (-> foo (dissoc :key) (assoc :new "bar")) ? (or perhaps something completely different)
20:22scottjalgernon: both are fine. using -> is personal preference. I'd say it's only slightly longer in this case.
20:23algernonscottj: thanks!
20:31amalloylonger or shorter isn't really the point. -> is best here because it keeps the dissoc-related arguments next to the symbol dissoc, and similarly for assoc. it also makes it clear that the "focus" of this operation is the map foo
20:41muhoodevn: i'm pretty sure it's in his github/gist history
20:43muhootechnomancy: there's a problem, teams of 3-4 people are chosen @ random, time limit on solution, presentation of solutuions at end of night. fun
20:43muhoothis particular one was barcode scan decoding, IIRV
20:43gfredericksdisappointing that *print-meta* has no effect on pprint :/
20:43muhooIIRC even (damn gw keyboard)
20:44muhoog2 keyboard. mofo
20:44amalloymuhoo: no, i like the typo. "If I recall verily" makes you sound very posh
21:08muhooindubitably
21:57brainproxyso... suppose I have a lazy sequence which is the product of a map, and a few steps into it there is something that will cause it to "blow up"
21:57ForSparePartsIs it possible to pull in a function from another namespace with :use and then use that function as my init for gen-class?
21:58ForSparePartsWhen I try, Java complains that -init isn't there at runtime.
21:58brainproxynow suppose that the first member of the sequence is not something that will cause a problem, perhaps a computation that will return the long 123
21:58brainproxyit seems that in some cases I can (first mylazyseq) just fine
21:58brainproxyand in other cases I can't
21:58bbloombrainproxy: that has to do with sequence chunking
21:58brainproxybbloom: i see
21:59bbloombrainproxy: in some cases, operations are applied somewhat eagerly to a chunk of the sequence
21:59brainproxybbloom: in both cases when I (class mylazyseq) I just get clojure.lang.LazySeq
21:59brainproxyi.e. there is no indication of an innerclass
21:59brainproxyi.e. denoting "chunked"
22:00brainproxybut maybe that's irrelevant
22:00brainproxyin any case, thanks for letting me know; I now have some idea what's happening
22:01bbloombrainproxy: sorta irrelevant
22:01bbloomLazySeq wraps a thunk function
22:01bbloomwhich itself contains the chunks
22:02brainproxy`(->> (map (fn [a] (a)) (list #(/ 1 1) #(/ 1 0) #(/ 1 2))) (cons 123) (drop-while #(= % 123)) first)
22:03bbloomseems link the default chunk size is 32
22:03brainproxyoh it's &
22:03brainproxy&(->> (map (fn [a] (a)) (list #(/ 1 1) #(/ 1 0) #(/ 1 2))) (cons 123) (drop-while #(= % 123)) first)
22:03lazybot⇒ 1
22:03brainproxyin that case it works fine, no blow up
22:03brainproxybut I have something that looks almost exactly like that which does blow up
22:04brainproxyand the list containing the thunks has only two things in it
22:04brainproxyi.e. it's not very big
22:05bbloombrainproxy: size doesn't have much to do with it. if you're getting a chunked seq for fewer than 32 items, you'll have a single chunk
22:05bbloomso up to 32 items will be evaluated all at once
22:06brainproxy32 being the number of??
22:06bbloomtry #(-> % seq class)
22:06lazybotbrainproxy: What are you, crazy? Of course not!
22:06bbloom,(class (seq (range 5)))
22:06clojurebotclojure.lang.ChunkedCons
22:06bbloom,(class (seq [0 1 2 3 4]))
22:06clojurebotclojure.lang.PersistentVector$ChunkedSeq
22:07bbloom,(class (seq (list 0 1 2 3 4)))
22:07clojurebotclojure.lang.PersistentList
22:07bbloom32 is the chunk size
22:08bbloomanyway, you can work around the problem by including a try/catch and a sentinel value
22:09bbloomor test against zero
22:09brainproxycool
22:10bbloom,(let [div (fn [x y] (if (zero? y) :zero-denom (/ x y)))] (map #(apply div %) [[5 10] [3 2] [4 0]]))
22:10clojurebot(1/2 3/2 :zero-denom)
22:11brainproxybbloom: i gotcha, in this case it's more about figuring out why sometimes something was lazy "as expected" (though naively) and sometimes not
22:11bbloombrainproxy: performance :-)
22:11brainproxyi actually have a variant of the functionality which is completely lazy, for those times when you just have to have the whole computation be lazy
22:12bbloombrainproxy: basically, you're lazily operating on 32-item chunks
22:12brainproxybut it was the "non lazy" version, which was sometimes lazy and sometimes not, which was puzzling
22:12bbloomitem 33 and on won't be computed until needed
22:12brainproxybbloom: i gotcha
22:12brainproxythanks for your help!
22:12amalloytry/catch!? that's a pretty unpleasant solution
22:12amalloyjust un-chunk the sequence before you start doing dangerous stuff to it
22:12bbloomamalloy: hence i suggested the test against zero :-P
22:13bbloomamalloy: is there an operator to unchunk?
22:13amalloyno, but a function to do it is trivial
22:13mudgehello
22:14amalloy(defn unchunk [xs] (lazy-seq (when-let [xs (seq xs)] (cons (first xs) (unchunk (rest xs))))))
22:15bbloomamalloy: that calls first on the seq, which causes the first chunk to be traversed, which blows up.... see above converstaion
22:15amalloybbloom: you unchunk *before* you do the dangerous operation
22:16bbloomamalloy: *shrug* i'd just rather treat all exceptions as programming errors :-)
22:16amalloy(take 5 (map dangerous-function (unchunk coll)))
22:16amalloybbloom: doesn't matter; you've only solved a sub-problem. what if instead of throwing an exception, f takes an unlimited amount of time and never returns?
22:16bbloomnon-termination is also a programming error ;-)
22:16amalloyor prints something to the terminal that you don't want printed
22:38SgeoI should write a thing to parse Tcl stuff
22:38SgeoOh hmm this is a thing that exists http://en.wikipedia.org/wiki/Tcl/Java
22:43sliferguys i need help
22:43sliferwhy do i always get this error
22:43sliferNo 'xpc' param provided to child iframe
22:43sliferwhen i try to connect to clojure
22:43sliferthrough web
22:44sliferhttp://localhost:9000/repl
22:44sliferi start the repl with this code :set REPL_CLJ="(require '[cljs.repl :as repl])(require '[cljs.repl.browser :as browser])(repl/repl (browser/repl-env))"
22:45slifer why do i always get this error : No 'xpc' param provided to child iframe
22:47sliferNo 'xpc' param provided to child iframe with repl
22:58wingyso sick .. my test file is 2500 lines long
22:58wingyone single service
22:59wingygood thing i used midje though .. or it wouldn't even be readable https://www.refheap.com/paste/6393