This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-29
Channels
- # announcements (10)
- # aws (4)
- # babashka (42)
- # beginners (208)
- # bristol-clojurians (2)
- # calva (13)
- # chlorine-clover (52)
- # cider (5)
- # clara (22)
- # clj-kondo (2)
- # clojars (14)
- # clojure (107)
- # clojure-europe (24)
- # clojure-nl (4)
- # clojure-uk (6)
- # clojurescript (3)
- # conjure (20)
- # cursive (23)
- # datascript (2)
- # datomic (15)
- # figwheel-main (3)
- # fulcro (23)
- # jobs (3)
- # kaocha (5)
- # keechma (3)
- # local-first-clojure (1)
- # malli (13)
- # off-topic (16)
- # planck (6)
- # re-frame (8)
- # reagent (3)
- # reitit (1)
- # releases (1)
- # remote-jobs (1)
- # rum (1)
- # sci (37)
- # shadow-cljs (16)
- # tools-deps (158)
- # vim (3)
- # xtdb (8)
can someone explain what's going on here?
(->> #(println (rand-int 10))
(repeatedly)
(take-while some?)
(take 3))
when evaluated this prints 1 number@ccann Because println
returns nil
so the take-while
stops immediately -- after printing the first number.
Hey, everyone. How do you check for precondition assertion error messages in tests? Here is minimal example, which fails:
(defn foo
[xs]
{:pre [(seq xs)
(every? pos-int? xs)]}
xs)
(deftest foo-test
(is (thrown-with-msg?
AssertionError
#"Assert failed: (every? pos-int? xs)"
(foo [1 2 nil])))
(is (thrown-with-msg?
AssertionError
#"Assert failed: (seq xs)"
(foo nil))))
Can't figure out what regexp to use:
Expected: (thrown-with-msg? AssertionError #"Assert failed: (every? pos-int? xs)" (foo [1 2 nil]))
Actual: java.lang.AssertionError: Assert failed: (every? pos-int? xs) activator.domain.equipment_test$foo.invokeStatic (equipment_test.clj:87) activator.domain.equipment_test$foo.invoke (equipment_test.clj:87) activator.domain.equipment_test$fn__13934$fn__13935.invoke (equipment_test.clj:97) activator.domain.equipment_test$fn__13934.invokeStatic (equipment_test.clj:94) activator.domain.equipment_test/fn (equipment_test.clj:93)
It's a regexp, you have to escape all your parens and question marks, like this: #"Assert failed: \(every\? pos-int\? xs\)"
i kinda hoped assert errors would have exception info to analyze with ex-data but sadly that's not the case...
wanted to point you to my convenient lib for testing ex-infos but alas (still the plug https://github.com/valerauko/harinezumi)
i kinda hoped assert errors would have exception info to analyze with ex-data but sadly that's not the case...
What is the state of Clojure on Android? I need to quickly implement an app that is UI-light but data-heavy, using external Java SDKs as well, on an Android device (it's an RFID scanner, running Nougat). Is using Clojure an option, or will it take me too long to figure things out? Searching the web shows answers from several years back, so I thought I'd ask here.
there is no active Clojure support on Android
I think the best option is probably things like React Native on ClojureScript
(or whatever the hotness is in that area, not really something I follow)
Ok, in that case it probably won't help me much, because I need to use the vendor-provided Java libraries. Writing the thing in Java will be faster.
Syntax error compiling at (REPL:0:0). Unable to resolve symbol: LOL in this context user=>
how can i make cider load and switch to a certain namespace on startup? i'm using deps and .dir-locals.el cider does not respect the main-opts that are declared in the alias
cider needs its own main opts to start up nrepl and ensure the middleware is hooked up
I've thrown everything in it just to see if it works:
{
:main-opts ["-m" "mycotensor.no-object.system"
["-e" "(load \"mycotensor.no-object.system\")"]
]
;; :jvm-opts ^:replace ["--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED"]
:repl-options {
:init-ns "mycotensor.no-object.system"}
:nrepl {:extra-deps {nrepl {:mvn/version "RELEASE"}}
;; :main-opts ["-m" "nrepl.cmdline"]
:main-opts ["-m" "mycotensor.no-object.system"]
:init-ns 'mycotensor.no-object.system
}
:repl-options {:init-ns 'mycotensor.no-object.system}
}
this is my .dir-locals.el :
((nil .
((cider-clojure-cli-global-options . "-A:my-alias")
(cider-repl-display-help-banner . nil))))
(Although with the new runtime basis / alias data stuff that @alexmiller dropped, CIDER could leverage. https://insideclojure.org/2020/07/28/clj-exec/ )
although the cider-clojure-cli-global-options
can be used now to accomplish that. as well as jacking-in with a prefix argument and directly editing the startup command
i think you would need to use the new stuff that @ghadi is talking about. i haven't read on it but just seen the excited chatter in #tools-deps . But you can do more stuff at startup now. So whatever command it looks like with clj
should work if you edit that startup command. and once you are happy with it you can throw it into your dir locals (cider-clojure-cli-global-options "-A:my-alias -X whatever-the-new-stuff-is")
I'm trying to play with the new clj exec stuff that @alexmiller talks about here: https://insideclojure.org/2020/07/28/clj-exec/, and I keep getting a NPE when I try to use -X:foo. I ran the linux-install-1.10.1.600.sh script, but earmuffs clojure-version shows :qualifier nil. I'm trying to figure out if I've got a dumb mistake, or if there's actually an issue. Any suggestions?
Heh. I was doing something stupid. new machine, and autosave wasn't on in my editor.
that could probably be cleaner
a ticket or a place to file a ticket?
in general, best to add a question to https://ask.clojure.org if you have suggestions
there is no ticket, but it would go in TDEPS
I'm just going to fix it right now, so need to file one
not a direct answer, but you might be interested in https://clojure.org/guides/dev_startup_time
the two most common issues are a) a def that takes a long time to create a resource (often something with side effects) or b) you're just simply loading a lot of code. the link really is directed at the latter problem
if you can affect the code at the beginning of startup, using the :verbose
flag in the initial :require
is sometimes insightful (or use the jvm's switch to print classloading)
@souenzzo, also check out http://clojure-goes-fast.com/blog/clojures-slow-start/
yep, another good tool
It's a huge project, there is ~3 pain points that I think that is problematic But I want some tools to be able to say "this will improve A, that will improve B"
@dominicm also wrote a tool recently to measure the time of loading per namespace, but I forgot the name
Lol @borkdude, you wrote a tool but forgot it's name!? I thought you wrote the tool but forgot the name.
@kenny that one. I was searching his github account, but could not find it there. that explains it.
Are there common organizational pattern(s) for where to put test specific resources? For example, you’re making a web router. You want to be sure it’s returning the correct files (stylesheets, html, xml et al). So, we add some dummy files to our project to verify they are retrieved.
I surveyed a few clojure code bases and noticed patterns like
• top level dev-resources
• nested test specific resources test/app_name/resources/*
or test/app_name/test_resources
It’s not a huge deal, but i’m curious if there are any thoughts on this
I tend to just put them in the test
tree at the appropriate relative location so they automatically become accessible as resources when test
is on your classpath.
To me, dev-resources
sounds like stuff you'd need for dev in general, not just specific to running tests.
@vlaaad Not quite sure what you mean... Any Clojure process anywhere can start a Socket REPL and you can connect to it via telnet from anywhere network-accessible...?
Ah, you want a Socket client ?
remote like remote-prepl, but repl, *in*
/`*out*` bound like io-prepl, but remote and repl
I would think it was easier just to work with io-prepl
as a client and then present a prompt and implement out/error display as you want?
Otherwise, you have parse/handle the regular REPL output (the namespace prompt etc).
found tubular, by the way, seems like what I want: https://github.com/mfikes/tubular
I've done a few client/servers for clojure repls where the transport is some something a little more involved than sockets, the server launches a clojure.main/repl with *in*
and *out*
bound in such a way that the data is passed over the transport
the client then just pipes the data in and out of *in*
and *out*
in a local repl connecting it to the server
half that tubular project is just a vendoring of some other code that needlessly wraps the java socket api
hello everyone, I need some general advice on dealing with html manipulation with clojure I need to load a html file from disk, add some nodes there (like divs with certain data), then serve this file what I have in mind is: • transform html into hiccup • insert the data somehow • convert it back to html Im not too sure on how to insert data inside hiccup, and maybe there is a better approach than hiccup?