This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-06
Channels
- # admin-announcements (266)
- # alda (20)
- # announcements (1)
- # aws (16)
- # beginners (16)
- # boot (288)
- # brevis (7)
- # cljs-dev (40)
- # cljsjs (32)
- # cljsrn (5)
- # clojars (23)
- # clojure (169)
- # clojure-art (2)
- # clojure-czech (3)
- # clojure-finland (1)
- # clojure-italy (3)
- # clojure-norway (1)
- # clojure-russia (88)
- # clojure-sg (3)
- # clojurescript (300)
- # clojurewerkz (8)
- # community-development (14)
- # component (4)
- # core-matrix (1)
- # cursive (9)
- # datavis (26)
- # datomic (44)
- # devcards (3)
- # funcool (1)
- # hoplon (7)
- # jobs (4)
- # ldnclj (11)
- # lein-figwheel (1)
- # nyc (2)
- # off-topic (4)
- # om (149)
- # onyx (1)
- # overtone (1)
- # parinfer (15)
- # proton (3)
- # re-frame (9)
- # reagent (45)
- # yada (2)
Sorry for butting in. Quick question about the reader and the forward slash in macros (regarding the namespace usage, http://clojure.org/reader, apologies if this has been asked…) Is it the case that because the reader cannot (?) be decorated you cannot pass /whatever to a macro? For example `(defmacro silly-macro [& forms] (str forms))` If anyone has a link, I’d love to read about it more…
Can anyone recommend a CSV parsing library? It needs to be relatively permissive, since many of the files deviate from the standard (and worse, they deviate in different ways).
I use data.csv frequently
Yeah, I found that and clojure-csv (which hasn't been updated in a while, but is not like csv changes much). I'll just try both and hope either one can read the malformed files
You could also look for Java csv parsers
Thanks. I think I'll start with this https://github.com/metasoarous/semantic-csv
@datamadic: for pasting in multiline code you can use triple single quotes `
forward slash is usually used as an accessor to some namespace: (def foo (some-ns/bar ...))
@datamadic: and by all means, feel free to butt in with whatever questions you've got - that's what slack is for
I guess I don't understand what you intend /what
to represent in your example. It seems to me that it doesn't matter that you are passing it to a macro or just a regular function. Clojure has to figure out how to resolve /what
and I'm not sure that's a valid reference, but I could be wrong.
i found it interesting that even to a macro (supposedly un-evaled forms) still get processed a bit. I mean it makes sense, you have to go from text to data struct somehow
then i was wondering if you can override that behavior at the reader level. All of this is motivated by me wanting to copy and paste a bit of html into clojure (not as a string) and spit it out as a template (I know there are better ways to do this, this is more of a learning exercise for me)
@alexmiller: What's up with the Clojure/West CFP topics?
Actually, I was glad to see that on the list as I was thinking about submitting a proposal for something related to the artsy stuff I've been doing.
That would be welcome :)
I mean, I just added core.matrix to my project dependencies - that's pretty serious stuff there.
@alexmiller: I'm going to do it. I think it's time. Been too long since I've been to a tech conference. I'll probably ask for a mentor as well. Why not.
hi guys, I have an idea that I will walk through datomic schema, then get value type, then generate ui based on that information. But I haven't used walker before, is there any good tutorial about it ?
Trying to code a CRUD webapp and need to represent the database schema. I have come up with something like this https://gist.github.com/martinskou/a765f29b9e4089a823f2 and could use some feedback or alternatives.
How can I unquote forms in project.clj
? I'm trying to use ~(System/getenv "DATABASE_URL")
inside of the defproject
form in project.clj
, but I'm getting this:
Exception in thread "main" java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/unquote, compiling:(/private/var/folders/g2/b9wxt05j1wlg7cs_0hr26ktc0000gn/T/form-init8842813568841950115.clj:1:125)
That should work. At least it seems to in an old project of mine: https://github.com/ShaneKilkelly/jetcan-server/blob/master/project.clj#L65
Are you using it in the same way?
@shanekilkelly: yeah this is actually also for migratus, but it's not working for me for some reason 😞
drat, can you show us your project.clj?
Ah, so the quoted form needs to be at the top level
@martinskou: how meaning to first char of keyword is uppercase ? https://gist.github.com/martinskou/a765f29b9e4089a823f2
@nxqd hi. I am building some kind of a crud generator here: https://github.com/sveri/closp-crud it is still considered alpha, but if you got some time to look at it, i would love to hear opinions.
to understand how the special forms work you'll have to read Compiler.java
, which unfortunately is not so easy to read/understand
LispReader.java
is the reader. if you'd rather read the clj version of that, try reading tools.reader
's source code
there's no official clojure-in-clojure effort, tools.reader
is part of a set of contrib libraries that reimplement/rearchitect the infrastructure around the clojure compiler in clojure
I read this and thought it was somehow in the works http://dev.clojure.org/display/design/Compiler+in+Clojure
I know there are parsers (combinator or otherwise) for strings. Are there parsers for sexps? I remember Cursive's creator talk about implementing something that for Cursive, but a cursory Google can't seem to get me a library that could do it (or I'm blind).
@jcomplex: EDN is just like JSON but using Clojure's syntax and primitive-data-type semantics.
@jcomplex: for more info, see https://github.com/edn-format/edn
I’d say rather that edn is just the data structures part of clojure
Is there something specifically you’re looking for help with, @jcomplex?
@donaldball: but its main domain is the same as JSON's: data transportation
@jcomplex one of the Datomic training videos has an overview of EDN, if you'd rather listen than read: http://www.datomic.com/part-ii-the-datomic-information-model.html
I'm reading about mount, and it looks pretty awesome. I'm not sure if the author is in here, but the docs are very well done. Congrats.
Good to know! I'm definitely giving it a try on my next project. My current one has component's tentacles in it.
Component is all nice and good and then until the code starts looking more like Java than Clojure : V
@ghadi: couldn't figure out how to do groups with seqex, this one has that described in the readme.
Less tongue in cheek - https://github.com/jarohen/bounce
so, I feel stupid asking this, but that generally means it’s a question I should ask: what is so OO about component?
or maybe to slightly reframe it: what is it about component that bothers people such that they qualify it as more "OO-like” than other solutions?
reading this https://github.com/tolitius/mount/blob/master/doc/differences-from-component.md
I don’t find that a good critique either. I tend to find that clojure embraces objects when they’re useful, e.g. when encapsulating state; it just doesn’t hold that every domain entity merit a bespoke class.
On another front: has anyone run across a good clojure library for rendering graphs of data structures as e.g. a uml diagram?
Loom might have what you're looking for: https://github.com/aysylu/loom
Very nice, thanks
@donaldball: If by 'rendering' you mean to create images of them, Rhizome may be what you are looking for: https://github.com/ztellman/rhizome
Hey all, I have a leiningen question, I guess. If I load a file in the repl, then delete a function from it and reload, the repl still has the function available and returns whatever the latest implementation was. Is this normal?
@ddellacosta, @ghadi, @donaldball: subjectively speaking, I prefer using values and functions over objects - Component seems to shoehorn people into wrapping everything up into a defrecord
@sdroadie: yes - although you can (remove-ns 'your.namespace)
before you reload the file to clear it out
there are tools to do that transitively too (i.e. reloading all of the namespace that depend on the namespace you've just changed) - clojure.tools.namespace, in particular
see http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded and https://github.com/stuartsierra/component
@ddellacosta, @ghadi, @donaldball: it then seems a reasonably common (anti-?) pattern that every time a function needs to use a dependency, those functions then get wrapped up in a Component (maybe to take advantage of the DI?), which then propagates up the call stack
(should say, of course, that this is just based on what I've seen when talking to other people at work/conferences/dojos/down the pub, but to me it seems reasonably common)
having said that, I do seem to recall someone mentioning in a blog post/conf talk that you should only make a Component to encapsulate either state and/or lifecycle, and hence avoid these 'transitive' components
@ddellacosta, @ghadi, @donaldball - it is a simplification, that's for sure, but I wouldn't call it a strawman. When writing code with component you're basically left with two choices - you either write code inside a defrecord
as to close over components you depend on so you can refer to them easily in the function bodies or write functions externally to the defrecord
and have to pass a component and destructure it to get at it's contents in each function that depends on it. Both options result in Clojure that can feel awkward - first option makes it look and feel like a parenthesised Java (hence "too OO"), the other is repetitive and verbose.
@jarohen @jaen thanks for the explanations. jaen, I think that’s the clearest explanation I’ve seen yet, thank you
@donaldball: We've got a #C0F0V8DT5 channel as well where we talk about, you know, data visualization stuff
I guess the approach I’ve tended to take to that problem, @jaen, is to lean heavily on protocols to describe the service(s) provided by the stateful components, coding against those protocols in the business fns, and rely on component to wire up a system of the form I want at the time e.g. for production or repl use, or maybe just reify simple impls for unit tests of those business fns. That has tended to work out pretty well for me, though I reckon it probably does break down for components with really broad responsibilities?
Anybody know how to make lein deps :tree
work when a dependency is missing? The whole reason I want to use it is to see what’s bringing in that missing dependency!
Well, broad responsibilities would be a SRP violation anyway, so there's that. And I suppose (defn something [db id] (proto/retrieve db :user id))
can somewhat alleviate the need to destructure. It's just probably me being uneasy with using a lot of polymorphism then.
@snowell: lein deps cannot know a dependency unless it is specified in pom.xml
. the compilation stacktrace should point to the offending file though right?
And if I try to do my lein deps :tree > some_file
it only outputs that error instead of a tree AND that error
Well for now I can stick the offender in :exclusions until I determine I actually need it. Dependency hell is always fun /s
Hi all, does anyone else think frequencies
would benefit from having a variant with arity 2? The additional argument would be the initial map of frequencies, defaulting to {}
JIRA ticket welcome https://groups.google.com/d/msg/clojure-dev/09VUlcA5lJg/Bfd04PWenYAJ
are there any mature and feature-rich migrations frameworks on the JVM that would compete with rails migrations?
@djanus: I've recently felt that frequencies
was very specific and wonder if it couldn't be generalized.
(defn hashmap-set
[keyvals]
(persistent!
(reduce
(fn [ret [k v]]
(assoc! ret k (conj (get ret k #{}) v)))
(transient {}) keyvals)))
Not crazy about the name and maybe someone has better code for this but I just need a map with sets as the values.
Both solve very general problems in a way that didn't exist in clojure core, yet clojure core has frequencies
which is such a specific use case. Not trying to start a "why isn't this in core" argument, just wondering if there are some patterns that could be explored and exploited.
I've come to rely on into
as my go-to swiss-army-knife of data transformations, in part because of the transducer variation when needed.
I'm sure others have written very similar functions as the ones I posted here. I just think it would be nice to have something concise but open-ended enough to feel as comfortable and handy as into
, my poster child example.
Once I got used to into
it has come in so handy my code is full of example uses of it. And I recently converted a bunch of code someone else had written and I replaced every single loop/recur
with either into
or into
with some for
comprehensions. And at least for me the code is so much smaller and easier to understand.
I really hesitate to write these little helper functions, like hashmap-set
and zipmapf
because I know that for anyone else reading the code they won't have anywhere near the initial understanding of what these functions do compared to a function from clojure core.
@meow: I wonder if instead of hashmap-set
if you could write a transducable group-by
fn like
(defn group-by-into
([to f from])
([to f xform from]))
So in your example you would implement hashmap-set
like (group-by-into #{} key (map val) keyvals)
Not sure if better!> Both solve very general problems in a way that didn't exist in clojure core
I must say I never understood why there's no zip
and you have to do (map vector ...)
.
I kinda understand it - there's less incentive to write zip
if you have vararg sequence functions
But sometimes I wanted to use zip
with for
for example (where specifying two sequences would result in Cartesian product and not side-by-side iteration).
you know, I looked at those a while back but haven't done so recently - will do - definitely good stuff there
I am 99.9% sure its a bad idea and should be forgotten about (its not something I've used, I just looked at your fn and your comments about into
).
However, the key take away is perhaps it'd be nice to have better tools for pouring collections into associative structures if you want to be able to say, group into sets.
Yeah, I'm definitely going to take a real close look at cgrands stuff because he is hella smart and because I think I see a variety of transducers that relate to stuff I might need in my current project.
there aren't a lot of helpers in clojure that really encourage making positional things easy -- rather to favor associative, yada yada