This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-11
Channels
- # admin-announcements (36)
- # beginners (1)
- # boot (267)
- # cider (19)
- # cljs-dev (12)
- # clojure (149)
- # clojure-austin (4)
- # clojure-canada (1)
- # clojure-czech (3)
- # clojure-dev (31)
- # clojure-japan (2)
- # clojure-uk (22)
- # clojurebridge (3)
- # clojurescript (314)
- # clojutre (18)
- # core-async (8)
- # cursive (4)
- # datascript (1)
- # datomic (27)
- # editors (2)
- # events (80)
- # hoplon (13)
- # javascript (2)
- # jobs (5)
- # ldnclj (12)
- # ldnproclodo (1)
- # off-topic (4)
- # re-frame (21)
- # reagent (87)
- # testing (13)
I have isolated my dependency problem I spoke about yesterday. It's here: https://github.com/borkdude/ring-problem
The error I'm having is: java.lang.ClassNotFoundException: ring.middleware.not-modified, compiling:(matchmaker/api.clj:52:7)
and if seq is idiomatic, why does https://clojuredocs.org/clojure.core/not-empty exist?
@borkdude: you are calling ring.middleware.not-modified
here https://github.com/borkdude/ring-problem/blob/master/src/matchmaker/api.clj#L52
That's it. Doh. I didn't even think about it, because it worked in a project where I borrowed this code from.
@atroche: not-empty? will return the collection if true eg (not-empty? [1]) => [1] that's the only difference I can see
Then (seq x) rather than (not (empty? x)) makes little sense given you'd want true | false
@adebesin: depends on the situation, nil is falsey so works well in logical tests (as @niwinz shows)
@adebesin: pretty good article on nil-punning in clojure: http://www.lispcast.com/nil-punning
Is there a function to dig down into maps that contain maps to avoid nested gets? something like (get person :name :first-name) ?
@profil beat me to it!
Thanks.
(get-in person [:name :first-name])
in your examplehello clojurians
I couldn’t find a way to destructure using keys and &
in ES2016 this will be possible:
{a, b, …rest} = {a:1, b:2, c:3, d:4}
any way to do something like this with let
?
e.g.:
(let [{:keys [a b] & rest} {:a 1 :b 2 :c 3 :d 4}])
which is invalid
don’t know if here is the best place to get help 😛. If not I can delete these msgs
bound to rest
var, an array
it would be better used as let {a, b, …rest} = {a:1, b:2, c:3, d:4}
I misread docs
it would be bound to rest
var, an object
{c:3, d:4}
oh thanks!
this did the trick: (let [{:keys [a b] :as m} {:a 1 :b 2 :c 3 :d 4} m (dissoc m :a :b)] (println m))
clojure
(let [{:keys [a b] :as m} {:a 1 :b 2 :c 3 :d 4}
rest (dissoc m :a :b)] (println m))
not sure if mutating m
inside let
is ok
(edited to avoid mutation)
@shamatov I would have found any actual coding, however simple, quite frustrating if I didn't understand some of the ideas behind clojure. I suggest you watch Introduction to Clojure for Java programmers (even if you don't know Java - it doesn't go into Java in any detail AFAIR, more OOP vs FP, and gives good intro to Clojure data structures) Also, I highly recommend Clojure Programming (O'Reilly) . It starts with some Ruby and Java code, then shows the Clojure equivalent. Clojure has very little syntax, which is great when you have a bit more experience, but when starting out, can be a bit daunting, and IMO this book does nice job to show how Clojure is built up of smaller building blocks (e.g. it shows do form, and then other places where do is 'implicately' used, etc). Helped me understand how things fit together.
does anyone have good examples of a hexagonal architecture / ports and adaptors sort of approach to Clojure? or functional programming in general, how these ideas translate?
Is there a way to use threading (-> or ->>) when some functions require the passing argument as the first one and some as the second one?
arrdem: beautiful.
Wrote a minimal Clojure client for Airtable (40loc): https://gist.github.com/martinklepsch/302121cdacd6771354c6 — Feedback welcome
@chouser: I tend to go the route of each component has an atom or two for internal state (such as caches or whatnot). But it is concievable that you could have a State component that is simply an Atom containing a hash-map that can then be shared between lots of components.
But then you trade off the optimization of just having a single atom (and perhaps, a single view to mutable application state)
against the need to use more complex keys when reading/modifying the atom's map value.
is there a good embeddable database here in Clojure land? I'm trying to slap together a simple CRUD service for my own use for organizing papers, tracking contacts and otherwise doing structured document storage and search.
The simplest thing that could possibly work would seem to be a heap of UUID named EDN objects and a browser.
@arrdem: I guess you care about storing the data yourself right?
@martinklepsch: I mean there's nothing security sensitive I intend to store here, but yeah being able to maintain local state and synchronize via dropbox or something would be nice.
I can hammer out a UUID heap in a few minutes but if there's something else compelling I'm happy to look at/hear about it.
@arrdem: I think for structured document searching, it's going to be hard to beat elasticsearch, but might be overkill.
yeah I've heard good things about elasticsearch and we're using it in prod here but I haven't had to really mess with it.
aggregations are super easy to consume in clojure, just some edn and results are a for-comprehension away.
@arrdem, there's https://github.com/tonsky/datascript, and then you could also use something like h2 (SQL), or neo4j if you are into graph databases 😛
yeah I think elasticsearch is overkill for this... my data is likely to be sufficiently small that I could probably make a single EDN file work 😛
I've gotten something to work with this: https://github.com/weavejester/clucy
For web development what are people using to manage their assets (e.g. compile LESS / SCSS, etc)? It seems like there are one-off plugins for these kinds of tasks, but I'm wondering if people are eschewing all that in favor of using tooling from other languages (Grunt / Gulp / etc).
@zane: I think #C053K90BR was built for these use-cases and is similar in architecture to gulp
@arrdem: you could probably make something nice using electron, allows you to access the filesystem properly so you can sync your edn files/client-side db
@gtrak: @zane targeting node or browser? I haven’t needed npm myself yet
@martinklepsch: hum... yes but learning JS/CoffeeScript is probably out of the time budget for this project 😛
@martinklepsch: webpack lets you use npm as a dependency manager but package for browser, same as browserify
@arrdem: you can easily make electron apps with CLJS
@martinklepsch: Browser.
@zane: @gtrak unless you have special needs I’d say you can easily make your way around npm when making cljs stuff
@martinklepsch: For this particular project the front-end is in vanilla JavaScript.
it's getting easier, especially with the recent work letting closure compiler consume other modules, but unfortunately for legacy-code and social reasons I won't be able to avoid npm, coffeescript, bower.
@zane have you seen: https://github.com/magnars/optimus
@martinklepsch: No, no I did not. 💖
@gtrak: you mean react plugins/addons type stuff?
@gtrak: it’s fairly trivial to make packages with deps.cljs
. probably only an option when npm isn’t already being used.
I should also mention we're transitioning from an ember codebase . I think it's nice that we're packaging stuff up for closure/cljs, but there are going to be cases where decent interop is truly necessary, the flexibility to have cljs consume other things, and the reverse.
Agree, it just sounded a bit like “you’ll need npm” and that didn’t seem right 😛
@martinklepsch: The problem I'd be trying to solve is how to avoid having to vendor everything.
gtrak: bad news, clucy is pretty old and upgrading to latest lucene isn't gonna be trivial 😐
ztellman: amusingly this seems to be a reflection issue that my recent work would fix...
I just got a pretty weird error from my Compojure app (https://gist.githubusercontent.com/mmower/3e8eb55ba4b5bdb94593/raw/3873ba6c40f93e78383fdd0c892ce38cf72584a9/gistfile1.txt) i’m commenting out code to try and figure out what i broke but I can’t see anything relating to my code in this stacktrace, anyone see anything I am missing?
@sandbags: you need to upgrade instaparse. They were relying on an internal implementation thing in Clojure, broke in 1.7
Updating compojure to latest should also work @sandbags
Okay so it looks like what's happening is that into-array
has tag ^"Ljava/lang/Object;"
which is strictly correct because anything is an Object however in the method call case I'm interested in it's not sufficient because there are two varargs methods which are more specific than Object so when Clojure emits a reflective method call with an Ljava/lang/Object;
there result is a no such method exception. Neat.
@arohner @martinklepsch thank you both!
Hi folks. I’ve got a question about compojure-api - does anyone have an example for setting Access-Control-Allow-Origin in my API ?
@shriphani: Should work the same as with regular compojure
@juhoteperi: I don’t see any ring middleware calls in the defapi macro examples so I am a bit confused.
(defapi app' ...)
(def app (-> app' (wrap-foo-bar)))