This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-10
Channels
- # adventofcode (3)
- # aws (2)
- # beginners (85)
- # boot (8)
- # boot-dev (4)
- # cider (36)
- # clara (3)
- # cljs-dev (87)
- # cljsrn (3)
- # clojure (87)
- # clojure-austin (12)
- # clojure-brasil (1)
- # clojure-dev (8)
- # clojure-dusseldorf (5)
- # clojure-estonia (5)
- # clojure-greece (4)
- # clojure-italy (3)
- # clojure-spec (17)
- # clojure-uk (55)
- # clojurescript (70)
- # core-logic (2)
- # cursive (6)
- # data-science (18)
- # datomic (13)
- # emacs (34)
- # fulcro (347)
- # graphql (12)
- # hoplon (6)
- # jobs (3)
- # jobs-discuss (43)
- # juxt (2)
- # keechma (31)
- # leiningen (29)
- # lumo (2)
- # midje (2)
- # off-topic (118)
- # om-next (4)
- # onyx (39)
- # pedestal (6)
- # re-frame (85)
- # reagent (21)
- # remote-jobs (3)
- # ring (5)
- # rum (2)
- # shadow-cljs (126)
- # spacemacs (1)
- # sql (6)
So ^:const
is sort of "direct linking" for Var values š
The kind of thing thatās real easy to miss when youāre ājust optimizingā things.
aot (a feature people don't understand and don't think through the implications of) combined with const (a feature people don't understand and don't think through the implications of)
Hello all, I've read about Jlink in Java 9 and I see a big advance about memory and performance running embedded java services. Do you think it can be used with Clojure?
I've modified clojure to use modules (java.base + jdk.unsupported) and jlink'ed it into a 45MB docker image
Can anyone recommend a tutorial on learning a workflow with mount and tools.namespace? Iām trying to do something stupidly simple (open a db connection, run a count query, close the connection), but something (?) isnāt working and Iām lost as to how to debug the problem
Using Cursive, attempting to follow this: http://grishaev.me/en/clj-sqlite except with mount-lite
Part of the struggle is Cursive/REPL; even if I load a file into REPL I have to manually re-require libraries to test sub parts of the file etc - Iām 100% sure itās possible to get more value out of REPL but I need a howto. In general itās an immensely frustrating experience - every documentation or tutorial shows a piece of the puzzle, and I need to find a sustainable way to debug the project in a situation when Iāve put the pieces together in the wrong way.
have you seen the mount test app? should be able to get some inspiration there: https://github.com/tolitius/mount/tree/master/dev/clj
Iāve seen this thread https://clojureverse.org/t/share-the-nitty-gritty-details-of-your-clojure-workflow/1208/23 but with my current state of knowledge itās too much disparate input ĀÆ\(ć)/ĀÆ
My basic strategy is: 1. write short functions 2. write unit tests (clojure.test/is ...) right under the functions 3. eval them in the repl
Iām not currently using namespace; I know itās meant to resolve these kinds of problems, thatās why I asked. Iām a beginner with Clojure - old hand otherwise, but finding it really hard to start with Clojure workflow, as I donāt have anyone to show me their workflow in person. I understand all people have personal habits and nobody wants to tell you The Right Way, but I have to start from something.
@lady3janepl here is my workflow: I have this fn in my dev/user.clj
(ns user
(:require [clojure.tools.namespace.repl :as tn]
[io.aviso.exception :as e]))
(defn refresh []
(let [e (tn/refresh)]
(set! *warn-on-reflection* true)
(if (instance? Throwable e)
(e/write-exception e)
e)))
everytime Iāve made a change I want to test, I run (user/refresh)
in my REPL and all my code is reloaded
I'm being a bit daft with syntax.. I have have a function that returns a vector (it maps over items and transform them a bit). Now in the end, I want [:g [item1] [item2]]
. Obviously [:g [[item1] [item2]]]
is easy to get but how do I "spread" the list to the vector starting with :g
? I think I need apply
..
you know, I'm actually using into []
elsewhere and the thought of trying it did cross my mind.. dunno why I didn't.
it actually works beautifully here because I can just (->> (fetch-orig-array) (map my-transform) (into [:g]))
this also works
user=> `[:g ~@[[:item1] [:item2]]]
[:g [:item1] [:item2]]
but donāt do that šI have a map with a stateful resource in it (a process actually) and would like to use that via with-open
. What is the best way to do that? The map so far of course does not have a .close
method to be called by with-open
.
@nblumoe not possible AFAIK due to https://dev.clojure.org/jira/browse/CLJ-308
I think your best bet is to look at the source for with-open
and implement something similar: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L3797-L3816
you can make a Closeable
protocol and make your map a record that implements said protocol + combine it with a modified with-open
macro
Hello everyone
I'm new to the clojureu community
Does anyone have experience using swagger in clojure apis?
I have a little, using: https://github.com/metosin/compojure-api
Thanks @schmee. I am quite surprised. But yeah, I will go with my own try/finally block then. Was already starting off with then but then realised there are more resources which could be handled by with-open
and thus wanted to try that. Oh well, back to start then. š
Nice, @manuel I've been following that link but still a little bit confused with my error messages š I'm a JS developer and used swagger quite a lot, usualy ina yaml file; the structure in clojure projects is still new to me š
ok, sorry, I have no experience with yaml files for Swagger. Only used Swagger with compojure-api to be honest š
I see. Is there any particular way to build thte structure? I realized it was written in the handler.clj file usually
this is how I did it in one of my projects: https://github.com/manuel-uberti/boodle/blob/master/src/clj/boodle/api/handlers.clj#L15 Pretty much followed compojure-api docs though
There is a also nice full demo app at https://github.com/yogthos/memory-hole
i'd like to count the number of times a given dependency is used in a project. i.e.
{:org.clojure/java.jdbc 75, :korma 10, ā¦}
anything exist that would help me do that?tools.namespace
and tools.deps.alpha
both seem potentially relevant but without batteries.
Hi, Iāve create a simple two utils for Clojure CLI. They allow you to run nrepl server and run tests. https://github.com/mrroman/devtools/
vec forces lazy sequences
~you canāt wrap something that produces a vector and make the thing inside the vector lazy`
oh - I misunderstood, neverm ind
what about (take 1 (repeatedly next-page))
?
each next-page call is ten items though, so you need to lazily consume the contents of each call
Ah right, missed that start takes an arg
@tdavis (apply concat (map (comp next-page #(* 10 %)) (range))
- will consume 1 result at a time, but only realize 10 at a time
(take 2 (map vec (partition 10 (range))))
=> ([0 1 2 3 4 5 6 7 8 9] [10 11 12 13 14 15 16 17 18 19])
or actually (mapcat (comp next-page #(* 10 %)) (range))
but, using laziness to control side effects is always a bit weird and tricky - it can improve things if you produce the input lazily, and do side effects eagerly, then piping into your data oriented code with an explicit boundary
(eg. delivering onto a queue and blocking until previous results are consumed)
i'm not trying to control side-effects, it's just db paging. i can't read a million rows at once so i wanna read 100 at a time, but scrolling through results requires knowing some column value for the last result in the previous iteration. and that lazy million-row query is mapped over.
i always find it trivial to express in java or python or anything with stateful iterators or generator-type functions, but really trips me up in clojure for some reason
Reading from a db is a side-effect
I typically cheat on things like DB paging and just hold on to the current page number in an atom or similar
makes it easier to do things like jump-to-first, jump-to-last, jump-to-page-n
Since db paging is inherently a stateful side-effecting operation, itās not un-Clojure-y to bring in the state management functions of Clojure.
hm, if I need to iterate a list (vector) and each item needs to know a value from last item (specifically, distances. Each item needs to know previous one's x coordinate so it can do previous x + its distance), is there a "common" clojure pattern for this?
(map f (partition 2 1 coll))
f will get a collection of two items, x and next-x
well - kind of - something like (map f (partition 2 1 (cons ::first coll)))
is sometimes more useful, just make sure f does the right thing when it detects the āprevious itemā is the keyword ::first (or nil or any other placeholder, depends on your algorithm surely)