This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-19
Channels
- # announcements (5)
- # beginners (68)
- # boot (1)
- # cider (27)
- # clara (11)
- # cljdoc (10)
- # clojure (129)
- # clojure-europe (2)
- # clojure-italy (16)
- # clojure-nl (15)
- # clojure-spec (74)
- # clojure-uk (31)
- # clojurescript (62)
- # core-async (17)
- # cursive (28)
- # datomic (22)
- # duct (29)
- # emacs (10)
- # fulcro (65)
- # hoplon (2)
- # hyperfiddle (16)
- # instaparse (3)
- # kaocha (2)
- # lein-figwheel (3)
- # leiningen (1)
- # mount (1)
- # nrepl (21)
- # off-topic (23)
- # re-frame (59)
- # reitit (18)
- # ring-swagger (2)
- # shadow-cljs (2)
- # spacemacs (16)
- # timbre (2)
- # tools-deps (22)
I haven't used rewrite-clj before, but am aware of its existence, and it might be in the neighborhood of tools you are asking about: https://github.com/xsc/rewrite-clj
Hmm, thanks - in this case I don’t need formatting preservation. Genetic Programming has some useful stuff: http://www.thattommyhall.com/2013/08/23/genetic-programming-in-clojure-with-zippers/
Question - I'm using Clojure-future-spec aplha17 and just migrated to Clojure 1.9 and I get: Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.future/ident?
Anyone knows about this?
@didibus You might want to be a bit more specific about what you actually did to cause that exception. I just tried clojure-future-spec
with clj
and 1.9.0 and it seems to work...?
Ya, it seems it is thrown when doing Class.forName("clojure.java.api.Clojure");
from Java
Actually, I don't know. It is pretty strange, I get the error when I'm compiling my java tests
What was the name of that tutorial site that teaches clojure through drawing with a graphics library online?
no, it was a live coding site, with rows that had a tutorial and the code you typed would draw shapes on the right side
I read that book though 🙂
@U1CUUKHDL the intro to the maria IDE? "learn clojure with shapes" https://www.maria.cloud/intro ?
Yes! I do remember it was a femenine name, I even got to trying "sophia" lol
I have to check out Maria. I enjoyed the time I spent typing into Power Turtle. 🐢 http://timothypratley.github.io/power-turtle/
@jonoflayham Thank you very much I solved the issue.
No problem publishing small files here, but more common to publish links to things, when you know them, e.g. https://clojure.org/api/cheatsheet which also has a link to this page, with other versions: https://jafingerhut.github.io/
Has anyone seen an expect like tool or library, written in clojure? I want to say I ran across one a while back, but my google-fu is failing me at the moment.
For testing? If so, there’s https://github.com/clojure-expectations/expectations
expect is a library for driving programs that communicate via stdio - basically it allows automating anything that provides a "repl" or "command line"
I started work on a clojure expect once but didn't get very far
I have a lazy sequence of vectors. I want to flatten this structure (to lazy sequence of vectors' elements), while retaining the lazyness.
Is there a core function for this?
The only ones I've seen use varargs, which would require an apply, which would realize whole lazy sequence
@roklenarcic Maybe you could try (mapcat identity ...)
?
I think that's just (apply concat (apply map
under the hood
I guess straight up flatten would work if vector elements aren't sequential
(sequence cat col)
would work. If you're doing a pipeline you can just add cat
into any transducer pipeline you're composing to flatten it one level
Hi! Is there something like contains-in?
-- something that tells me whether a subsequent get-in
will come up with something, just like contains?
tells me whether get
will work?
Hi everybody. Is there an equivalent in deps.edn
for Leiningen :repl-options {:init-ns ...}
settings? In other words, can I start the the REPL into a specific namespace?
clj -e "(ns clojure.set)" -r
:)
Sometimes vars are used instead for a little more indirection in places where you don't want to hold on to just a function value (because you want to redefine the function).
For example (inc 1)
and (#'inc 1)
both work, but if you have a case where maybe this is in a map
{:my-fn inc}
you can dynamically get new behavior if instead you hold onto #'inc
@Audrius If by "how this form is called" you are asking "how do people refer to it when speaking to each other", it is sometimes called a var quote
http://www.javamagazine.mozaicreader.com/NovemberDecember2018/Default/15/0#&pageSet=18&page=0 => Java has 90% market share of JVM languages, nothing new about that. But I was a bit (positively) surprised that the second popular JVM language is Clojure, not Scala or Kotlin.
What do you think about Clojure's future? I have tried to convince some colleagues to use it in our corporation with some success.
Clojure is a great language. the stuff that makes it great to me is the stuff that made 1.0-1.8 great. so new changes etc are either very nice and welcome or irrelevant to me. and the core good stuff that make it a great language won't be changed since the stewardship is so great
sample size is quite small and these kind of surveys are usually not really representative of the reality
sample size was like 10k in this one wasn’t it? that’s actually pretty big imo (the annual Clojure survey is usually about 2k)
@kari.marttila the truth is that only you can and your organization can decide what technologies to base your business on and different people will make different choices based on their own needs and situation. Clojure is not going anywhere and is a viable option. I personally think it has vast advantages over some of the alternatives, but you should consider the tradeoffs as well.
Sometimes people compare languages and fail to distinguish between value and trendiness. Clojure may look trendy at some times and not-so-trendy at others, but it provides solid value for organizations that use it, and for that reason it has a future regardless of fashion.
Clojure has always put a lot of effort into reducing the cost of change in your code over time. That has tremendous value to businesses but is sometimes difficult to communicate or to see in small or initial projects.
I really like Clojure, but I'm afraid it will gain a lot of users in the near future is pretty slim. A lot of Java developers seem really 'afraid' if the parentheses. Also to many people seem to put great value in having a big company backing a programming language.
From my conversations the main friction has to do with programming philosophy and education. Eg. they are happy to use a language that has far fewer delimiters if it uses a conventional object-oriented design
and I was horrified to see what happens when a java programmer figures out records and protocols before they internalize the basics of clojure...
Languages don't "need" to be mainstream-level successful tho' these days -- we have a lot of choice -- and if you stay on the JVM, being polyglot in a large company makes sense: let teams use whatever language they want, as long as everyone can call each other's libraries...
I think it's generally easier to convince people to switch something that looks similar to what they already know - when I used to work primarily with Ruby, most of my colleagues were eyeing Elixir as an alternative, now when working with Java it's mostly Scala or Kotlin
@gklijs IIRC, Java and Clojure have the same number of parens (in some cases Java has more), it is just the placement that is different.
@noisesmith Agreed. The biggest obstacle to Clojure -- and to FP in general -- is the mental shift from OO based on mutable state.
@mafcocinco Yup, obj.foo(bar,quux);
=> (foo obj bar quux)
-- but it's surprising how many people find that a "hard" transformation to perform in their head 😐
indeed. it can be difficult when you have been doing OO for so long but it is definitely worth the investment. Personally, the amount of cognitive load was significantly reduced not having to remember different calling conventions.
that's true for me too, but I think it's a question of which you learned first
I would agree as well, but my core CS education was in Scheme and ML. I learned OOP the end of junior year/senior year of college and then had to use it for some 10 years at my first job.
could be. I learned FP and OO just some weeks behind each other at uni. FP was much more simple to me.
maybe "found fluency with first" rather than "learned first"
Perhaps. My personal feeling is, placed side by side in front of say first year Comp Sci majors, most people will find FP easier to understand. What makes in challenging (opinion, no evidence) is the baggage of OOP.
Clojure is more disciplined than most higher level languages I've seen in not having special cases to remember. There's still special cases, but they are remarkably rare.
I hope all the best for Clojure's future - Clojure is definitely my personal favorite language. Lisp REPL is the best productivity tool I have ever used.
But in a big corporation you cannot always choose the language used in the project. However, I try to promote Clojure every time I can.
in a corporation you often have to code things in a language 1) your team knows or has time to learn, and 2) it's easy to hire for or find more people to maintain. You're sometimes limited in what languages you can use by the "bus factor." Lisps always have to contend with this because the syntax looks scary to the uninitiated, but it seems like they always carry on regardless by picking up a following of talented devs
and clojure does a great job of being FP-first but supporting other paradigms where needed, which you can't say about a number of other FP languages
Echoing Sean's comment above, I think that while you may hear complaints about syntax and think they are superficial (and I would agree), there are significant hurdles to people, including me, who are used to writing imperative for loops with if conditions inside of them, all day, to iterate over arrays or lists, and then to switch to Cloure, and just feel stupid that you don't know how to do really basic stuff.
That stupid was directed at my own remembered mental state, not anyone else. Maybe a better way to say it is: you feel like you went down multiple notches in competency all of a sudden.
it's a sub-optimal skill tree strategy in the short term :D
Question, if I have a map
clj
{"FirstName" {:value "asdfas", :invalid? false}
"MiddleInitial" {:value "a", :invalid? false}
"LastName" {:value "asdf", :invalid? false}
"EmailAddress" {:value ""}
"PrimaryPhone" {:value ""}
"DateOfBirth" {:value ""}
"SocialSecurityNumber" {:value ""}}
`
And I want to return the keys and the :value
in the nested map how would I do so?
Example output
clj
{"FirstName" "asdfas"
"MiddleInitial" "a"
"LastName" "asdf"
"EmailAddress" ""
"PrimaryPhone" ""
"DateOfBirth" ""
"SocialSecurityNumber" ""}
I tried using doseq
but it seems to be geared more towards side effects
(doseq [keyval map-to-destruct] (prn (key keyval) (:value (val keyval))))
Thanks @noisesmith
that fn
could be replace by #(update % 1 :value)
but I think the fn version is clearer
(reduce-kv (fn [m k v] (assoc m k (:value v))) {} {:a {:value "a"} :b {:value "b"}})
is how i would do it. not a big fan of updating vectors positionally
@jacob.haag I use clojure.algo.generic.functor for stuff like that
it's different because mine uses transducers - but the behavior is the same
It amazes me how easy it is for users to extend Clojure. In just a few lines of code, I just added the ability to leverage isa?
hierarchies (and prefer-method
-like disambiguation) in my predicate dispatch example on SO: https://stackoverflow.com/questions/53329709/dispatching-function-calls-on-different-formats-of-maps/53354967#53354967
By dispatch on [1]
do you mean being able to do the implicit (nth [0 1 2] 1)
when 1
is passed to [0 1 2]
?
Oh no, you mean actually dispatching on [1]
... you're supposed to supply functions, not equal vals, so you're supposed to provide #(or (= % [1]) (= % [2]))
in that case.
and you could theoretically just pass one of the spec validator functions as a predicate
I made a version that memoizes args->poly-fn
for a given poly and invalidates the cache when another defpoly
is called with that poly, but that's a pretty big hammer.
Has anyone run into an issue with require
'ing a namespace in multiple threads, one thread marking the ns as loaded before it is actually complete causing another thread to think the code is require
'ed resulting in a function call occurring before it's ns is loaded, ultimately producing java.lang.RuntimeException: No such var:
exception?
@kenny Yeah, FWIW, the ClojureScript compiler guards against that: https://github.com/clojure/clojurescript/commit/0d52cf27d73444508ad2e75d94e0345e426dcaa9
The ClojureScript compiler started having this issue, I believe, after parallel compilation was added to it. (IIRC, when compiling ClojureScript code in parallel, there is a possibility that one namespace might cause a compilation thread to require some Clojure code—for macros—while another races with it). Regardless, you can see that the ClojureScript solution serializes all requires.
hello, using deps.edn
I'm trying to override a dep from maven (that comes from another dep) with one in git, but when I try I'm getting Unable to compare versions for
, is there a way around this?
@wilkerlucio How are you currently trying to "override" the dep?
by adding on my project deps, like:
camel-snake-kebab {:git/url ""
:sha "865416c2cec019cee92d8d3892d20a64559a4054"}
(tools.deps cannot compare versions from different providers because they have no ordering)
You'll need to add an alias with :override-deps
to specify the Git version (and then specify that alias when invoking clj
)
@seancorfield thanks, that works 🙂
Cool!
(we use :override-deps
heavily at World Singles Networks to "pin" versions of all the libraries we use in multiple subprojects)
@seancorfield speaking of, have you had any luck with private git repos? initially I ran into this problem https://dev.clojure.org/jira/browse/TDEPS-31 but after performing the workaround in the linked blog post, it also decided it didn't like my ssh key (I tried both my initial ed25519 key and then an RSA one, both loaded into my ssh-agent, to no avail)
I haven't tried it with private Git repos, sorry.
@U9QQRN612 delete http://gitlab.com from your known hosts file before running the workaround.
I still have some tinkering to do - in the meantime I just went back to using a local version
Is there a good sqrt function for BigInts in an existing Clojure package?