This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-11
Channels
- # admin-announcements (10)
- # arachne (2)
- # beginners (74)
- # boot (302)
- # cider (49)
- # cljs-dev (11)
- # cljs-edn (7)
- # cljsjs (13)
- # cljsrn (1)
- # clojure (164)
- # clojure-austin (1)
- # clojure-brasil (3)
- # clojure-finland (2)
- # clojure-greece (4)
- # clojure-russia (48)
- # clojure-uk (11)
- # clojurescript (138)
- # community-development (1)
- # cursive (13)
- # datascript (1)
- # datomic (19)
- # emacs (4)
- # events (1)
- # garden (1)
- # hoplon (123)
- # jobs-discuss (9)
- # keechma (5)
- # lein-figwheel (4)
- # leiningen (2)
- # luminus (15)
- # mount (1)
- # off-topic (8)
- # om (66)
- # on (1)
- # onyx (28)
- # other-languages (2)
- # planck (1)
- # proton (5)
- # re-frame (18)
- # reagent (15)
- # untangled (15)
I’m new to Clojure, and asked a few experienced Clojurians if I should use Stuart Sierra’s Component in our projects and received more nays rather than yays. I’m curious why some people don’t like Component?
I couldn’t find any detailed explanation of someone’s opinion why Component rather complicate things
mount and yoyo are alternatives some people seem to prefer; you could review their docs and see how their arguments strike you. Myself, I’m an unabashed fan of the component philosophy.
Though to be fair, it’s a bundle of machinery that could confuse a beginner.
I'm new to clojure too and I'm fascinated by the philosofy of pure functions that I ask why so many other concepts like protocol, record, multimethod
I'm reading through them and dont realize yet the importance, I need some meditation
https://www.reddit.com/r/Clojure/comments/3zppdn/the_beauty_of_clojure/ && https://www.reddit.com/r/Clojure/comments/41p73n/contrasting_component_and_mount
I also used mount and didn’t like it. In the end, use what you feel comfortable with. To start you don’t need any of those.
[ring middleware question] hello all! did anyone experienced problems with enabled wrap-hsts? with it my handler always returns absolutely empty http 200 with HSTS header and no body on any url
@vinnyataide: I found clojure intimidating enough at first that I purposefully ignored macros, multimethods, records, and protocols until I was more comfortable
Records and protocols are often misunderstood and sadly reduced to Java interfaces and objects. But they are so much more.
thanks @donaldball @roberto for your insights. I will focus on the basics first
We’ve just gone through the process of converting over to Component at work (World Singles), and there are many benefits in terms of development workflow but it — and the other, similar, libraries do add a certain amount of complexity.
(and I just updated boot-expectations
to make it easier to use with Component … I’ll have to blog about this!)
to pile on, I have not formed a favorable impression of anything besides component in this space
We’d held off moving to Component because it seemed an all-or-nothing approach but after chatting to a few folks who are already using it, a piecemeal approach became apparent and we’re happy with that…
for example, at my last job we used component entirely using multimethods and :type tags in maps, no records, deftypes, or protocols
….so our subsystem start
functions set up our legacy global state now (instead of them just being delays and other weird stuff) and we’re slowly migrating our namespaces to accept a Component instead of (or as well as) just relying on that global state.
If we were starting from scratch now? Definitely would use Component from Day One.
can you not use reduce inside of recur to do exhaustive searching? something like…
(defn- recursive [start id]
(loop [node start]
(if (nil? node)
false
(if (condition node)
true
(reduce (fn [found nxt]
(and found (recur (get-next node))))
false (get-next node))))))
if you recur in a function that takes two arguments, you must recur with two arguments
recur is best seen a restricted recursive function call, restricted to calling the current function from tail positions (the way loop works you can pretend it is a macro that expands in to a function that is immediately invoked with the initial bindings)
if in the above node
had something like {:upstream [foo bar baz …]}
, how would you search node, then if not found in node, search across :upstream node
? mentally it maps perfectly to a recur
but I dont know how else you could do it except some sort of map or reduce across all :upstream
hard to say, I don't entirely follow what you are saying about the shape of your data, you may just want a function call, not recur
if the dataset is enormous I run the risk of a stack overflow with anything but recur, though, right?
so on at least two counts recur doesn't work the way you think it does and the way you are trying to use it
if you rewrite your algorithm to be iterative, then you can implement it using recur
could anyone with experience with Bouncer please tell me why I continue to get the default generic error message even though I provide a custom one? http://pastebin.com/E71kPuXY
can someone help me. sorry for noob question. I need to define a route such that it would redirect and serve a resource from resources/public folder. e.g. when /fonts/modern/foo.woff2
is requested it should be served from /better-fonts/modern/foo.woff2/
so basically for anything that starts with /fonts
it need to replace it with /better-fonts
Does anybody else have problem with lein uberjar
?
All of a sudden it doesn't want to compile my code:
clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: resources/see-also.edn (No such file or directory), compiling:(info.clj:143:38)
My project.clj dependencies:
:dependencies [[org.clojure/clojure "1.7.0"]
[clj-slack-client "0.1.6-SNAPSHOT"]
[org.julienxx/clj-slack "0.5.3"]
[enlive "1.1.6"]
[schejulure "1.0.1"]
[com.novemberain/monger "3.0.2"]
[yesql "0.5.2"]
[org.postgresql/postgresql "9.4-1201-jdbc41"]
[clj-time "0.11.0"]
[org.clojure/tools.nrepl "0.2.12"]
[cider/cider-nrepl "0.12.0"]]
No mention of see-also.edn
in my code. Is some of the dependencies broken?Exception in thread "main" java.lang.IllegalArgumentException: Not a file: jar:file:/home/erik/stress-0.1.0-SNAPSHOT-standalone.jar!/underscore-1.3.3.min.js
which states that the thingy passed has to start with a file:
whereas when you read the resources from an uberjar, the thingy starts with jar:file
feature. A resource is not necessarily a file on the filesystem. The call to io/resource
will give you java.net.URL
, which you should be able to use directly wherever you need it
how come EDN doesn't have an IANA media type yet? is it just a matter of no-one caring enough to go through the process, or is there a reason they don't want to go there?
mostly crickets on these three year old issues https://github.com/edn-format/edn/issues/43 and https://github.com/edn-format/edn/issues/53
@plexus: Rich said he doesn’t know a lot about it, and isn’t sure how it would limit future changes
I see, I suppose having it registered would imply a stable spec, so I guess there's a concern that it would hinder EDN from evolving...
Anyone help me on how to specify java source code path in boot? That is, in build.boot file.
@chunsj: #C053K90BR is probably the best place to ask
@martinklepsch: thank you
it there a way to enable compiler warnings when I use apis from newer clojure version than expected deployed version? say I want to use only stuff up-to Clojure 1.7
@triss i've been having more trouble with that lately than normal, seems a combination of restarting emacs and the nrepl server solves it
just found this in the #C0617A8PQ room, it fixed everything: https://clojurians.slack.com/archives/cider/p1462956148001569
ahh, somehow my own intermittent issue is connecting to nrepl and CIDER saying it's not jacked into anything when I try to eval code.
I want to write a markdown file and embed some Clojure (maybe ClojureScript) code in fenced code blocks as I'd run it in a REPL, so I'd have (require '[clojure.string :as string])
etc., and I want to include the evaluated output that the REPL prints out right below each code snippet. Before I hack together something to do this, any suggestions? I don't want anything as heavyweight as Hydrox or Marginalia which are more for annotating source code/tests, I want something much more expositionary.
@roberto thanks for mentioning that. Not ideal because I'd like to be able to use the processed markdown file as a Github README, but also I'd like to use JVM things.
how does one write the type of a byte-array
in Clojure? (type (byte-array 4))
tells me it's a [B
@triss you can use (Class/forName "[B”)
@fasiha: Um yes. I want a function to behave differently depending on type of argument passed in.
thanks @ddellacosta !
Hi guys, we are doing a meetup and want to review some open source project/library, go through its code and learn some good patterns of the language. Any suggestions for a clojure project/library that is also beginner friendly?
@pcbalodi: a library like environ maybe? it's fairly easy to read https://github.com/weavejester/environ/blob/master/environ/src/environ/core.clj
My question will involved a complex map. What is the prefered code example site here? I can't get to pastebin
Slack will let you post a "note", or you can use http://refheap.com
http://gist.github.com is fine, but https://www.refheap.com/ is built in Clojure, thus cooler 😉
@virmundi: lucky you. Firewall in my current client blocks Github too!
if I want to extend a record in another namespace, is :import
still the idiomatic way to bring that record into the current ns?
@virmundi: I tried this in the REPL:
(zipmap (keys m) (for [v (vals m), m' v] (update m' :lines (fn [v] (mapv #(dissoc % :column2) v)))))
(zipmap (keys m) (map (fn [v] (mapv #(update % :lines (fn [v] (mapv (fn [m] (dissoc m :column2)) v))) v)) (vals m)))
virmundi: Here's how to do it with Specter: (transform [ALL LAST ALL :lines ALL] #(dissoc % :column2) m)
@nathansmutz: why LAST?
@nathanmarz: how do I get to just the jar? It's not showing up in Maven Central. I'm having to work with nothing by java -cp and Notepad.
It's on Clojars: https://clojars.org/com.rpl/specter
I literally don't have lein, mvn or gradle. What I'm not seeing, and that could be due to me looking like old people run, is the link to the jar itself
Question about evaluation order. I know that functions evaluate inside out, meaning the inner form is evaluated before the outer form. But what about macros? It looks to me like they are expanded from outside in, meaning the outer macro is expanded before the inner macro. Is this correct?
@didibus: yes they are
@didibus: cf macroexpand
@didibus: but note that this is not really evaluation
@nathanmarz: I tried the transform. The columns still exist. Does specter work over a map with a lot of keys at its root?
Ok, cool, good to know. Ya I know it's simple expansion, but it means you can't do: (doto (object) (if (not (nil? object)) (.put "wtv"))) for example. Since the (if) will expand after the (doto)
@didibus: it's more a matter of compilation vs evaluation than expansion order. (not (nil? object))
is not an information that's available at compile time.
macros receive argument as unevaluated , they transform data into a form clojure can evaluate. If the outer macro is expanded before the inner macro, how does the outer macro evaluate without the evaluation of the inner macro? @val_waeselynck
you really have to consider that macros manipulate code, not values
@lewix: it's easy to prove that it is.
by example
@jr quicker than me
I'm looking. Right now I want to make sure I'm adding the other 110 columns to remove properly into dissoc
@lewix: try this
(defmacro say-hello [& body] (println "hello"))
(comment (say-hello "coucou"))
@lewix: if macro expansion was outside-in the second for would trigger the println
the compiler walks down the tree of code analyzing forms, before analysis it calls the macro expander, thus macros are expanded from the outside in
oh yeah right sorry I meant inside out
Has someone written any documentation on tagged literals? I'd like to know how to create and manitpulate them. Any pointers appreachiated.
Hey, I am using seesaw to build a gui. I created a swingx/table-x component and want to sort columns that contain doubles. However, table-x seems to sort only alphanumeric, is there a way to pass in a specific sort function? Or maybe tell seesaw that my column contains numbers
Ok, seems like I have to override a method of the tablemodel class to achieve that. Jeez, such a simple thing, yet so hard to achieve
@sveri it is still Swing after all 😄
I published the results of my research around code reloading in Clojure and thought this might be of interest to some of you: http://danielsz.github.io/2016/05/06/Ghosts-in-the-machine