#clojure logs

2015-04-03

01:46mordocaiI have an error with trying to create a schema for a record from another namespace. I'm importing it but still no go. What am I doing wrong? https://github.com/mordocai/clojure-maildir
01:46mordocaiError shows up when compiling schemas.clj
01:56mordocaiUgh, laptop is way too aggressive at turning off wifi. If anyone answered my query I missed it.
01:58mavbozomordocai: records initialization should be Email. or ->Email or map->Email
01:59mavbozomordocai: or maybe that's how scema.core works
02:00mordocaimavbozo: Yeah, AFAIK when specifying a record for a schema you are supposed to give the raw record not an initialized one. It appears to actually be erroring on the import btw.
02:05mavbozomordocai: what's written in the error message?
02:12mavbozomordocai: i cloned your repo and change the import line to (:import [clojure_maildir.records Email])
02:12mavbozothe schemas.clj compiled
02:13mavbozoalthough I got another error: No such var: records/->Email, compiling:(clojure_maildir/core.clj:22:5)
02:16mordocaimavbozo: Ah, just got my error in a pastebin. https://www.refheap.com/99187. Thanks for the import correction! I'll work on the next error.
02:22mordocaiExcellent, those errors are all fixed! Thanks for your help!
02:27justin_smith~next
02:27clojurebotIt's greek to me.
03:02guthurIs there a way to reload a project.clj in cider/nrepl
03:02guthurI have added a dependency and would like it loaded
03:03justin_smithguthur: sure, if you use pallet/alembic
03:03justin_smithor even pomegranate (but alembic is easier, it has a "load-project" function that does what you want)
03:03jonasenguthur: I usually do M-x cider-restart
03:04jonasenguthur but that restarts everything I think
03:04justin_smithyeah, that shuts down your repl and makes a new one
03:05guthuryeah i figured restart would work
03:05guthurI will check out alembic and pomegranate
03:06justin_smithguthur: a good cantidate for putting in ~/.lein/profiles.clj under :user {:dependencies [ ... ]}
03:06justin_smiththat, criterium (for benchmarking functions for speed) and tools.trace (for debugging)
03:07guthurjustin_smith: yeah just in the process of adding it
03:15TEttingerhm, so, I have some questions for #clojure's masters of the immutable
03:19TEttingerif I were to make a new def-like macro that defines a symbol as being a "state variable" (not sure what to call it, really, but the idea is, any changes to any state variable update the same global collection that stores all state variables, increment a version number, append the new state to a list of remembered states)...
03:20TEttingerI basically have an append-only log of immutable historic states
03:21TEttingerbut I want to be able to jump back to previous states, assigning the current state the value from an earlier version
03:24TEttingerI'm just not sure how all this will work
03:39TEttingercfleming, I have a bit of confusion regarding the behavior of Cursive and lein projects with -main
03:40TEttingerit seems like right clicking a file or project and telling Cursive to Run a given module just does nothing and exits after a few seconds
03:40TEttingerI must be missing something
03:40TEttingerI'm on 13.1
03:49guthurI'm trying to use https://github.com/xsc/ancient-clj
03:50guthurif i require [ancient-clj.core :as ancient] i get the following exception...
03:50guthurCould not initialize class com.amazonaws.ClientConfiguration
03:51guthurany suggestions
03:53TEttingerguthur, it looks like ancient-clj depends on a com.amazonaws lib https://github.com/xsc/ancient-clj/blob/master/project.clj#L10
03:54TEttingerbut it must be doing something as soon as it's read
03:54guthurTEttinger, yeah, does lein not grab those
03:54TEttingera very old lein version wouldn't
03:54TEttingeran... ancient lein version :P
03:54guthuri'm pretty much upto date
03:54guthurLeiningen 2.5.1 on Java 1.7.0_75 OpenJDK 64-Bit Server VM
03:57TEttingerand the only stuff that actually is run by including ancient-clj.core seems awfully small
03:57TEttingerhttps://github.com/xsc/ancient-clj/blob/master/src/ancient_clj/core.clj#L9-L17
03:58TEttingerah, that was added fairly recently though https://github.com/xsc/ancient-clj/commit/15b508f5ee5bd6212020b434a438ecaa8086567b
04:03guthurmaybe i will try and earlier verson
04:04TEttingerthat was sept 2014
04:05TEttingerif a version from august or earlier works, that might be an interesting issue to report
04:05sveriHi, I just tried out core.typed and started annotating a namespace with two functions. I am calling a few other libraries there which are not under my control and it turns out I have to annotate each other function call I am doing into a different library? It makes sense following the logic of typing. How do people handle this? I mean, does it make sense to to collect external library annotations in a central place so I can access it
04:07TEttingerI'm curious about how that works in practice too, sveri, but I haven't used core.typed
04:07sveriTEttinger yea, I have a helper library and I think about making a namespace with just lots of annotation definitions that I need somewhere else
04:08TEttingerI wish there was some way to automate that, but I don't see how it could work
04:08TEttingerI guess some kind of type inference could be used if it had a basis of how they are used
04:09sveriTEttinger maybe a github repo makes sense too where people can contribute type definitions..
04:09TEttingeryep
04:11sveriI will ask on the core.typed mailing list what people think about that and maybe start one
04:14sveriI just looked at some github repo and found this: (ann ^:no-check clojure.java.io/writer [Socket -> BufferedWriter]) this is exactly what I mean, I guess so many people will have this line somewhere in the code...the duplication will be immense
04:18sveriTEttinger In case you want to follow: https://groups.google.com/forum/?fromgroups#!topic/clojure-core-typed/nrHx_1XO9cc
04:39expezhow do I add the character literal ( to a clj file?
04:39expez\( doesn't work and neither does \\(
04:40dstocktonnot sure what you mean expez
04:40dstocktonwhere in a clj file?
04:41expezdstockton: I want to compare against the character literal (, but I can't eval the code. I thought \( was the right way to do this but cider is barfing on an unmatched delimiter
04:42dstocktonmight be a cider issue, \( works fine in the repl
04:42oddcully,(= \( \()
04:42wagjo,\u0028
04:42clojurebot\(
04:42clojurebottrue
04:43wagjoexpez: you may use \u0028 as a workaround
04:43oddcully,(= \( \u0028)
04:43clojurebottrue
04:44expezsubmitted a ticket. going with workaround for now. Thanks!
04:51TEttinger&(map char "()[]{}")
04:51lazybot⇒ (\( \) \[ \] \{ \})
04:51TEttinger&(map int "()[]{}")
04:51lazybot⇒ (40 41 91 93 123 125)
04:51TEttingerhm
04:52TEttinger&(map (comp #(format "%04X" %) int) "()[]{}")
04:52lazybot⇒ ("0028" "0029" "005B" "005D" "007B" "007D")
04:52TEttinger&(map (comp #(format "\\u%04X" %) int) "()[]{}")
04:52lazybot⇒ ("\\u0028" "\\u0029" "\\u005B" "\\u005D" "\\u007B" "\\u007D")
04:52TEttingerthere you go, all the brackets that might mess cider up
05:03cflemingTEttinger: Hmm, I'm not sure about the autodetection there - what you want is to go to Run->Edit Configurations and create an Application configuration
05:04TEttingerI checked that
05:04TEttingerI have one made
05:04cflemingWhat happens when you run it?
05:04TEttingerbut it isn't... doing anything. and I don't see where to call -main
05:04TEttingerit doesn't print anything because it is supposed to open a window, but no window opens
05:04TEttingerif I call -main in the repl, I get the window just fine
05:05cflemingIn that run config, you enter your main class - that should be the class generated from your main ns
05:05TEttingerif I terminate the repl and try to open again, Cursive throws an exception (I submitted a bug report)
05:06cflemingTEttinger: You did? I don't think I saw that
05:06TEttingerit was less than an hour ago
05:06cflemingTEttinger: Oh, you mean an exception report, not an issue
05:06TEttingeryes
05:06cflemingRight, I haven't checked those
05:06cflemingCan you send a screenshot of your Application run config?
05:07TEttingerthe options for the run config are "script path", where I have the file path to the clj
05:07TEttingersure
05:07cflemingOk
05:07cflemingHang ok
05:07cflemingHang on
05:07cflemingYou're talking about a Clojure Application config
05:08elvis4526Is there a way to provide a default implementation for a method when using protocols ?
05:08TEttingercfleming, correct
05:09cflemingYou use that one if you have a Clojure script to run, once you're using -main you're in Java land really
05:09cflemingAlthough that config should handle it (there's an issue in the tracker for it)
05:09TEttingershould I just add a call to -main at the end?
05:10cflemingThe config you want is just called Application, it's what you'd use if you were running a Java program
05:10TEttingerah! ok
05:11cflemingSorry, this is old code and more confusing than it should be, I'm planning to fix it soon as I re-vamp the run config stuff
05:12TEttingernope, Application doesn't recognize anything in my project as a main type
05:12TEttingermain class, rather
05:12TEttingerit's not a big issue, I should be doing more from the REPL anyway
05:13TEttingerbut it was certainly an early stumbling block
05:13cflemingAre you using :gen-class?
05:14cflemingYeah, it's surprising how infrequently people use -main, which is why I've never prioritised fixing it, but it's pretty nasty right now
05:15TEttingeryeah, I have :gen-class in the ns
05:16TEttingerthanks for the quick reply!
05:16TEttingerother than being very confused by structural editing, I've been pretty happy with Cursive so far
05:16cflemingOk, so I think there' s a problem where Cursive doesn't correctly publish the main method in the class generated from the namespace
05:16TEttingerah!
05:17cflemingGive me a sec
05:17cflemingWas that confusion about structural editing in Cursive specifically, or do you just not use it?
05:20TEttingerI've never used structural editing before, I couldn't turn a variable into a call that uses that variable, so I ended up with all this weirdness trying to stick a paren in the middle of a form...
05:20TEttingerI had something like, let's say (* width height), and I wanted to change it to (* (/ width 3) height)
05:21TEttingerit let me add the first paren, but any time I typed ), it closed a much later form
05:22cflemingOk, did you figure out how to turn it off?
05:22cfleming(might be best until you get more used to Cursive - just learn one new thing at a time :-) )
05:23TEttingeroh yes, I turned it off right away
05:24cflemingSo I just ran a main method, here's how: I used the Application config, you're right that it doesn't find the main class, I'll fix that. But you can type in the class anyway, which is basically your namespace name with dashes replaced with underscores
05:24cflemingIt'll warn you that the class doesn't have a main method, but you can ignore that
05:24cflemingAre you using Leiningen?
05:24TEttingeryes
05:25TEttingerI imported a project by finding my existing project.clj
05:25cflemingOk
05:25cflemingOne thing you should check if you're using AOT is that Cursive is set to compile your namespace - it doesn't autodetect the ones it should compile yet
05:25TEttingeroh, and just calling -main at the toplevel works for now
05:26cflemingThat's under Settings->Build etc->Compiler->Clojure Compiler
05:26cflemingOk. I'm actually working on a bunch of run/execution stuff right now, I'll see if I can fix this for the next build
05:28TEttingergreat, thanks!
06:56noncomanyone using neo4j + neocons here?
07:36unindentedis there a way I can run all :test assertions for my module functions when executing `lein test`?
07:36unindentedI mean these kinds of assertions: http://clojure.org/special_forms
08:03borkdudeI want to change something in a database and upload something to s3. this has to occur in a synchronized fashion. maybe this is where "(locking ...)" comes in
08:03borkdude?
08:04borkdudethere may be a race condition when I don't lock
08:56guthuris there a way to force the output of print when printing to the shell
08:56guthurin CL you would use terpri
08:57guthurI am wanting to prompt and accept an input
08:57guthurbut unless i use println the prompt will not show
09:10guthurah, the answer was (flush)
09:56gfredericksthis thing with iterate is so complicated
10:39justin_smithTEttinger2: regarding your history of states: make "place in state history" one of your history-tracked states of course :)
10:39justin_smithTEttinger2: that way you can walk not only history, but history of backtracking history
11:05mikerodWhy would I get UnsupportedClassVersionError Unsupported major.minor version 51.0 types of exceptions running clojure 1.6 things in Java 7?
11:05sobelthx to whomever turned me onto Robert.Hooke yesterday
11:05mikerodI was under the impression that clj 1.6 was fine in Java7
11:05mikerod specifically I got this compiling cider/nrepl/middleware/util/java/parser.clj
11:05sobeli'm cross-cutting through orthogonal concerns like butter
11:07justin_smithmikerod: odd
11:07justin_smithmikerod: usually jvms are really good at keeping these things compatible
11:08mikerodjustin_smith: Java 7 does have a change in class format with JSR 202 https://jcp.org/en/jsr/detail?id=202
11:08mikerodhowever, I thought many people were running Clojure fine in this Java version (pretty sure)
11:09mikerodand this is JIT compiling - if it were AOT I may be more likely to understand having an issue
11:09puredangerclojure 1.6 works perfectly fine with java 7
11:09justin_smithyes, I have used 1.6, 1.7, and 1.8 extensively and have not seen these sorts of issues
11:09puredangersomehow you have newer class files and an older jvm
11:09mikerodjava.lang.UnsupportedClassVersionError: com/sun/javadoc/ClassDoc : Unsupported major.minor version 51.0, compiling: ider/nrepl/middleware/util/java/parser.clj
11:09mikerodOh... that's odd
11:10mikerodI guess I'll look at this some more.
11:10puredangerlooks like what you'd get with a mismatched jvm / jdk ?
11:11mikerodpuredanger: we accidentally had a node in a distributed cluster have java7 instead of java6 - that we have developed for currently in this case
11:11mikerodI guess something could just be screwed up there
11:12sobelwhat's the most current 'release' quality Clojure version?
11:12mikerodI just can't understand how a JVM running with Java7 could cause a JIT compiled class to break during compilation. I'm sure I just am not connecting the dots here then. I just wanted to make sure I'm not crazy and Clojure is fine running on Java6 and above
11:12puredangerare you sure it's a java 7 jvm?
11:12puredangerlooks like java 6 jvm and java 7 classes to me I think?
11:13puredanger51.0 is the JDK7 class format iirc
11:13justin_smithyeah, that would be the parsimonious explanation
11:14mikerodSo it sounds like somehow I had a com/sun/javadoc/ClassDoc compiled from Java 7 trying to run on a Java 6 JVM - ok, I think that makes sense
11:14mikerodwhich would be nothing to do with Clojure :P
11:14justin_smithmikerod: could be a cider bug?
11:15puredangeryou could see this if you were running java 6 vm with the java 7 jdk jar
11:16mikerodjustin_smith: perhaps, or potentially we really just had a very mixed up machine
11:16mikerodpuredanger: that sounds like a likely candidate of what happened there I'd guess
11:16justin_smithoh, wow
11:16puredangerfor reference, you shouldn't do that :)
11:16justin_smithhaha
11:16mikerodCider middleware parser does use com.sun.javadoc.ClassDoc so the pieces are fitting more together
11:16mikerodhaha
11:16puredangerit's ok to do the reverse though if you have the right settings :)
11:17mikerodyes, it does sound like a bad idea. the machine was set up incorrectly - I was just trying to make sure we didn't run into a clj incompatibility since we do intend to be moving to Java7 for this stuff in the near future.
11:17mikerod(inc puredanger)
11:17lazybot⇒ 41
11:17puredangermight as well move to 8 ...
11:17mikerod(inc justin_smith)
11:17lazybot⇒ 231
11:17mikerodpuredanger: yes I'm pushing for the jump from 6 to 8
11:17mikerodrather than stopping at 7
11:18puredangera lot of clojure stuff I run sees ~10% improvement from 7 to 8
11:18puredangerobviously, YMMV
11:18mikerodEspecially after hearing all about lambdas from Brian Goetz at clojure/conj :P
11:18mikerodJava lambdas that is
11:19puredangersome day we'll get those in Clojure too
11:19mikerodany particular reasons Clojure would get a speed up from Java7?
11:20justin_smithmikerod: to flip that - I would be surprised if you saw any slowdown
11:20mikerodjustin_smith: true. I'd imagine any new versions of JVM should be more perfomant
11:20puredangermost java releases optimize things like object allocation, locking, etc
11:20puredangerinlining
11:20mikerodI know clj isn't doing anything extreme like using invokedynamic at this time though
11:20mikerodI see
11:21puredangerwe're going straight to invokehyperdynamic
11:21puredangeris it still april fool's?
11:21mikerodhaha close enough
11:46expezGiven a file is there some easier way to check if it's present on classpath than to list all stuff on classpath and check if file is either listed itself or if a parent dir is?
11:46justin_smithexpez: do you know the expected relative path?
11:47expezI actually want to get all the project's clj files, perhaps there's an easy way to do that directly
11:47justin_smithoh, so you want to search for all clj files on the class path?
11:47expezya
11:47expezbut only the project's own, I don't want stuff from jars
11:47justin_smithexpez: assumed you only want things on disk in that project
11:48justin_smithyeah
11:48justin_smithso I guess you could look for classpath entries that are directories on disk, under the project root
11:48matthavard`,(range 10)
11:48clojurebot(0 1 2 3 4 ...)
11:48matthavard`Oh that's so cool
11:48justin_smithexpez: once you filtered for those, you could do a file tree
11:49justin_smithfile-seq
11:49justin_smith(doc file-seq)
11:49clojurebot"([dir]); A tree seq on java.io.Files"
11:50expezjustin_smith: I guess that's the way to go. Given the dirs I can use find-clojure-sources-in-dir from tools.namespace
11:50expez(inc justin_smith)
11:50lazybot⇒ 232
11:50expezthanks! :)
11:50justin_smithnp
12:37tahmidHas anyone tried material-ui for om ? (this repo https://github.com/taylorSando/om-material-ui)
12:43dnolentahmid: probably a better question for #clojurescript
13:09TimMc,(clojure.string/join " " "hello")
13:09clojurebot"h e l l o"
13:16gfredericks,(clojure.string/join "hello" "hello")
13:16clojurebot"hhelloehellolhellolhelloo"
13:19hyPiRion,(.trim (clojure.string/join "hello" " "))
13:19clojurebot"hello hello hello"
13:20justin_smith,(clojure.string/join "hello" "")
13:20clojurebot"hellohellohellohellohellohellohellohellohellohellohellohellohello"
13:20justin_smithTEttinger2: ^
13:41brainproxyfor new projects happy to use the latest clj alpha, is it better to get on board with the new reader conditionals or go with cljx?
14:24noncomhow do i make cheshire generate strings like {key: value} instead of {"key": value} from my data? i.e. how to make it omit quotes from the parameter key ?
14:25dnolenmpenet: ping
14:27TimMcnoncom: Like... make not-JSON?
14:28justin_smithnoncom: yeah - see for yourself, string is required for json http://jsonlint.com/
14:28noncomumm probably.. ok, i know, but neo4j does not accept it like that
14:29noncomit wants property names without quotes
14:29TimMcDoes it call it JSON?
14:30noncomno, it does not. but the only difference from json is this
14:30mpenetdnolen: yes?
14:31delaney1do we have any transit experts in the house?
14:31noncomso instead of writing a brand new stringifyer, i thought cheshire might do. esp that this kind of json can be *read* by cheshire
14:31dnolenmpenet: ready to move on ASYNC-120, I reviewed your patch, it looked OK but when applied it did not work as intended
14:31TimMcOh weird, it can?
14:31gfredericksI'd hope not
14:31noncomyes, see https://github.com/dakrone/cheshire/blob/master/src/cheshire/factory.clj
14:31dnolenmpenet: if you set up go blocks to take from the promise chan and then supply it via >! in a later go block only one of the <! takers will be fulfilled
14:31noncom:allow-unquoted-field-names factory param
14:31delaney1i'm trying to implement a transit-c# reader, but seeing what i think is a bug in one of the examples
14:31gfrederickswoooah
14:32noncomi guess cheshire only allows that coz jackson allows that
14:32TimMcOh, not by default, good.
14:32dnolenmpenet: the tests weren't translated well enough to capture this case, I'm not yet sure of the root cause
14:32TimMcnoncom: There's a chance there's a key encoder...
14:32mpenetdnolen: hmmm ok, I'll have a look when I get some time, but I am on a trip at the moment, I wont be back until wed
14:33mpenetdnolen: feel free to take over if you find the reason behind this problem
14:34dnolenmpenet: however it inspired me to rip out the old hand rolled runner and rely on cljs.test testing functionality & async test support. Happy to take a rebased patch.
14:34mpenetnoted
14:34dnolenmpenet: if I don't get to it before you return
14:34noncomhmm, yes, looks like i have to get inside the encoder..
14:35TimMcdelaney1: Link to example in case there is a transit expert around?
14:35gfredericksthe best kind of json is json where the object keys are serialized json objects
14:35delaney1TimMc: i'll make a gist, thanks
14:36noncomgfredericks: sure, standards are out best good, but here i just want to be able to give my objects to neo4j and writing a custom string generator for this is a little overkill :)
14:36TimMc{[object Object] 5}
14:36danielglausergfredericks: That's awesome
14:37justin_smithnoncom: (cheshire/generate-string {{:a 0} 0})
14:37gfredericksnoncom: I'd say this is a lot more neo4j's fault than cheshire's fault though
14:37justin_smith"{\"{:a 0}\":0}"
14:37justin_smithsorry, that really wasn't directed specifically to you, noncom
14:37TimMcnoncom: http://jackson.codehaus.org/1.1.2/javadoc/org/codehaus/jackson/JsonGenerator.Feature.html#QUOTE_FIELD_NAMES
14:38TimMcIf you want to use Jackson directly.
14:38TimMcMaybe cheshire supports that option though, or maybe it can pass through options?
14:39noncomTimMc: thanks for the hints, i will check this out!
14:41TimMcAlthough the phrasing "want to use Jackson directly" waas a little hard for me to type out.
14:43noncomyeah :D
14:43noncommaybe i'll just patch cheshire if i won't find another way around
14:43delaney1lol, in writing the gists i reread the spec ~ "if they are longer than 3 characters cache it"
14:55TimMcgood ol' SSCCE
15:17zanesWhat would be the most idiomatic way to apply two transducer pipelines in parallel to an input, merging the results?
15:28puredangerthe map transducer can read two inputs
15:28puredangerthat's the only one atm
15:31gfrederickspuredanger: I'm apparently too timid to say this on the ML but the iterate thing Bronsa was bringing up feels pretty gross to me
15:31gfredericksunless it's well documented
15:31puredangeryou mean the reduce caching aspect?
15:31gfredericksyeah
15:32gfrederickshe brought up perf but I'm thinking functions with side effects
15:32Bronsagfredericks: iterate's doc explicitly says f should be side-effect free, though
15:32puredangeriterate specifically says in the docstring that the f must not have side effects
15:32gfredericksthe old docstring says that?
15:32puredangeryes
15:32gfredericksthen maybe the answer is just to take that seriously I guess :)
15:33gfredericksokay I don't mind as much then
15:33BronsaI still don't think the new impl is a good idea :)
15:33gfredericksBronsa: just because of potential slowdown?
15:33Bronsayes
15:33puredangerseqs cache. if you want caching, use seqs.
15:34puredangerthe new version is faster for that too.
15:34Bronsapuredanger: iterate's docstring says "returns a lazy sequence"
15:34puredangerit is a lazy sequence
15:34puredangerit is also reducible NOT as a lazy sequence
15:34gfrederickshmm
15:34Bronsait's a sequence and a generator
15:34Bronsadepending on how you use it
15:34puredangeryes
15:34Bronsait's obviously not a sequence when you reduce it
15:34Bronsawe should document it
15:35gfredericks^ that part bothers me just for being complicated to understand
15:35puredangereither path must produce the same values (if f does not have side effects)
15:35BronsaI'd rather have it reverted, but if that's out of the question we should at least make it clear how it will behave
15:36Bronsapuredanger: I'll admit my ignorance, but no side effects === pure?
15:37Bronsai.e. is `rand` considered side-effecty?
15:37puredangerwell, I'm using them to mean the same thing, but I'm sure some smarter person than me has a distinction
15:37puredangerrand *is* side effecty
15:37amalloyBronsa: "side effects" and "pure" are both vague words; in some contexts they include rand, and in others they don't
15:37puredangerI think maybe it would be better to say "deterministic"
15:37gfrederickswhat about (let [r (java.util.Random. 42)] #(.nextLong r))
15:37puredangersame inputs = same outputs
15:37amalloypuredanger: no, that's super wrong
15:37justin_smithpuredanger: see gfredericks' talk at clojure/west for a non-side-effecty rand I think
15:38gfredericksoh crap I just got cited
15:38puredangerpre-cited even
15:38justin_smithpre-cited
15:38ntaylorand now he's ex-cited!
15:38Bronsapuredanger: the new version of iterate is probably faster for seqs b/c it doesn't guarantee once only computation like LazySeq does
15:38BronsaI don't like that either :P
15:39puredangeryes, that's exactly the point
15:39justin_smithBronsa: seems like there are a few things in clojure that say "no side effects please" but in practice we use as if side effects were OK
15:39justin_smithand maybe those chickens are coming home to roost
15:39gfredericksyeah that's what I meant about taking it seriously
15:40Bronsajustin_smith: my complaints have little to do with side-effects, much more with predictable performances
15:40puredangerI spent a few hours looking through oss for places where someone had violated that instruction and I don't recall finding one
15:40puredangerBronsa: it is predictable. it's just different.
15:40BronsaI always assumed functions returning lazy seqs guaranteed caching & once-only computation
15:40Bronsanot the case anymore
15:40puredangerthey do, when used as a seq
15:40gfrederickspassing something to reduce is something you can do with a seq
15:41Bronsapuredanger: not if the seq is realized in two different threads at the same time
15:41Bronsapuredanger: it's not synchronized
15:41puredangerthis is not feasible in all cases, just these specific functions which generate the identical sequence of values every time
15:41puredangerBronsa: but the same values will be generated
15:42puredangerthis is the same technique used lazily cache hash codes once computed
15:42TimMcThrowing an exception is also a side-effect by some definitions.
15:43puredangercycle, repeat, and range (fudging promotion cases) never throw exceptions
15:43puredangeriterate can, but that is handled in the ticket CLJ-1692
15:44gfrederickscycle could throw an exception while realizing a lazy seq :)
15:44puredangerhmmm
15:44gfredericks,(cycle (map #(/ 42 %) [2 1 0]))
15:44clojurebot#<ArithmeticException java.lang.ArithmeticException: Divide by zero>
15:45gfrederickswould have to examine the stack trace to verify
15:45solussdWhat’s the recommended way to rcreate a test.check generator from a generator that will have duplicates?
15:45gfrederickssolussd: to dedupe it you mean?
15:45solussdyes
15:45gfrederickssolussd: what sort of thing are you trying to generate?
15:45solussdstrings, but the system I’m testing does a uniqueness check
15:45gfrederickslike ids?
15:46solussdunique names, so, yeah, like ids
15:46puredanger(take 2 (cycle (map #(/ 42 %) [2 1 0]))) indeed is this problem
15:46gfrederickssolussd: it bugs me that there seems to be no foolproof way to provide that, but there's a few less-than-ideal tactics
15:47gfrederickscertainly you can fmap with distinct
15:47puredangerwith the obvious memory impact :)
15:48gfredericksnow that I think about it maybe this could be done in a not-terrible way
15:48gfredericksshrinking is the sticky part
15:49solussdfmap with distinct would just generate strings without duplicate characters, right?
15:49gfredericksoh I mean generating a whole collection
15:49gfredericks(gen/fmap distinct (gen/vector my-string-generator))
15:49solussdgotcha
15:49ambrosebspuredanger: what difference does it make if eduction is no Seqable?
15:50ambrosebsmaybe I'll keep reading this email chain first.
15:50ambrosebs;)
15:51lexi-lambdaIs there a clean way to map over every other element of a collection?
15:51gfrederickspuredanger: thanks for backandforthing
15:51gfrederickspartition can help
15:51lexi-lambdaI.e., I want the result to contain all elements, but I only want the mapping fn to be applied to the even elements.
15:51puredangerambrosebs: not much given that seq will wrap an Iterable
15:51puredangerlexi-lambda: take-nth ?
15:52ambrosebspuredanger: is there a conceptual reason?
15:52justin_smith,(mapcat (fn [[x y]] [(inc x) y]) (partition 2 (range))) ; lexi-lambda
15:52clojurebot(1 1 3 3 5 ...)
15:52puredangerambrosebs: sorry, reason for what?
15:52amalloyjustin_smith: careful. what if the coll has 9 elements?
15:52ambrosebspuredanger: why is eduction no longer Seqable?
15:52puredangeroh, there was just no reason for it to be
15:52justin_smithamalloy: good point, that makes the answer trickier
15:53amalloyjustin_smith: map-indexed
15:53lexi-lambdathis works, but I'd be curious if there were a nicer way to do it with built-in constructs http://stackoverflow.com/a/10326400/465378
15:54amalloylexi-lambda: not really. that's how i'd write it
15:54lexi-lambdaAlright, thanks.
15:55amalloythough in my many years of clojure i have never had a need for map-nth. i have trouble imagining scenarios where i'd have data in a shape that needs to be map-nth'd
15:56justin_smithamalloy: what if every 1000000th visitor to your site should get a free ipad?
15:56amalloyjustin_smith: joke acknowledged
15:57ambrosebspuredanger: any other new data structures where similar decisions have been made?
15:57amalloybut seriously, map-nth still doesn't make sense there. i'd want a list of all the winners, not a list of all the guests where the millionth one has some extra data
15:57puredangerambrosebs: repeat,cycle,iterate changed in alpha6. range is coming (CLJ-1515) but varies slightly b/c range is chunked where the others were not.
15:58ambrosebspuredanger: these are all Seqable though?
15:58puredangeroh, they *are* seqs
15:59puredangerthe extend ASeq
15:59puredangerso they are also Seqable by returning this
16:00puredangerambrosebs: keys/vals both changed somewhat as well but they only committed to returning Seqable before and still do, but also happen to be IReduceInit now
16:00puredangerreally, all of repeat,cycle,iterate (and other seq functions as well) should preferably only commit to returning a Seqable, not a seq. but there's too much of an existing expectation to rely on that
16:01ambrosebspuredanger: well at least an IPersistentCOllection I hope
16:01puredangerideally those functions could have done like keys/vals and just returned something that is Seqable/IReduceInit
16:02puredangerthey are, but that's what I'm saying I wish they weren't
16:03puredangertoo likely to break existing code if we changed that
16:04puredangerevery flavor of this has been tried on 1603 or 1515 - tons of patches there trying different things. I feel like I've spent a ridiculous amount of time on just counting with range :)
16:04ambrosebspuredanger: ok I'm kind of following.
16:04gfredericksit seems like making things try to be collection-like and special-reducible-like gets messy
16:04ambrosebspuredanger: I immediately thought of using coll? to check if something is immutable.
16:04puredangeryeah, tons of things like that
16:04puredangeror seq?
16:05puredangerwho knows what we'd break if we made the results seqable but not seqs
16:06puredangerthere are a couple patches (referred to as the "split" impl where I tried this) that allow LazySeq to be created with a second function implementing reduce
16:06puredangermaking this a capability that others could use
16:06puredangerbut that's pretty dangerous without understanding all the cache tradeoffs and expectations
16:07ambrosebsthis is interesting. we probably can't break this at runtime but I could assign less specific static types to sequence functions in core.typed to reflect what could have been.
16:07ambrosebsI thought the contract of seq was returns nil or Seq.
16:07ambrosebsISeq
16:07puredangerthat seems right
16:07ambrosebsbut in a perfect world it's nil or Seqable?
16:08puredangerno, I'm saying functions like map, filter, etc should take a seqable and return a seqable
16:08ambrosebsaha
16:08puredangerright now they actually return a seq, which people have come to rely on
16:08puredangerno takebacks! :)
16:08amalloyfunnily, usually when people say they want map to take a seqable and return a seqable, they mean they want map on a vector to return a vector
16:09puredangera vector is a perfectly good seqable :)
16:09ambrosebspuredanger: so I should rely on map returning an *immutable* seqable?
16:09puredangerbut I think that desire is wanting even more :) (which you can get with transducers of course)
16:10puredangerseqable is describing potential. I don't know what a mutable or immutable seqable would be
16:10puredangersequences should always be immutable
16:11ambrosebsso map could return a mutable structure?
16:11ambrosebstheoretically :)
16:11ambrosebsie. something that returned a different value for first
16:12puredangeronce you obtain a sequence from it, I would expect it to always be the same
16:12ambrosebsah so (seq (map ...)) is immutable but (map ...) is fair game?
16:12puredangeronce you open that box with the cat, you'll know whether it's angry
16:12puredangeror dead
16:13puredangerwell trying to be careful here about what expectations are now and what they might theoretically have been if we started over designing Clojure knowing what we know now...
16:14puredangerright now, I would say the expectation is that map returns a sequence, which is immutable
16:14puredangertheoretically, it could have committed only to return a seqable, that when poked will yield a sequence, which is immutable
16:16amalloyi feel like there's a lot of code that depends on seqable things returning the same thing when seq'd twice. like, (let [xs (map whatever ys)] (if (empty? xs) "empty :(" (first xs)))
16:17puredangerabsolutely
16:18puredangerand that should always work
16:18puredangerbut what if xs was an object that only realized itself at the first point when you asked it for a value?
16:19puredangerI'm not saying at all that we are or will change anything about this
16:19puredangerpurely in thought experiment land here
16:19puredangerlook at LazySeq for example
16:20puredangerit does exactly this kind of thing. when you ask for a seq, it synchronizes and builds it
16:21Bronsapuredanger: I reopened CLJ-1694, you just used a bad example
16:24puredangerthx
16:33ambrosebspuredanger: ah I meant map returns an observationally immutable thing wtr first/next.
16:33ambrosebswhich sounds like what you just described.
16:33puredangeryes
17:01bacon1989so is there a single statement equivalent to (not (nil? <expression>)) with a single form?
17:01bacon1989like not-nil?
17:02bacon1989i've been using it constantly, I feel like there should be a function for this already
17:02amalloybacon1989: in 1.6+ there's some?
17:03bacon1989amalloy: but doesn't that take a container?
17:03amalloysome?, not some
17:03bacon1989,(some? nil)
17:03clojurebotfalse
17:04bacon1989,(some? "value")
17:04clojurebottrue
17:04bacon1989,(some? [1 2 3])
17:04clojurebottrue
17:04bacon1989,(some? [])
17:04devnhello friends and uncles
17:04clojurebottrue
17:04bacon1989interesting
17:04justin_smithdevn: hello
17:05bacon1989that should work, thank you amalloy
17:05bacon1989i
17:05bacon1989i'm confused by the name though
17:05justin_smithbacon1989: some as opposed to none?
17:06bacon1989looking at it that way makes sense, but there's a nil? function, not-nil?
17:06justin_smithsure, (complement nil?)
17:06ambrosebs,not-nil?
17:06clojurebot#error{:cause "Unable to resolve symbol: not-nil? in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: not-nil? in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: not-nil? in this context",...
17:06bacon1989i'm just being picky
17:07justin_smith,(map (complement nil?) [:a [] () nil false])
17:07clojurebot(true true true false true)
17:07bacon1989some? is fine, but it's not the first thing I think of, when i'm looking for the complement of nil?
17:07ambrosebsit's like an option type on something being a reference
17:07bacon1989justin_smith: in that case, i'm better off just sticking with (not (nil? <expr>))
17:07bacon1989but some? appears to be a replacement
17:08justin_smithbacon1989: well, complement returns a function, is the difference
17:08bacon1989oh right
17:31lalaland1125Hi. I am trying to turn a persistent hashmap into a persistent array map. This is my current attempt "(print (type (apply array-map (flatten (seq {1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1})))))"
17:31lalaland1125Is this incorrect?
17:31lalaland1125It doesn't appear to work right in clojurescript.
17:32justin_smithlalaland1125: why do you care whether you have a persistent hashmap vs. persistent array map?
17:32justin_smithas far as I know, array maps above a certain size are always auto-promoted to hash-map
17:32lalaland1125I am trying to hot fix a library bug.
17:33lalaland1125The library itself has to be changed to work with hash maps, but a simple fix should put that off.
17:34gfredericksyeah looks like cljs doesn't let you do this the way clj does
17:34gfredericksI feel like I pointed this out to david a year ago or something
17:35justin_smithgfredericks: can you make an arbitrary sized array-map in clj?
17:35gfrederickstotes
17:35gfredericksjust call array-map
17:35gfredericks,(type (apply array-map (range 100000)))
17:35gfredericksit's greek to me
17:35clojureboteval service is offline
17:35gfredericks&(type (apply array-map (range 1000)))
17:35lazybot⇒ clojure.lang.PersistentArrayMap
17:35gfredericksanyhow there's one with 500 at least
17:36lalaland1125So its probably a clojurescript bug.
17:36gfredericksI dunno david might disagree
17:36justin_smithlalaland1125: a minor thing - (apply concat {1 2}) is much better than (flatten (seq {1 2}))
17:36gfrederickslalaland1125: what is the problem you're trying to hot fix?
17:36justin_smithbecause flatten can destroy your data (or cause an odd number of args)
17:36lalaland1125https://github.com/juxt/bidi/issues/55
17:39justin_smithlalaland1125: why not fork the lib and put the proper protocol in there instead of the concrete type? https://github.com/juxt/bidi/blob/master/src/bidi/bidi.cljx#L251
17:40gfrederickslalaland1125: so the problem is that the protocol isn't implemented for hash-map? why not just do that?
17:40justin_smithoh yeah, you can extend that from outside bidi
17:40justin_smithd'oh
17:40justin_smith(inc gfredericks)
17:40lazybot⇒ 132
17:41justin_smithILookup or maybe IAssociative or IMap
17:41gfredericksuh
17:41justin_smithhttps://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L391
17:41gfredericksno you'd do the concrete class right?
17:42gfredericksI don't think you're supposed to extend protocols to protocols
17:42justin_smithgfredericks: oh, is this extending a protocol to a protocol issue?
17:42justin_smithyeah
17:42justin_smithright, I keep forgetting that
17:47lalaland1125gfredericks, Your solution worked very well. I am new to clojure and didn't know that you could do that sort of thing outside of the implementing class.
17:49justin_smithlalaland1125: yeah, you don't have to "own" the protocol or the class you are extending it to in clojure. Which would be insane in an OO situation. But hey Madness? THIS IS FPP.
17:50justin_smithmix that with mutation and enough magic and things can still get weird though, of course
18:18lewixhello guys
18:18justin_smithello, you lost your L
18:18lewixhow does clojurescript compare to typescript
18:18expezfavorably
18:19lewix@justin_smith, im on my phone ^^
18:19yally04Hi all, how would you partition a seq by groups of two values? e.g. [3 4 5 6 7 8] becomes ([3 4] [4 5] [5 6] [6 7])
18:19lewixexpez: the talk of the town is all a out typescript
18:19yally04It's been way too long since I've written any Clojure and I know this should be very simple!
18:20justin_smith,(partition 2 1 [3 4 5 6 7 8 'yally04])
18:20clojurebot((3 4) (4 5) (5 6) (6 7) (7 8) ...)
18:20yally04oh man, of course ...
18:20yally04forgot that partition had that option.
18:20yally04thank you!
18:20lewixabout*
18:20justin_smithnp
18:21lewixjustin: how would you partition it with map
18:21justin_smithwith map?
18:21lewixjustin: yup basically reinventing the wheel
18:22amalloy(map list xs (rest xs))
18:22justin_smithyup, that's the one
18:25lewix amalloy: xs (rest xs)?
18:25justin_smith,(let [xs [1 2 3 4 5]] (map list xs (rest xs)))
18:25clojurebot((1 2) (2 3) (3 4) (4 5))
18:26justin_smithxs is a common name for more than one x in the haskell / ml world
18:26lewixjustin can you explain the map function
18:26justin_smithlike what it does in general, or what it did that?
18:27lewixi dont understand the logic
18:27justin_smithit takes list, and applies list to one element from xs and one element from (rest xs)
18:31justin_smiththen it does the same thing, from the next element of each
18:31raspasovlewix: here
18:31raspasov,(map list [1 2 3] [4 5 6])
18:31clojurebot((1 4) (2 5) (3 6))
18:31raspasovyou're "mapp-ing" list to first element of each collection, then to second elements of each collection, etc
18:31lewixdope. amalloy: how did you think about it so fast?
18:31lewixraspasppv: thanks
18:31lewixjustin: thanks
18:31amalloylewix: it's a very common trick
18:32lewixthanks guys
18:48justin_smithin case anyone was curious, XP table for programmers http://jimkang.com/namedlevels/#/class/programmer
19:15mfikesgfredericks: FWIW David fixed array-map http://dev.clojure.org/jira/browse/CLJS-1189
19:18justin_smithnice
19:26andy___Is there a reason (reverse ...) isn't also a transducer?
19:29justin_smithandy___: it needs to create a sequence of the entire input, so transducing would not really help
19:30andy___I know it needs to buffer, but so does --for instance-- partition-by
19:30justin_smithandy___: but it needs to buffer the entire input, at which point being a transducer has zero benefit
19:31justin_smithI mean, I could imagine an implementation that called rseq on vectors and walked arrays backwards, but we don't even have a non-transducer version of that reverse
19:31andy___but what if I want to use it for the sake of composability?
19:32justin_smithfunctions are composible, the only reason transducers are better is they avoid extra unneeded work, with reverse you cannot avoid that work
19:33andy___hmm I see, I guess it'd be a tough sale since transducers also also supposed to all work with core.async
19:33andy___and in that case it would just wait until that channel closes
19:33justin_smithright - that would kind of suck
19:34caterndear clojurists
19:34andy___alright, fair enough. :)
19:34caternif I wanted to convert this object into a clojure map, how would I go about that? http://libvirt.org/sources/java/javadoc/org/libvirt/DomainInfo.html
19:34justin_smithcatern: have you tried bean?
19:35justin_smith,(bean (java.util.Date.))
19:35clojurebot#error{:cause "denied", :via [{:type java.lang.ExceptionInInitializerError, :message nil, :at [java.lang.reflect.Proxy$ProxyClassFactory apply "Proxy.java" 672]} {:type java.lang.SecurityException, :message "denied", :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}], :trace [[clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69] [clojurebot.sa...
19:35justin_smitherr...
19:35justin_smiththat usually works :)
19:35caternI found http://stackoverflow.com/questions/7916199/use-java-object-as-clojure-map which suggested bean, but it just returns {:class org.libvirt.DomainInfo}
19:35amalloyjustin_smith: this thing doesn't have getters, it has public fields
19:36justin_smithahh
19:36caterni don't know much about Java so even obvious suggestions are helpful
19:37noonianjust to clarify, you want to be able to use an instance of a DomainInfo as a map? or represent the same data as a map?
19:37justin_smithfor that few fields you could do it by hand, and look for something more automated if you need to do it for a bunch more classes
19:37caternnoonian: yes, or something like that.
19:38justin_smithcatern: noonian offered two options
19:38caternjustin_smith: there's a bunch of these kinds of objects in the libvirt Java API
19:38caternjustin_smith: either of those options is acceptable
19:38justin_smithAhh, yeah. I have seen reflection based macros to automate such things.
19:39andy___catern: Check out https://github.com/zcaudate 's libraries. They do a bunch of java interop. Maybe you can find something there
19:49caternjustin_smith: what kind of approach could I take there? (.getFields (class info)) and.. then what?
19:52justin_smithcatern: a macro could turn a collection of fields to a call to hash-map with keywords named after those fields mapped to their values
19:52justin_smithif the fields of the class are knowable at compile time, of course
19:54noonianhmm, that class looks like it will be mutating constantly though
19:54nooniancputime - the CPU time used in nanoseconds
19:55noonianso that approach would only give you the values when the map is created
19:55caternnoonian: true
19:55caternnoonian: fortunately in practice actually no, it seems to be immutable
19:55catern(i.e. once I get it, it doesn't change)
19:56noonianif that's the case then what justin_smith is describing is probably the way to go
19:59caternwhat if instead I
19:59caterndid
20:00catern(let [fields (.getFields (class info))] (map (fn [field] [(str field) (.get field info)]) fields))
20:01catern(into {} that)
20:02caternhow awful is that
20:02caterntoo awful?
20:02nooniannot too awful if it works :P
20:03caternbut that's heavily abusing reflection
20:03caternwhich is bad for performance
20:03caterninnit
20:03nooniancould do a camelCase to kebab-case conversion and turn the keys into keywords if you wanted the maps to follow clojure idioms
20:03noonianyeah, but depending on what you are trying to do it might not matter
20:03caternyeah, something like that (rather than (str field))
20:04caterner
20:04caternrather than (str field)*
20:05caternyeah, (.getName field) instead
20:10raspasovcatern: I don't know the library internals very well, but I believe Amazonica does a very neat two way conversion between Java <-> Clojure
20:10raspasovwith the Amazon Java Library
20:10raspasovmight be helpful to look at, not sure
20:19noonianheres my quick attempt: https://www.refheap.com/99213
20:53caternfor adding a bunch of new key-value pairs to a map, I should use assoc, right?
20:53caternjust checking
20:57caternalso!
20:57caternhow best to work with XML in Clojure?
20:57caternthis thing? https://github.com/clojure/data.xml
20:58skelternetWhat are you going to do with the XML?
20:59caternlook through it for a specific field (or whatever it's called, <tag>the thing in here</tag>) and use the value inside
21:00catern(among other read-only things, possibly. no generation)
21:00skelternetwill the target tag always be in the same place in the hierarchy?
21:01skelternetis the xml small?
21:02caternthe xml is small
21:03skelternetYou'll find a lot of choices. I asked about the size because sometimes XML sources are too large to want to load up as a dom.
21:03caternthe target tag will always be in the same place hierarchy (if I understand what you mean. I could always use the same xpath expression)
21:03caternsame place in the hierarchy*
21:05skelternetIt has been a while. I'd try it with data.xml
21:06skelternetthat should get you a clojure data structure from the xml
21:07skelternetugh…I remember doing this now
21:07skelternetIt's version of the datastructure was verbose
21:07caternewwwww
21:08catern{:tag foo :attrs [foo bar] :content "quux"}
21:08caternthat's pretty terrible
21:08skelternetlet me look for what I ended up using
21:08caternwould be appreciated
21:08skelternetit may have been a zipper
21:10skelternethttp://clojure.github.io/data.zip/#toc0
21:11skelternetYes…this is what I ended up using.
21:12skelternetI had to scrounge for useful examples, and this was a a year ago or more.
21:12skelternetI'd hope there was a better library or better examples.
21:12caternehhhhhh
21:12caternhttp://stackoverflow.com/questions/11215040/available-clojure-xml-parsing-libraries-that-complement-clojure-xml-parse
21:12caternthis answer is pretty true
21:12skelternetOnce I had the zipper, I could use tags as the predicates
21:12caternI'll just transform this nested thing
21:13caternalternatively, I could just use xpath
21:14skelternetI like that better than the zipper, I think
21:14caternwhich one?
21:14caternthe stackoverflow or the xpath?
21:14skelternetI think I used something like
21:15skelternet(xml-> myxmlzip :outtertag :midtag :innertag text=)
21:15skelternetI like the stackoverflow idea
21:16skelternetseems like it should be a standard part of the xml library though, as frequently as we'd use it
21:19amalloyskelternet: and what if the xml looks like <outertag><midtag>...</midtag><midtag>...</midtag></outertag>?
21:20amalloythe standard xml interface can't really be to treat them like maps, because they can encode structure that isn't mappy
21:21skelternetI'm thinking back to that session with the zipper.
21:22skelternetQuick googling…
21:22caternokay
21:22skelternetDo we stil have xml-seq?
21:22caternI'm pretty sure that The Right Way is xpath
21:23skelternethttp://blog.korny.info/2014/03/08/xml-for-fun-and-profit.html
21:23caterna nice, simple, standard, declarative way to navigate XML
21:24skelternetamalloy, I think that if you need all of them, then xml-> otherwise xml1->.
21:25skelternetxml-> returns a sequence of the results of the predicates. Since :outertag :midtag text= can be applied to multiple nodes, I'd expect a sequence of the text of midtags
21:26skelternetI remember thinking at the time I should right a library for the common task of tweaking xml files.
21:26skelternetI was tweaking poms then.
21:27skelternetright/write
21:29skelternetcatern, are you just extracting the value and using it, or are you changing the value and hoping to write it out?
21:31skelternethttps://github.com/kyleburton/clj-xpath
21:35caternskelternet: just extracting
21:35caternindeed, I am using that library right now
21:35caternand have solved my problem with it :D
21:35catern:)
21:36skelternetyou kids these days…with your libraries and your xpath...
21:36skelternetwhat did the code end up looking like?
21:37caternhttp://ix.io/hiC
21:43skelternetdoesn't seem terrible
21:43skelternetI remember having to review xpath then, too.
21:43skelternetThanks!
21:46skelternetthe memories…
21:51guthuri have a key value list (:foo 1 :bar 2), what is the idomatic way of extracting values from this
21:51skelternetvals ?
21:52skelternet'(vals {:foo 1 :bar 2})
21:52skelternet,(vals {:foo 1 , :bar 2})
21:52clojurebot(1 2)
21:52guthurbut it's a list not a map
21:52skelternetohhh
21:53skelternet,(into {} '(:foo 1 :bar 2))
21:53clojurebot#error{:cause "Don't know how to create ISeq from: clojure.lang.Keyword", :via [{:type java.lang.IllegalArgumentException, :message "Don't know how to create ISeq from: clojure.lang.Keyword", :at [clojure.lang.RT seqFrom "RT.java" 506]}], :trace [[clojure.lang.RT seqFrom "RT.java" 506] [clojure.lang.RT seq "RT.java" 487] [clojure.lang.ATransientMap conj "ATransientMap.java" 42] [clojure.lang.ATran...
21:54skelternetchecking my cheatsheet…seems like I've seen that before and it seemed obvious after I saw it.
21:56caternis ring/compojure/hiccup still my best bet for a simple web application?
21:56caternor, let me put this another way
21:56skelternet,(hash-map '(:foo 1 :bar 2))
21:56clojurebot#error{:cause "No value supplied for key: (:foo 1 :bar 2)", :via [{:type java.lang.IllegalArgumentException, :message "No value supplied for key: (:foo 1 :bar 2)", :at [clojure.lang.PersistentHashMap create "PersistentHashMap.java" 77]}], :trace [[clojure.lang.PersistentHashMap create "PersistentHashMap.java" 77] [clojure.core$hash_map doInvoke "core.clj" 369] [clojure.lang.RestFn invoke "RestFn.j...
21:56caternwhat's the absolute simplest way I can start serving a map over the web?
21:56skelternet,(apply hash-map '(:foo 1 :bar 2))
21:56clojurebot{:bar 2, :foo 1}
21:58skelternetWill that get you there, guthar?
21:58guthurskelternet: yeah that looks good, cheers
22:00skelternetcatern I think ring/compojure is the quickest I can think of for just that, given no need for REST or anything else.
22:39caterni'm so lazy
22:39caterni'd rather just convert a map directly into HTML
22:39caternlike, a list of maps into a table
22:39caternugh I wrote a function to do this before
22:40caternnow I have to write it again (because I can't find my earlier attempt)
22:40caternlame
22:41caternalternatively
22:41caterni'll use something to convert to json
22:42caterner, an actual question instead of complaints:
22:43caternif one tries for a client-side web application, and serves up a bunch of stuff as JSON that is then rendered by Javascript on the front end, is it possible/natural to have this be a traditional multiple-page application or are you pretty much stuck with the single page app?
22:44catern(I don't really know anything about web development)
22:49catern(that's not actually a Clojure question though)
22:59nuwanda_catern: I don't see why you would be limited to a certain architecture just based on that description
22:59caternOK
22:59caternand, another question
22:59caternI knew this at some point
23:00caternbut I've forgotten it :(
23:00caternHow should I run a Ring server while developing, so I can keep restarting it as I make changes to my application?
23:00caternIt seems to background by default and keep the port bound... so I have to M-x cider-restart
23:03tolstoycatern: For what it's worth, I don't use "lein ring" and so on. I just use a function that starts the server and eval that in the repl.
23:03tolstoyUsing http-kit, or jetty-runner, or aleph or something.
23:03caterntolstoy: yeah? I had the same thing, but when I interrupt it, it doesn't seem to actually stop the server.
23:04tolstoyHow are you interrupting it?
23:04caternunless this function has the autoreload stuff
23:04caternC-c C-c
23:05tolstoyI just re-evaluate routes and so on, though it's tricky if the handler isn't always re-evaluated each time a request comes in.
23:05tolstoyFor instance (run-server (fn [r] (my-routes r)) {:port 8001}) or something like that seems to work.
23:06tolstoyThen you can re-compile my-routes with C-c C-c and have the new functionality take effect without restarting the server.
23:06tolstoyDoes any of that make sense?
23:09caternI mean, I'm specifcally using ring/run-jetty
23:10tolstoyYou have to, uh, (.close) it, I think?
23:12tolstoyOh, (.stop server).
23:15mgaareAlso, pass your handler to jetty symbol-quoted
23:28tolstoyI seem to have an issue with that in that I pass in deps through there: (make-app db other-thing whatever) which then returns a handler that takes those as params.