This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-21
Channels
- # aleph (7)
- # beginners (79)
- # calva (1)
- # cider (5)
- # clj-kondo (12)
- # clojure (7)
- # clojure-austin (1)
- # clojure-brasil (2)
- # clojure-chicago (1)
- # clojure-europe (2)
- # clojure-seattle (4)
- # clojurescript (68)
- # data-science (1)
- # datavis (1)
- # figwheel-main (2)
- # hoplon (2)
- # juxt (1)
- # leiningen (3)
- # luminus (8)
- # off-topic (65)
- # onyx (1)
- # pathom (12)
- # reagent (6)
- # reitit (3)
- # shadow-cljs (7)
- # spacemacs (5)
I dont like deps edn - to me, other than NIH it seems to be unable to do anything lein cant already do
Also i am biased as my deps based inexperience caused me to be unable to have emacs cider jack in autoload my core.clj file in a deps project, but same using lein has no issues
@m131 As someone who used Leiningen for years at work, then Boot for years, and now CLI / deps.edn
for everything at work, I can tell you that it has plenty of pros.
Comparing it to Leiningen directly is a mistake and misses the point.
But, if you're only doing basic stuff in simple projects, there's really very little between the tools: they all start a REPL, they all run Clojure code. The differences become evident only when you need to customize how the tools behave in complex project environments.
has anyone setup CircleCI with Codecov? I don't understand the file
variable... where is CircleCI placing the test reports by default?
I am trying to iterate over elements stored in a javelin formula cell in hoplon using for-tpl
What I would THINK this would return based on my shaky understanding of hoplon for-tpl and javelin formula cells: each element in the collection created by ""(take count (iterate element (element))""
But what I actually get is this: ""[#object [javelin.core.Cell 0] #<HoplonElement: DIV>]"" (my element happens to be a vector of a javelin cell and a hoplon div). This looks to be the javelin formula cell, but I can't figure out how to access the data I want!
Fixed! Turns out the reason I couldn't use deref on the object was because everything needs to be nested under a div
In this case, the * functions are primitives understood by the compiler
I think you might have read let*
instead of list*
:) there's nothing special about list*
And sometimes that convention is used elsewhere - the * function is the āimplā version and then the unstarred version is the āpublicā version
Thatās not a universal convention though
thank you! I think the original example I encountered was of the "impl/public" variety š
Is there a good pattern for when you want to map over a collection, but in rare cases one input element should generate multiple output elements?
(I could do a mapcat, but having to return a single-element vector for majority of the elements seems like an overkill)
(very contrived example: (1, 2, 3) should generate (false, true, false) but (1, :twice, 3) should generate (false, nil, nil, false))
@lady3janepl Are you wanting to optimize this case for execution speed? Or code clarity?
expected input in the form of nested maps, expected output html, I'm attempting to write nicely composable functions š
ended up with a reduce-kv which for most keys does a (conj result (case k ...)) but for the special key, concatenates to result instead.
mapcat
seems like the most readily understandable construct, but I see what you mean... I guess in your case it is doing mostly a map
returning non-collections
(specifically, I'm generating <meta> tags for open graph data, where they have a convention that for an array of something, you should repeat the meta tag multiple times)
https://github.com/niallkennedy/open-graph-protocol-examples/blob/master/image-array.html#L12-L21 <- example
one simple way: (map #(str % " foo") ["a" "b" "c"])
=> (map #(str % " foo") ["a" "b" "c"])
("a foo" "b foo" "c foo")
#()
is a shorthand for (fn [] )
which doesn't require naming arguments, and only allows a single form in the body
Thanks @noisesmith !
Hello, IĀ“m Orlando from Nicaragua. Former COBOL, C, Visual Fox Pro, Oracle, C#.Net developer, now manager, whoĀ“s having fun again with Clojure
Hi! How can I start a repl with clj
and deps.edn in a particular namespace? If I start the repl then do (in-ns 'hello)
it doesnāt work (as if the namespace isnāt loaded). The only way I can get it to woork is by doing this:
user=> (require 'hello)
user=>(in-ns 'hello)
hello=>
@hmaurer You can give those forms on the command-line (so you could also provide them via :main-opts
in an alias
(! 686)-> clj -e "(require 'example.main)(in-ns 'example.main)" -r
#object[clojure.lang.Namespace 0x5ba88be8 "example.main"]
example.main=>
{:aliases
{:repl
{:main-opts ["-e" "(require,'example.main)(in-ns,'example.main)" "-r"]}}}
and then clj -A:repl
But I would ask why you care what ns the REPL starts in? I think it's better to stay in user
and require
things in via aliases as needed...
my favorite: (doto 'foo.bar (require :reload) in-ns)
that way I can run it again when my code runs, and it leaves me in a decent state if anything goes wrong
(I think I learned this trick by watching over @technomancy's shoulder, but not certain)
@noisesmith ah nice, ty!
often while developing I will repeatedly run (doto 'foo.bar-test (require 'foo.bar :reload) in-ns (clojure.test/run-tests))
- a one liner that reloads my source and the tests, then runs all the tests
(I find it useful to be in the test ns while developing often - weak tdd)
and even if I reboot my box, or just have to restart a repl, the command line history has a standalone in it that I can find easily with control-r, that loads everything I was most recently developing and runs the tests
I combine this with a script that finds all files that are different between my branch and origin/master into a new instance of my editor, and voila - probably the simplest possible version of project history and reload
#!/bin/sh
git fetch
nvim $(git diff --name-only origin/master)
follow-up question: when I call (>!! some-chan some-vlaue)
in the repl, it blocks until the value is picked up from the channel (with core.async). I would like to interrupt this, but Ctrl-C exits the repl completely (on os x). any idea?
that's inherent with the clj repl as is, there's probably some trick with signal handlers but nrepl / repl-y already has this set up
also you can just use put!
instead of >!!
- optionally with a callback that logs / prints
@hmaurer probably the lowest effort would be using nrepl in clj - there's alreayd projects that make this simple
yeah Iāve used nrepl before; I just wanted to get it to work with clj since itās dead simple for some things
this makes me realize I want to find out how the repl-y client signal handler interrupts the last input without shutting down the client or vm...
@noisesmith please let me know if you do š
found this: https://clojureverse.org/t/interrupt-clj-evaluation-without-exiting-repl/4046/9
I was about to link this https://github.com/trptcolin/reply/blob/908fafbc4b2c5a3888397e8f6718410248918b1f/src/clj/reply/eval_modes/nrepl.clj#L35
so nrepl has a built in :interrupt-id tag that you can pass the id of a pending input
next step would be to see how nrepl handles :interrupt-id and cancels that operation
I don't see the full picture, but this is certainly a key part https://github.com/nrepl/nrepl/blob/2b432c859c5a98b6e8c97338315bfaab2961641b/src/clojure/nrepl/middleware/interruptible_eval.clj#L55
tl;dr looks like "replace eval with something that sets things up to be registered and interruptable"
(for the repl itself at least)
so back to my first reply - the easy way is to use nrepl via clj (there's a few setups for doing this, I'm not certain which one is the best pick)
https://github.com/clojure/tools.deps.alpha/wiki/Tools doesn't link to any of them
If there is something to add here - please do. It's a wiki.
it's a legitimate question for me - I have seen nrepl setups for clj, but haven't used any of them in anger
I will add one if I know it works well
(you could start two clj processes, one which starts an nrepl server (that's a one liner) and another that starts a REPL-y client (likely another one liner)
that's what lein is doing under the hood, starting two jvms
in fact instead of using Control-C you can just connect another repl to the same vm, and leave the other one running