This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-17
Channels
- # aleph (7)
- # announcements (1)
- # aws (12)
- # beginners (118)
- # calva (15)
- # cider (17)
- # clj-kondo (1)
- # cljdoc (11)
- # cljsrn (1)
- # clojure (108)
- # clojure-dev (32)
- # clojure-europe (3)
- # clojure-italy (4)
- # clojure-kc (1)
- # clojure-nl (4)
- # clojure-portugal (1)
- # clojure-spec (29)
- # clojure-uk (69)
- # clojurescript (91)
- # cursive (14)
- # datomic (8)
- # emacs (13)
- # figwheel-main (12)
- # graphql (4)
- # jackdaw (1)
- # jobs (14)
- # lambdaisland (3)
- # luminus (3)
- # nyc (1)
- # off-topic (14)
- # onyx (23)
- # pedestal (8)
- # re-frame (4)
- # reitit (3)
- # shadow-cljs (6)
- # spacemacs (7)
- # specter (2)
- # tools-deps (3)
- # unrepl (4)
- # vim (7)
- # xtdb (10)
Is clj different from "java -jar clojure.jar"? I created deps.edn but the dependency is not picked up with "java -jar clojure.jar"?
clojure doesn't come with any dep resolution
also, newer versions of clojure need at least one other jar (for spec) so can't just run with clojure.jar
they need two - spec.alpha and core.specs.alpha
ahh, I always conflate the two
as outlined in the clojure readme, there is a build profile to build a local clojure uberjar (including the spec jars) that can be invoked with java -jar. we intentionally do not publish that anywhere.
so yes, clj is different from just using java on clojure.jar
When you run the java
command like that, it has no reason to read your deps.edn file at all, and will ignore its contents.
The clj
and clojure
commands look for and read deps.edn
files.
well, in an alternate implementation if deps were part of clojure.core, it could - but deps.edn is not part of clojure and it doesn't
incidentally, this would require clojure to depend on 9000 maven libraries, so you should be glad it's not included :)
yeah - not saying it would be a good idea at all
I dont want to install clj on windows as that will require extra permissions I just want to copy or build and run clj?
It only requires the elevated permission for the install -- not for general running -- I have the Powershell version installed on both my Windows machines.
you could make your own uberjar with the deps you want pre-bundled
I liked the idea of editing deps.edn to add the deps so If I want to add new deps I need to do uberjar again
Is there an idiomatic way of joining two things where both can be either a collection or a single item? (Impractical approaches also welcome, as long as you point them out!)
the best thing is don't allow that kind of polymorphism, but when you can't choose (eg. comes from input following a spec you don't control) you probably want to start with a coercion function that checks for coll?
and then wraps in a collection if it isn't one already
there's also seqable?
but that eg. thinks "foo" is a collection of characters (hardly ever what you want)
coll? works for the built in clojure collection types, which is what you'd usually see in clojure code anyway
That's what we're currently doing, down to coll?
!
I was mostly hopeful there'd be a better way... thank you!
yeah - I think the fear was that if (fn [x] (if (coll? x) x [x]))
was provided it might make people think code like that is a good idea (it's not, but sometimes when bad data is coming in it's the least bad option)
I thought you're referring to http://clojuredocs.org/
@ramblurr Assuming you can run a REPL while you're offline, all the docs are available in the REPL -- because they're part of the code -- via doc
, find-doc
, apropos
etc.
i think cursive downloads them for you and displays them with control-Q. some info here: https://github.com/clojure-emacs/cider/issues/2663
If you want an app that provides offline documentation, take a look at Dash -- for macOS and iOS (not sure if it is Android/Windows?) -- which I believe includes Clojure docs.
I use Zeal, a linux clone of Dash, and it looks like there are some clojuredoc docsets! Great!
hi people, I'm using the library docjure
to read xlsx
files, but I have some inconsistencies when reading. Sometimes the map which were to get an string with "05/02/2019" reads it as "Fri Fev 05 00:00:00 BRT 2019" for example.
I would like to pass an expected datatype to the library parse each column with a predefined type, idk if this is possible actually, the docs in the library are not clear
I think xlsx data types are per-cell
so my guess would be that doesn't exist
unless docjure adds something over the top of that
I haven't used docjure but I've done a bunch of work against poi directly (the Java lib docjure uses) via Java interop
just depends what you want and need
I was expecting to use spec
to validate the data from the file, but I get a lot of false-positives and they are not consistent. For example (s/def ::field integer?) and I read a value as '2.0' one time and later '2'
I suspect that's more due to the xlsx file, which often has inconsistent per-cell data types and values
I use Zeal, a linux clone of Dash, and it looks like there are some clojuredoc docsets! Great!
that is, your data is actually messy; it's not the library's fault
in that case, sounds like your validation is working :)
yes, the data is in very bad state. I have a client that is sending me this through FTP and they create the xlsx via macros.. yea
I wanted to send back to them whatever they mess up really big. Like, date value inside a integer field
the real problem is that the same xlsx file does not show the same inconsistent cells to me.
every time I run the code, a different cell in this file might have a problem or not. But the file is the same
oh, well that's weird
I found this: https://github.com/ontodev/excel/blob/3faba013935baba1065b446c5a6a8d5683d9a5a8/src/ontodev/excel.clj#L21
Any suggestions on this error: java.lang.ClassCastException: class clojure.lang.AFunction$1 cannot be cast to class clojure.lang.Associative (clojure.lang.AFunction$1 and clojure.lang.Associative are in unnamed module of loader 'app'
? It points to the following line in my code: at ring_app.core$wrap_nocache$fn__13142.invoke(core.clj:12)
, which is:
(defn wrap-nocache [handler]
(fn [request]
(-> request
handler
(assoc-in [:headers "Pragma"] "no-cache")))) ;; line 12 in source
Trying to add Pragma: no-cache
to the headers of the response map the handler returns. So, response, would be the answer. Sorry about delayed response
Could someone clarify to me what these different packages do and how they interact with oneanother: figwheel-main, figwheel-sidecar and lein-figwheel?
Hi FiVo! As I understand it, figwheel-main is a standalone version of lein-figwheel. The latter originated as a leiningen plugin and was later rewritten to be used in other tooling
ok, so I am trying to move from lein-figwheel to figwheel-main with some luminus generated project, but end up on some page that tells me to run lein figwheel
. I tried to follow the instructions on https://figwheel.org/ for Leiningen but it doesn't work. I remove the lein-figwheel
plugin and added the figwheel-main
dependency.
@finn.volkel have you seen this? http://manuel-uberti.github.io/programming/2018/08/03/figwheel-main/
I'm new to clojure but not to lisps, so far I'm a big fan! Wondering what the state of development for android is at the moment. Are there good options? From what I've seen this is a tricky subject, and clojurescript + react I the way to go. It seems to me that there is a larger diversity of libraries in the JVM than through javascript. Are there good JVM based options?
Android has their own jvm-like thing, but I don't think clojure works well there because of startup time
@markgdawson I would look at cljs + react native
That's what I've heard. Shame, because the l libraries available on clojure "proper" seem (at a first glance) to be more extensive than the javascript alternatives for isoteric things. For example, I looked for a library to read emails over imap. Easy to find in clojure. Couldn't find anything in cljs.
Hello Guys, how to access system map of stuart components in REPL?
it's not required that it have any globally visible binding (and it's often recommended that in prod it doesn't) but you can easily give it a global binding via def during development
there's no default way to find it - you need to put it somewhere visible yourself
(there are examples in the readme)
OK @noisesmith I got it, Its just to learn how stay the map after start component.
the simple way to do it is with def
- this is what the readme shows https://github.com/stuartsierra/component#entry-points-for-development
(def system (example-system {:host "" :port 123}))
;;=> #'examples/system
(alter-var-root #'system component/start)
;; Starting database
;; Opening database connection
;; Starting scheduler
;; Starting ExampleComponent
;; execute-query
;;=> #examples.ExampleSystem{ ... }
(alter-var-root #'system component/stop)
;; Stopping ExampleComponent
;; Stopping scheduler
;; Stopping database
;; Closing database connection
;;=> #examples.ExampleSystem{ ... }
(quoted from that page)Great @noisesmith, helped me a lot! 😃, I 'm tried adapter in my code this form.
Not surpringly I guess, as this is complied to javascript, whilst clojure can leverage any JVM language.
I'm only using deps.edn with aliases for running my things in my projects, like an interactive nrepl instance, but I find myself always doing (use 'clojure.repl)
in my nrepl to be able to do things like (doc). Is there a better way? How does lein repl
automate that for example?
(apply require clojure.main/repl-requires)
gives you all the things clojure itself would put in your initial ns (clojure.repl, clojure.pprint, javadoc)also it's "future proof" as it gives you the right bindings for any future enhanced clojure
lein repl
relies on the "reply" lib to do ns initialization iirc, I wouldn't use lein's code as an example for elegant ways to do things generally - it's a big complex project with a lot of contributors that are relatively new to the project, its features work but it's not a tidy codebase
(eg. there's a lot of blatant copy/paste code)
Wow nice! So if I start nrepl with -e "(apply require clojure.main/repl-requires)"
it'll have all that?
nrepl itself should be giving all of that to you in your first ns - unless your first ns fails to load properly
but yes
oh - I see, you start nrepl programatically and it isn't neccessarily giving your user the same ns that was initial to the program itself
right, user
is the default if you don't make it start up with any other ns, and has all the things in repl-requires (clojure itself makes sure of this)
you can also tell nrepl to start with a different ns (and then you get that same initialization for free in that ns)
but that's fragile because if the code for that ns breaks you can have a broken repl sometimes
Yes makes sense. Don't know why it doesn't start with repl-requires loaded already then
@tedefump the tool you are using allows an init-ns
arg https://github.com/lambdaisland/nrepl#usage
it does - but only in the initial ns
not to every ns
Ok, thanks a lot @noisesmith I'll investigate all that
I think adding -i some.ns
for your ns to the command line does everything you want
your namespace
that's up to you - as I said clojure itself makes sure that user has clojure.repl etc.
maybe I don't understand your problem (or you changed your mind about how to fix it)
So I think something silently goes wrong because when starting in the user namespace, I need to manually use clojure.repl from the interactive repl session to be able to type (doc map) for example
that's weird - that could be a bug in that nrepl lib
so yeah, maybe you do want to add that apply require to your startup
@noisesmith it it is of any interest to you this is how I can reproduce it clj -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"}}}' -m nrepl.cmdline --interactive
confirmed
justin.smith@C02RW05WFVH6: /tmp/foo$ clj -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"}}}' -m nrepl.cmdline --interactive
nREPL server started on port 60807 on host localhost -
nREPL 0.6.0
Clojure 1.10.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_171-b11
Interrupt: Control+C
Exit: Control+D or (exit) or (quit)
(ins)user=> ('doc (ns-refers *ns*))
nil
(ins)user=> ('pprint (ns-refers *ns*))
nil
(ins)user=> (apply require clojure.main/repl-requires)
nil
(cmd)user=> ('doc (ns-refers *ns*))
#'clojure.repl/doc
(cmd)user=> ('pprint (ns-refers *ns*))
#'clojure.pprint/pprint
Oh you aren't using the lambdaisland lib, you are just using nrepl, ok
and this indeed seems to do the trick clj -Sdeps '{:deps {reply {:mvn/version "0.4.3"} nrepl {:mvn/version "0.6.0"}}}' -m reply.main
Would anyone be willing to work with me a little while until I get the gist of some things?
Hello Everyone!!
need help with running repl from emacs using cider ...when I use cider-jack-in i get an error ..but when i type the exact command on the command line..it works fine
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: Error building classpath. Don't know how to create ISeq from: clojure.lang.Symbol