#clojure logs

2017-06-20

12:45otwieraczWhat's your first try when it comes to templating engine?
12:47otwieraczI've got pretty simple app utilizing compojure
12:48otwieraczpereferably, I'd like something what can be used to generate some pretty simple view without even knowing HTML and CSS.
12:48otwieraczJust to display some text
12:49lxsameerotwieracz: selmer
13:47charlesh`Re
13:51charlesh`I have an issue between s/with-gen and other spec generators override
13:51charlesh`If I define a spec using s/with-gen I cannot override it later
13:53puredangerThere is one bug similar but not same as this files
13:53puredangerFiled
13:54puredangerhttps://dev.clojure.org/jira/browse/CLJ-2079 - any chance that looks familiar?
13:54puredangerit's specifically related to alias specs, but that seems different than what you're describing
13:55puredangermaybe it's a bug in how you're declaring the overrides map?
13:56charlesh`it looks like it, indeed.
14:02charlesh`Yeah. I think it's exactly that. What I'm doing is schematically the following : (s/def ::bar any?) (s/def (s/with-gen any? (fn [] (s/gen ::bar)))) then (gen/generate (s/gen ::foo {::bar (fn [] (s/gen int)?)}))
14:02charlesh`the second s/def is ::foo ::fo
14:03charlesh`::foo *
14:04puredangeryeah, could be
14:05puredangerfeel free to drop an example in a comment there
14:05puredangerwhen someone gets to it, would be great to verify it's addressed
14:20charlesh`I've post a comment as you suggested
14:43rjungemannQuick question: I want to use a recursive macro to manipulate a form. Is it "safe enough" to use real recursion? It would be hard for me to use clojure.walk because I would like to conditionally halt execution down certain paths (so if I have a macro called `notes`, and inside the form, I call `notes` again, I don't want to evaluate the inner call—the idea is to have a small set of recursive macros which don't step on
14:43rjungemanneach others' toes)
14:44dysfunwhy would it be unsafe?
14:44rjungemannI guess for very deep forms there's a risk of stack overflow
14:44rjungemannThey'd have to be like... very deep
14:45dysfunin clojure, we tend to use loop/recur where possible to avoid accruing stack frames
14:45rjungemannIs it possible to use loop-recur on tree-like structures? I'd have to keep a context of some sort, yeah? And then I'd probably want to use a zipper instead... maybe that's what I should do
14:46dysfunloop-recur optimises recursion from the tail position
14:46hiredman_generally, the way to do recursive macros is you have the macro expand to a call to itself
14:47rjungemannOh interesting. Right now I have a very tiny macro which passes the form to a regular function which does the recursion. If I refactored it so the macro did the recursion and the function just handled one step of the recursion, would that prevent stack overflow?
14:48hiredmanit really shouldn't matter
14:48rjungemannCool that's sort of what I wanted to hear :¬)
14:48rjungemannI'll keep dabbling a bit but I'll probably keep using the working version with "true recursion" for now, thanks for the advice everyone!
16:49joschkaguys whats this again in clojure? https://msdn.microsoft.com/de-de/library/bb548651(v=vs.110).aspx
16:50dysfunreduce?
16:50clojurebotreduce accumulates the men from the boys
16:50justin_smithjoschka: to accumulate over a sequence, yeah reduce
16:51joschkareduce
16:51joschkaman I'm an idiot
16:51justin_smiththere's also reductions if you want a lazy-seq of states of the accumulator
16:51justin_smithand reduced to make it short-circuit
16:51justin_smithit's a handy corner of the language
16:51justin_smithsee also core.reducers for parallelism and other weird stuff
16:52joschkaI remember raging about the fact that c# calls this aggregate and now I only remembered the C# name :D
17:35TimMcIn some languages it's called fold.
19:02nickbirdhello
19:03nickbirdclojure is good