This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (4)
- # beginners (82)
- # boot (1)
- # calva (26)
- # cider (13)
- # clj-kondo (41)
- # cljs-dev (25)
- # cljsrn (7)
- # clojure (82)
- # clojure-berlin (1)
- # clojure-brasil (1)
- # clojure-dev (13)
- # clojure-europe (11)
- # clojure-italy (27)
- # clojure-nl (8)
- # clojure-russia (6)
- # clojure-spec (32)
- # clojure-uk (15)
- # clojurescript (61)
- # core-async (1)
- # cursive (9)
- # data-science (1)
- # datomic (18)
- # duct (1)
- # emacs (2)
- # events (7)
- # fulcro (13)
- # graalvm (5)
- # immutant (1)
- # jobs-discuss (63)
- # leiningen (3)
- # off-topic (48)
- # om (3)
- # pathom (13)
- # planck (20)
- # prelude (3)
- # re-frame (55)
- # reagent (13)
- # reitit (5)
- # rewrite-clj (12)
- # shadow-cljs (67)
- # spacemacs (14)
- # sql (5)
- # tools-deps (4)
- # vim (23)
- # yada (2)
i want to define a function that given an argument, it returns true when as long as one of the four functions f1-f4 returns true?
You might want to check
every-pred for inspiration (if you're only interested in the answer, check
Yup, hard to find out about what you don't know yet. This is a very useful resource (given 4 fn-like args, what could I use to get another function back?): https://re-find.it/?args=fn%3F%20fn%3F%20fn%3F%20fn%3F&ret=fn%3F&more=true)
it's very terse, to the point of not making sense but it takes a series of functions, and returns a function, that when applied to an argument(s) returns a vector of the results of those functions applied to the arg
The Clojure cheatsheet does not include all Clojure functions, but definitely all of the most commonly used ones, and some of the not-so-commonly used ones. They have been separated into categories based upon their use and capabilities. https://clojure.org/api/cheatsheet If you click on the "Source repo" link near the top you can find other variants of the cheatsheet, e.g. some of them have what I consider nicer-looking tooltips when you hover the cursor over a function name, showing the doc string for the function. Also a name search box near the top.
Coming from Haskell world, I often surprised, why there are so many unnecessary functions in core - i.e.
remove as duplicate of
filter (not), or
keep, or above example
((juxt nil? empty?) '()) as duplicate of
(mapv #(% '()) [nil? empty?])
Out of curiosity, have you found no unnecessary functions in Haskell, or simply fewer than in Clojure?
Looks like, but imho there should be a balance between convenience of use and hardness to remember many functions
((juxt nil? empty?) '()) can be considered as a duplicate of
(mapv #(% '()) [nil? empty?]), note that
(juxt nil? empty?) is a function in its own right that can be passed to other functions, returned from a function as a value, etc., where your second expression doesn't make such a function easily separable in that way.
No problem, if you work only with one blab, you can remember all its personal functions. But I think more uniq things - more comlexity. And there is not a big problem to wrote
(fn [x] (mapv #(% x) [nil? empty?]))
@ivana remember that clojure is not curried like haskell, so the existence of remove/juxt is also convinient for higher order use
A library should do one thing well ex. routing, ui or state A framework will have a bunch of batteries, usually routing, ui and state
other way to think about it: framework will impose certain kind of structure in your application, library will not (usually)
I’m trying to disable assertions checks(pre/post hooks) for production code, but could not figure out a way to do so. It seems to be a setting for the Clojure compiler, not having effect in runtime. Wondering what is the proper way to set
*assert* to false before code is compiled. Tried many things and nothing seems to be working. We’ll bundle the code as an uberjar.
if it's ordinary clojure code, you can
(set! *assert* false) before calling
compile, if it's leiningen: https://github.com/technomancy/leiningen/blob/87a6af9a12d5c479bfbb51f50b85c3fa4c2650a0/sample.project.clj#L286
We are packing using:
clojure -A:pack mach.pack.alpha.capsule ./target/my-app-api.jar -e build-dir --application-id my-app-api --application-version "$(git describe --tags)" -m my-app.main
(Possibly better behavior is clojure to initialize
*assert* to the JVM assertion status)
We are not loading
user.clj in prod code. We tried (set! assert false) as the first line of the main file. Apparently, the require will load and compile before
*assert* could be se to
Whats the current state of the art in terms of Repl driven development? For example, last i checked, it was easier to just restart your repl when you added a new dep. Is that still the case?
i see conflicting goals between "state of the art" and "easier". I always just restart my repl as I don't often add new things and its easiest for me to know i'm back in a clean state. I think deps.edn has a branch with this feature and nrepl has teased that its coming? possibly already landed. nrepl-refactor has had this for a while and I believe it is working with the current CIDER
I suppose don't see this as conflicting with anything. I just want to add some functions to my system. Reloading everything up to that point should ideally result in the same state. I suppose it because i'm not relying on any outside state. I'll take a look at nrepl-refactor 🙂
probably hasnt landed yet but theres this http://insideclojure.org/2018/05/04/add-lib/
I more meant how to divide the logic within an application into namespaces. How are people architecting solutions?
Some people like a fairly flat structure, with broad namespaces, some prefer a more deeply nested structure with more focused, shorter namespaces.
I think probably the only common thread is to separate different concerns, e.g., persistence from business logic, and to try to organize via "domain" concepts where possible.
Having recently bounced through Redux and Elm I was wondering if there were any architectural ideologues floating around.
So we have over 85k lines of Clojure with close to 300 source namespaces (and just over 300 test namespaces) and our source code averages about 200 lines per ns with our longest one being 2,000 lines (and only a handful are 1,000+).
Clojure source 279 files 67068 total loc, 3118 fns, 641 of which are private, 423 vars, 29 macros, 60 atoms, 580 specs, 21 function specs. Clojure tests 308 files 19301 total loc, 4 specs, 1 function specs.
No, Clojure is not very prescriptive about architecture, beyond trying to keep side-effects at the edges.
We've been developing this since 2011 and it powers the back end of all our dating sites (about 40 or so of them), as well as a few dedicated Clojure web apps.
Our approach to namespace organization has evolved over that time too, both in naming and actual organization.
We started broad and flat and we've gradually moved into narrower, more focused namespaces as we've refactored old code and added new code.
@drewverlee FWIW, I just restart my REBL/Socket REPL combo if I change/add new dependencies. That said, I don't do that very often so my REBL instance tends to stay up and running for days, sometimes even weeks!
(last time I restarted my REBL instance was 10:18 am June 13th, when we made a pass over our dependencies to update a bunch of them -- so "only" four days so far)
I think for most projects it tends to be the case that you dont add new deps very often. I was trying to use clojure in a more datascience type setting where i find that I want to try new libs relatively often (every 20 minutes or so). In order to find the one that fits my needs. Having to restart my repl 3 or 4 times in this setting becomes something of a creative drag.
with Cider I used to use
cljr-add-project-dependency which worked great but broke at some point. I don't know if it's working in the latest version but I still miss it every now and then.
@drewverlee Agreed, and that's why I have an alias in my
.clojure/deps.edn file that brings in the
add-lib branch of
tools.deps so I can start a REPL dedicated to exploration when I need to, and use
add-lib to try out various things.
@U04V70XH6 i'm trying to use the setup you describe in the helpful youtube video you made about 2 months back. Everything is working except when i eval forms in atom via chlorine there not sent to REBL. forms evaled directly through the repl in started via the clj tool are though. Any ideas why this might be.
@drewverlee Sounds like you're using the eval block commands instead of the inspect block commands
If you look in my keymap https://github.com/seancorfield/atom-chlorine-setup/blob/master/keymap.cson#L37 I only bind to the inspect commands -- because I'm always running REBL (and Clojure 1.10.1).
If you want to use Chlorine without REBL or on 1.9, you have to use the eval block commands (not the inspect block commands), so it sort of depends where you are.
I used to have the inspect variants bound to
ctl-, i and
ctl-, I but once I got into the habit of always using REBL, it was easier to just bind
ctl-, b and
ctl-, B since those were easier to remember (and I'd been using them for months, before I introduced REBL).
that wrapper is very thin, a good place to start would be to attempt the auth / connection code in with-connection manually and see what might be failing