This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-28
Channels
- # aleph (1)
- # announcements (16)
- # bangalore-clj (1)
- # beginners (78)
- # cider (109)
- # clara (3)
- # cljdoc (6)
- # cljsjs (3)
- # clojure (209)
- # clojure-dev (11)
- # clojure-europe (1)
- # clojure-france (9)
- # clojure-italy (13)
- # clojure-nl (3)
- # clojure-spain (2)
- # clojure-spec (19)
- # clojure-uk (50)
- # clojurescript (41)
- # clojutre (2)
- # core-async (45)
- # cursive (2)
- # datomic (14)
- # emacs (6)
- # figwheel-main (1)
- # fulcro (101)
- # graalvm (1)
- # graphql (3)
- # jobs-discuss (3)
- # kaocha (12)
- # leiningen (8)
- # music (4)
- # off-topic (47)
- # parinfer (8)
- # pathom (17)
- # pedestal (53)
- # re-frame (47)
- # reagent (22)
- # reitit (4)
- # shadow-cljs (49)
- # tools-deps (87)
what was it?
The error was because the :plugins
key value was incorrect. Just a single vector instead of each of plugin being its own vector
wow, the dark side of pure data driven DSL
#beginners might not be the right place for this question ... but, I'm pulling in AsciidoctorJ
(java bindings to a ruby gem called asciidoctor
) through tools.deps
and there's a gem that provides additional functionality ... is there a way to have tools.deps
use JRuby to pull in the gem so it can be used?
@johnjelinek it looks like jruby is on maven, so you can pull it in as a dep, the next question is how to invoke it to make it pull in and run a gem https://mvnrepository.com/artifact/org.jruby/jruby-complete
that might be more of a jruby question - I assume they have a java api, and if that exists clojure can use it via interop
for comparison, with clojure, you could depend on the lib via maven and it would in turn depend on clojure, allowing you to invoke clojure and run the lib
one would hope jruby allows something similar
So, it looks like AsciidoctorJ comes with an internal JRuby that can resolve gems, but those gems still have to get in there somewhere. I guess maybe there's a way to call the bundle install
of JRuby from within the Clojure process?
hopefully JRuby provides a way to invoke that via interop, if so you can do it from Clojure
a brief google search makes it look like the jruby bundler isn't tied to maven at all, so tools.deps wouldn't do anything with it, but you could definitely script a bundler call into a build process that uses tools.deps to find clojure / maven depenencies
tools.deps intentionally isn't a building or packaging tool, it's just for finding jvm deps
on the other hand, lein does intend to be a packaging and building tool, and does have a plugin for jruby (I can't vouch for the quality) https://github.com/jkutner/lein-jruby
I'm making a japanese learning application, right now I'm working on drills
So that I can test people for things in an automated way
Repeat it until you get >80% or whatever
{:は "Mr. Tanaka", :から "Japan", :verb "is."}
I have some example maps of potential sentences. The pairs of word+particle, represented in the map as matched :k "v" pairs can be in any order, as long as the verb's at the end.
Not all the maps have the same keys...
(particles)
should I be striving to name all the keys in the map the same?
like :word1 :particle-for-word1
:word2 :particle-for-word2
or can I name them :particle1 word1 ... :particle2 :word2 ... not every map has every potential key i'd be using, just a small subset
@noisesmith: ya, I'm trying to not use lein as much as possible ... and I've been using tools.deps
as my task runner with :aliases
@alexmiller: hey hey, I'm workin' through Clojure Applied
. Page 53, I've run into an error:
user=> (take 5 (sort (map (:name planets))))
Execution error (IllegalArgumentException) at user/eval6461 (REPL:1).
Don't know how to create ISeq from: clojure.core$map$fn__5862
this works though:
user=> (take 5 (sort (map #(get % :name) planets))) ("Earth" "Mars" "Venus")
so does this:
user=> (take 5 (sort-by :name planets)) ({:name "Earth"} {:name "Mars"} {:name "Venus"})
You have ( ) in the wrong place
(map :name planets)
not (map (:name planets))
(map (:name planets))
tries to select the :name
from the collection planets
which will produce nil
and then (map nil)
is the 1-arg form which produces a transducer.
Hence the error: trying to create a ISeq
(as the argument of sort
) from that transducer (which is an anonymous function from inside map
)
user=> (take 5 (sort (map :name planets))) ("Earth" "Mars" "Venus")
It's listed as a known issue in the errata: https://pragprog.com/titles/vmclojeco/errata
Is there an editor that offers automatically adding imports in clojurescript? especially adding libraries from javascript like material-ui? It's killing me having to type manual requires in when I need to use a button or something.
how are you importing them? do you know of [my.lib :as m]
, allowing you to refer to them as m/button
?
@UCW9TUDNK yup, what I'm hoping though is to not have to type any of that. I. typescript or kotlin when you use something from another library or package that you haven't written the import for, intellij will just automatically add the import for you. I'm pretty sure cursive can do this for Clojure, but not clojurescript
it would probably be best to ask this in the specific channel for your editor. (I recommend Cursive if you aren't attached to any specific one.) If it doesn't support this, a simple helper could be creating a snippet for the ns declaration that already includes the requires you usually type in.
or is this what the cljsjs projects are supposed to solve? providing namespaces and function definitions for javascript libraries?
sorry if this is a dumb question, but here we go: i have some values (in a list), where every one is one of a list of possible values (the status of a server, so "starting", "stopped", etc). These options have a specific order, and i need to find the entry in my value-list that comes first in the list of options. in java/kotlin, i would use enums for that, and have an enum entry for every option and then just sort. how do i go about doing this in Clojure? is there some idiomatic way to achieve this?
@lkowarschick you can do like this on Clojure, there is no enum like java on Clojure. All Clojure data structure (collections or map) is seq-able and you can iterate every element on it.
thanks for your time ;D my solution ended up being really simple:
(def states ["STOPPED" "STARTING" "RUNNING"])
(defn worst-status [stati]
(first (filter #(.contains stati %) states)))
After installing clj
according to https://clojure.org/guides/getting_started#_installation_on_linux, I cannot get the REPL up. The clj
command is unresponsive for a good minute and then spits out a big Java stacktrace, the key part is Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.clojure:clojure:pom:1.10.1 from/to central (
I'm very certain this is due to corporate network proxy. What's the recommended way to tell clj
about my proxy settings?
you can use maven proxy settings
In https://clojure.org/reference/deps_and_cli grep for Maven proxies
does anyone have examples of passing specs to defrecord
?
user=> (clojure.repl/doc defrecord)
-------------------------
clojure.core/defrecord
([name [& fields] & opts+specs])
Macro
(defrecord name [fields*] options* specs*)
Those specs are not spec specs
Specs there are referring to protocol/interface implementations
Hey, so I have a simple question. In Clojure, we use foo/core.clj(s)
a lot. However, when it comes to dependencies, what are the best practices? Should foo/core.clj
:require
things in it's folder, or should it act as a common
file intended to be included by others?
I'm neatening my file structure today, and was wondering whether db/core.clj
should contain common functions, or whether db/core.clj
should act as a single thing to require that handles your things for you. Any ideas?
arguably the ubiquity of "core.clj" is just circumstantial - it's a default with lein templates because single segment namespaces are problematic and some generic name was needed
ideally you can have a namespace with a more meaningful name
that said, if present, people expect the "core" ns to be top level, I think
I'm glad I chose right then 🙂 Thank you again!
the canonical example would be clojure.core (the top level clojure ns of clojure code, implicitly used if you use the ns
macro to create a namespace)
Hi. Sorry if the question is dumb enough, I do try to learn here.. 🙂
I have a timestamp value which I got in the way like that let [timestamp (java.time.LocalDateTime/now)
. How do I format the value to something like yyyy-MM-dd'T'HH:mm:ss
afterwards ?
java.time times usually use that kind of format as their default if you just call str
or .toString
on them
if you want to be explicit (.format (java.time.format.DateTimeFormatter/ISO_LOCAL_DATE_TIME) (java.time.LocalDateTime/now))
(I'm not familiar with java time yet but this seems to be a straight forward way. maybe someone more java interop-y than me can comment on how they'd do it
the parens around the ISO_LOCAL_DATE_TIME are optional btw, it's a field, not a method
I mean, (Math/PI)
is valid too, but it's weird
Thanks to all of you! However, I am still on figuring out how to "connect" the answer to my own needs (the test which is currently failing). At the moment I went to read some more info on the data/time in Java and Clojure. Hope to improve on the topic soon 🙂
none of this is Clojure specific (beyond interop syntax which applies to everything we get from Java)
which do you prefer: PersistentQueue or a channel?