This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-16
Channels
- # admin-announcements (2)
- # bangalore-clj (3)
- # beginners (15)
- # boot (303)
- # carry (18)
- # cider (7)
- # cljs-dev (222)
- # cljsrn (103)
- # clojure (196)
- # clojure-czech (2)
- # clojure-russia (69)
- # clojure-spec (21)
- # clojure-uk (48)
- # clojurescript (68)
- # cursive (18)
- # datomic (185)
- # events (1)
- # hoplon (2)
- # lambdaisland (1)
- # leiningen (1)
- # mount (10)
- # off-topic (1)
- # om (14)
- # onyx (154)
- # parinfer (1)
- # pedestal (3)
- # planck (5)
- # protorepl (9)
- # re-frame (17)
- # reagent (27)
- # ring (2)
- # specter (58)
- # test-check (1)
- # testing (7)
- # untangled (59)
- # yada (35)
what do you think about this? http://www.dwheeler.com/readable/
anyone know/remember enough to help me get started with Lighttable/Koans ? (lighttable installed, koans downloaded, ran "lein deps" but instructions I have to hook lighttable to running/compiling koans don't work as given (from a clojur list msg)
isak -- if it makes you happy/comfortable, but there's always going to be some form of grouping even if it's just whitespace
i've gotten used to lisp myself, but i'm wondering if it would be a good idea since so many people get so hung up on the syntax
My first reaction to Clojur (only half joking) was 'not ENOUGH parens' -- now I understand the reason for the other bracketing types and it makes excellent sense
anyone know what I must be running to get lighttable to "connect"? Some form of repl but I don't know what/how to do that
probably means syntax like this from other lisps:
(case data
((tuple len 'ok msg)
(io:format "~s seems good.~n" (list msg)))
((tuple len 'err msg)
(io:format "There's a problem with ~s.~n" (list msg)))
((tuple len 'warn msg)
(io:format "Be careful of ~s.~n" (list msg))))
Though I still believe that all lisp programmers have been doing indenting "wrong" for 30+ years 🙂
When I started (and many times now when confused) I line up the parens much like C or someething similar -- different but open paren causes indent, close outdent, and no extra closing parens on a line UNLESS they line up vertically
yeah the conds get much better i think. This leads to using whitespace for clarity in big conds
@herbm: Trying to do the Koans in LightTable is a painful, manual process. They weren’t designed for that.
However, I think if you run the Koans from the command line — as explained in the Koans repo — and just use LT for editing, you might get on OK.
I saw a real nice youtube video on the Koans which showed them auto-eval and I wanted to try that as must as do the Koans themselves.
Still looking for a Clojure editor/IDE I can tolerate 🙂 Been using a text editor and the repl till now (week or so)
you'll get a lot of recommendations for emacs, i think i saw a recent update to atom's repl stuff that looked real nice, and there's light table. Sorry they haven't been tolerable but once you get used to one you'll probably move the editor to the background and not worry about it too much after that
I would honestly prefer to use emacs but I am on Windows and my past experienceces with it indicate that it's something that requires a LOT of 'care and feeding' plus almost daily use.
I get Vim but again, don't have time to work with it everyday -- learning Clojure and FP is enough right now
@herbm: hi 🙂 have you tried Nightcode?
@seancorfield: when we’ve taken newbies through the Koans, we’ve always gotten them to do it in Light table and they’ve found it pretty good
Nightcode, not yet -- I think my problem with Lighttable might be "spaces in path" stupid "program files" directories
daniel, any idea where good instructions for just getting Lighttablehooked up with a repl might be?
I have lighttble, lein, repl's running, but not connected -- so far just been using the stock repl for working through 4Clojure and various books
And hi clojuregeek, you are the one who got me started onthe 4Clojure problems at the local meetup -- thanks !!!!
I 've done almost all the easy (and elementary) ones, a bit over halfway by count, so I am starting to need a better debugger/editor more and more
@herbm: maybe tomorrow we can pair program and i can show you some stuff
Ok @clojuregeek, is "tomorrow" a meetup or something?
no, I sent you a DM 🙂
Lighttable/clojure is working, ast least partially. I had to figure out to expicitly run a "lein repl"
Don't know if that was right/best, fut lighttable can now run clojure code at least (also deleted lib\clojure-1.3.0.jar from inside the koans folders (lt was complaining about 1.5 or better), then I edited the projects.clj for 1.8.0, ran "lein clean" "lein deps" "lein compile" before the "lein repl :headless" no idea which helped. Just guessing
@herbm: I used emacs for clojure for a while a year or so ago on Windows, and it didn't seem to have any extra issues from the OS, so it might be worth trying if you are comfortable with emacs on another OS.
No, I love the idea of emacs but just haven't tolerated the key bindings and have never (on quite a few short attempts) gotten a satisfactory setup that I could use occasionally (ie., not daily)
I quickly fall back into using a more poductive and simpler editor to get my work done, or because I work on many machines (where emacs doesn't exist) etc.
Had to write some perl code on Linux last month, and used Vim just enough to see where it was going (still would prefer emacs due to elisp) but abandonded it for nano just to get the work done and because I wouldn't be on that long)
Actually would have used emacs over vim then but it wasn't on those machines and they were supposed to be kept nearly pristine (writing automatic build/deploy code for an enterprise deployment system)
How do I make lein use a local source code repository for a library I’m developing?
pupeno: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies
Thanks.
@mbertheau: no worries, share away
Any ideas how to tell figwheel to reload code in my checkouts directory?
Ah, found it. 🙂
specifically the WARNING: bounded-count already refers to: #'clojure.core/bounded-count in namespace: clojure.core.async, being replaced by: #'clojure.core.async/bounded-count
What are good reasons to use namespaced keywords when the context is narrow and clear and no collision is expected? The only usages for namespaced keywords I see is to avoid collision, to give context when it is missing, to work seamlessly with Datomic, and to allow auto refactoring of keywords. It makes my code extra verbal so I try to avoid it.
@raymcdermott: hows that (1.9prob)??
@hiredman: @dpsutton the usage for the namespace in keyword was for this piece of code: https://gist.github.com/borkdude/8d69f326b3d363a0b34e7b949b039992 so the problem here is, ns has to be flexible
@raymcdermott: core added a function named bound-count in 1.9 and core.async already had one
So you get a warning. It's not harmful.
Eventually we will update core.async
Post Free Clojure Jobs -> https://clojure.news/#!/job
@raymcdermott: actually I forgot that I already did update core.async, just don’t think we’ve released a new version yet
so next version will avoid the warning
@alexmiller: as I thought. Thanks Alex
@alexmiller: hope you don’t mind such reports here
there was a ticket for it btw at ASYNC-171 - that’s also a good way to report things so they don’t get lost but fine to ask here as I (usually) watch it
Is there a more concise version of (map first (take-while #(= (first %) (second %)) (map vector list-a list-b)))
?
@mbertheau: what about this?
(map first (take-while (fn [[a b]] (= a b))
(map vector list-a list-b)))
isn't that bad? if you want the first matching, don't you have to skip over "failures"?
Hmm, interesting case where a (fn)
with destructuring is more concise than an anonymous function literal.
this can also work, if you dont need take-while behavior:
(mapcat (fn [a b] (when (= a b) [a])) (range 5) (range 5))
@mbertheau: it’s pretty common for fn+destructuring to be more concise/readable than #(). Plus, you can give a name to fn’s: (fn same [[a b]] (= a b))
- this can aid readability and also influences the generated class name which is sometimes helpful when debugging problems
@alexmiller: Interesting point of view - thanks. 🙂
How can I get the fully qualified symbol for a Var? As in,
user=> var-reference
#'user/the-var
user=> (?? var-reference)
user/the-var
Hmmm… (symbol (str (.name (.ns var-reference)) "/" (.sym var-reference)))
seems to do it. Lifted from https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Var.java#L130.I'm a little stuck on what's probably a simple question: I have a hashmap of hashmaps, and I need to iterate through the main map, and pull out matching elements, and from them build a data element that I can pass to a json encoder. Iterating through the maps is easy, pulling out matching elements is easy, but my functional fu just isn't getting the "build a data element" to create a json of the results. I can do this easily in a dozen other languages, but for Clojure I get stuck.
Just not sure how to do that with a map (a) of maps (b) when the match is a key in (b)
Right now I'm doing it with doseq, more or less like this: (doseq [tok tokens] (doseq [t tok] (if (.contains tags (:tag t)) ; we have a match
What I'd like to do is take all those matches and build something I can feed to a json encoder.
If you use doseq, 99% of the time you’re doing it wrong 🙂 — that’s the procedural way, not the functional way.
if you have a map of maps, calling (seq my-map) will give you a sequence of them, which you can map or reduce over
if you have a sequence of maps, you want to reduce this down to a single map of stuff you care about?
99% of the time it's wrong for functional purism, yes. I'm open to suggestions to avoid them, but sometimes I just need to get stuff done and not worry about pure functional code.
then the function tags-i-care-about takes a map that you build up into, and a map that you look into for stuff you care about
but if you know what tag you want it nested down to, like if each map in the map of maps would dictate what key to put it in, then you could reduce it down to a single map
takes a while to remember that loop is map and one value from a collection is reduce
I would say the primary conceptual difference is that instead of writing “what to do” (procedural) you instead write “what you want” (declarative), if that makes sense. So instead of saying “go through the data structure and do such-and-such” you say “I want a version of the data structure that has been reduced in such-and-such a way”.
Makes sense. I think I just jump between too many languages in a day, with Clojure and Erlang the only two functional ones.
Re: languages— You could just stick with INTERCAL… https://3e8.org/pub/intercal.pdf
I’ll plug the #C16LEKSLT channel as a good place to compare & contrast different languages and styles.
I must admit that when I switch to another language, I often find myself trying to do Clojure-y stuff… ;;
for comments, no commas between arguments in function calls, putting the (
in the wrong place, expecting "statements" to return values…
I think we all have some of "programming in our other/best/recent language" when we switch. Some of that is even good. Once we learn near patters in a language we can sometimes usefully take those patterns to other languages -- just have to write a bit more code
Yeah, it’s pretty jarring whenever I have to write a bash script after a bunch of Clojure development…
That’s why we switched to #C053K90BR and do a lot of our script-level stuff as Boot tasks 🙂
I know the feeling, @radon. I just spent five days writing Erlang and Python, and now I have this Clojure piece. My brain will come around eventually.
not sure if this is the right channel for this question, but what do the folks here recommend for interacting with relational databases, clojure.jdbc/hugsql/yesql/korma? I need to at least support two different databases (postgres/mssql), so there’s that
@verma those are all good options, altho if you're targeting multiple DB vendors, yesql will have you write multiple versions of your queries
right, those "import SQL snippets as clojure functions" are great if you're targeting a single vendor
FWIW there is a #C1Q164V29 channel
people who have used ORMs like korma here, is there anything in particular you’d like to warn against? .. I do like the flexibility of writing plain old SQL but compatibility and maintenance tend to be a pain (at least with multiple databases over time).
for the most part, korma has no support for special features you'd want to use in pgsql/mssql
if there's a bit of vendor-specific syntax that it doesn't support that you want to use, you'll be fighting against it
on the other hand, it mostly lets you compose queries programmatically, so if you have bits of syntaxes that differ between various vendors, you can handle that bit yourself
@verma: bunch of discussion on #C053AK3F9 yesterday about jdbc etc, I believe @seancorfield created a Gist to demonstrate
@verma: What was the question? (to save me scrolling back — I just got back from lunch)
Ah, found it… well, I’m biased but I prefer clojure.java.jdbc
, augmented with HoneySQL if I have complex SQL reports to build (since that provides a composable abstraction for SQL).
I am strongly anti-ORM (I’ve even given conference talks about that position 🙂 ) and usually start that discussion by directing people to Ted Neward’s piece on ORM being the Vietnam of Computer Science 😐
@seancorfield: I've been meaning to convert a korma-heavy project to honeysql; how well does it handle non-standard SQL?
My colleague gave a talk at Clojure/West about our use of HoneySQL, BTW.
@oahner: I guess it depends on what "non-standard SQL" you’re talking about?
for the type handling it's easy, just extending ISQLValue and such which clojure.java.jdbc handles beautifully under the hood, but getting korma to actually generate sql it doesn't have macros for is... problematic
Honeysql has good support for sql functions and sql raw values. It has pretty good support for novel sql clauses.
@seancorfield: this clojure/west or a previous one?
I want to say 2015…?
It was one I missed so I wasn’t there to cheer her on.
I do two conferences a year so it was Strange Loop and Clojure/conj last year. It’s Clojure/West and Clojure/conj this year (first time I’ve skipped Strange Loop for years).
that Strange Loop thing is boring, I would skip that one
i'm gonna be lucky enough to do both both clojure west and conj, and also strange loop this year
I wrote up working through some compilation conflicts with Figwheel and Reloaded. http://seespotcode.net/2016/08/16/figwheel-reloaded/
@robert-stuttaford: ^ That's the result of your help the other day. Thanks again!
What’s the appropriate clojure and clojurescript for a library to require? The oldest working version? The newest one? None?
I'd be tempted to say the minimal version that has all the functions your library depends on
This is just a library for other people to use. I don’t want to force people to use old versions of Clojure.
if memory serves, you can depend on a library that depends on an older clojure version than your project depends on, but you can't depend on a library that depends on a newer clojure version
you can depend on a library that uses a newer clojure version than your own project, however you'll run into issues if that library uses features or functions that aren't present in your project's clojure version
@pupeno if you have the freedom to do so I would use the latest stable versions of both. Right now that’s Clojure 1.8.0 and ClojureScript 1.9.216
I think Clojure 1.7+ covers 90%+
@oahner: responding to an earlier question, HoneySQL handles non-standard SQL very well
Is there a way to make the {:keys […]} destructure work with name-space qualified :: keywords?
Yes or also you can destructured many keywords in :my-ns with :my-ns/keys
See CLJ-1919
Was added in 1.9.0-alpha8