This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-21
Channels
- # announcements (1)
- # babashka (39)
- # beginners (91)
- # cider (9)
- # clj-kondo (10)
- # cljsrn (1)
- # clojure (54)
- # clojure-europe (45)
- # clojure-italy (2)
- # clojure-nl (1)
- # clojure-spec (39)
- # clojure-uk (21)
- # clojurescript (7)
- # core-typed (1)
- # cursive (9)
- # data-science (1)
- # datomic (2)
- # docker (3)
- # emacs (11)
- # figwheel-main (11)
- # fulcro (19)
- # java (1)
- # juxt (1)
- # kaocha (68)
- # malli (7)
- # meander (5)
- # off-topic (76)
- # pedestal (1)
- # re-frame (6)
- # reveal (1)
- # rum (2)
- # shadow-cljs (48)
- # sql (6)
- # tools-deps (47)
- # vim (8)
- # xtdb (23)
I've been out of the loop re: Clojure for ~8 years. Is there a modern/up-to-date guide to Clojure tooling and ecosystem of libraries?
@jonathan594 Clojure CLI tools and deps.edn
: https://clojure.org/guides/deps_and_cli Clojure Spec: https://clojure.org/guides/spec
Probably the other "big" thing in those eight years is transducers: https://clojure.org/reference/transducers
I find myself writing some async code, where there gets to be quite a bit of heavily nested code, only to "un-indent" at the bottom to return the channel I've been working with. Is there a Clojure function/macro that would allow me to write something like:
(with-return out-chan
(heavily
(nested
(code
(that can
(go on and on
(and on
(but the top form still returns out-chan))))))
Threading macros, doto
, refactoring into smaller functions, creating higher abstractions - the choice depends on the actual code.
this doesn't appear to work
dali/dali {:git/url ""
:tag "manual-connector-anchors"
:sha "875f7b40b1f8df37ca6b6e51624b96fb8122abac"}
user=> (require '[ :as dio])
Execution error (FileNotFoundException) at user/eval2056 (REPL:1).
Could not locate dali/io__init.class, dali/io.clj or dali/io.cljc on classpath.
The tag and the sha do not seem to exist for that git repository. If you always wanr the current master state you can leave away the sha and the tag
ok. I'm trying to reference this branch manual-connector-anchors rather than master, tho I suppose I could make sure the main branch works first
I would believe you would need https://github.com/stathissideris/dali/tree/manual-connector-anchors.git as url then but im not sure if that works
user=> (require '[ :as dio])
Execution error (IllegalArgumentException) at dali.dom/eval196$loading (dom.clj:1).
Cannot open <nil> as a Reader.
@alpox @dominicm thx. I've fixed my problem. I'm submitting a PR so that it is fixed at source as well. New code here: https://github.com/stathissideris/dali/tree/manual-connector-anchors
is there a clojure library to provide simple text based interactions to the user such as:
Which database
[1] Localhost
[2] Remote
or type 'q' to cancel
this is probably overkill, but https://github.com/phronmophobic/terminal-todo-mvc uses membrane+https://github.com/mabe02/lanterna for building terminal UIs
thanks! But I was thinking more along the lines of having a function invoked from the REPL use (read-line) to prompt you about how to proceed, not building a full-fledged app
(defn menu [{:keys [prompt options]}]
(let [options (map (fn [o idx]
(if (string? o)
{:id (str (inc idx)) :text o}
o)) options (range))
valid-options (set (map :id options))]
(loop []
(when prompt
(println)
(println prompt)
(println))
(doseq [{:keys [id text]} options]
(println (str " [" id "]") text))
(println)
(println "or press <enter> to cancel")
(let [in (str/trim (read-line))]
(cond (= in "")
:cancelled
(not (valid-options in))
(do
(println (format "\n-- Invalid option '%s'!" in))
(recur))
:else
(first (filter #(= in (:id %)) options)))))))
but with some code to print the options nicely, persist if you select the wrong thing etc ☝️
usage: (menu {:prompt "Which database" :options ["Localhost" "Remote" {:id "o" :text "Other"}]})
looks great
thanks… do you think it might be worth releasing?
seems like a useful gist. not sure where you might be able to put it so others could find it when they are looking for it
I think the community can contribute examples to https://clojuredocs.org/clojure.core/read-line. it would make a really great example there
good point!
thanks
if you do find a good place for it. I would suggest adding (require [clojure.string :as str])
near the top
although, most people would probably be able to figure that out
I think you’re right, as a small lib it would be tricky to google for
yea, there would be some value in having a place to put snippets like yours. I saw this post on r/Clojure the other day, https://www.reddit.com/r/Clojure/comments/i6ak56/does_clojure_have_a_list_of_curated_example/
but you know… maybe it would be useful as a lib now that babashka is such a big hit
the other way people might stumble across it is searching
, https://grep.app/search?q=read-line&filter[lang][0]=Clojure
yea, seems useful
@U0CMVHBL2 I was thinking something along the lines clj-read-line-menu, boring, self-descriptive and searchable!
searchable is good 🙂