This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-26
Channels
- # arachne (80)
- # beginners (76)
- # boot (16)
- # cider (66)
- # cljs-dev (62)
- # cljsjs (1)
- # clojure (106)
- # clojure-dev (5)
- # clojure-greece (2)
- # clojure-italy (9)
- # clojure-russia (1)
- # clojure-spec (61)
- # clojure-uk (130)
- # clojurescript (21)
- # core-async (9)
- # cursive (3)
- # datomic (37)
- # events (41)
- # figwheel (31)
- # fulcro (27)
- # hoplon (1)
- # jobs (2)
- # lumo (11)
- # off-topic (155)
- # re-frame (71)
- # reagent (27)
- # ring-swagger (3)
- # shadow-cljs (132)
- # spacemacs (5)
- # specter (1)
- # sql (37)
- # test-check (10)
- # uncomplicate (5)
- # unrepl (2)
- # yada (3)
for example, having a rule of thumb for a team that namespaces should only “reach down”, e.g. project.feature
should only import things from
or external libs
yes, that’s reasonable
obviously this breaks down when you want to extract common functionality of features into a ns
there’s also this if you haven’t seen it https://github.com/clojuredocs/guides/blob/master/articles/language/namespaces.md
@lilactown common functionality can be done that way, in particular by having a protocol at a higher level, and then implementations at a level below (or multimethods, similar concept) and it’s brought together at the top level by pulling in both the abstraction and a specific implementation
@lilactown this one is probably closer to what you wanted - an opinionated style guide for using namespaces https://stuartsierra.com/2016/clojure-how-to-ns.html
oh, wait - that’s more about the semantics of the ns block itself, not the relationships between namespaces
interesting, not sure I completely understand how the protocol/multimethod provides the same code reuse as extracting the defn into a common namespace
@lilactown the mechanics are that the protocol or multimethod is at the highest level, all the other code deeper down can refer to it
then, no matter where the concrete implementation comes from in the tree of namespaces, it will work
since nobody is reaching up or across (apart from protocol / multimethod - you do need to special case that one ns)
anyone familiar with the little schemer? i'm reading the section where they express length
without define
, just a bunch of inscrutably nested functions that are applied to themselves
i'd like to understand it more. can anyone provide some context for this exercise or point me towards another discussion of it?
((lambda (mk-length)
(mk-length mk-length))
(lambda (mk-length)
(lambda (f)
(cond
((null? l) 0)
(else (add1 ((mk-length mk-length) (cdr l))))))))
"applicative-order Y combinator"
I haven't read the Little Schemer any time recently, but if that book's authors didn't find a clear way to present it, I don't know who could.
Not sure if the answers here are anything like what you may be looking for, but maybe: https://stackoverflow.com/questions/93526/what-is-a-y-combinator
I never studied lambda calculus, but this answer on that page is likely part of the reason why people who study the theory of computation might be interested in the Y combinator: "Fixed point combinators are used to show that lambda calculus is turing complete. This is a very important result in the theory of computation and provides a theoretical foundation for functional programming. Studying fixed point combinators has also helped me really understand functional programming. I have never found any use for them in actual programming though."
In languages like Clojure, Scheme, etc., they provide straightforward ways to write recursive functions, so little need (that I am aware of) to write code like this in practice.
Hi all, I want to disable clojure's assertions when building the production uberjar of my app, is there a recommended way of doing this?
For leiningen you can modify :global-vars for production profile - https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L285
thanks @delaguardo that will do 🙂
I'm planning to use Compojure for a simple web server for managing certain processing X (a Clojure function, let's say e.g. that X continuously generates events and sends them somewhere as long as it is not told to stop processing). The Compojure web server has three commands: - start: Start X and keep it going until given command stop. - stop: Stop X. - status: Give status of X (whether running/stopped). I already wrote the Compojure skeleton for this, no problem with that. Here is my question: What would be idiomatic clojurian way in the Compojure application to start processing X (with start command) so that the web server itself does not block while X is running (in background).
I don't need any fancy processing framework or anything like that. Just some idiomatic clojurian way to do this. Any suggestions are wellcome! I guess this is a good chance to learn some concurrent programming in Clojure.
I think I got it: (async/go (while (= @server-state :running) (log/trace " INSIDE GO ")))
Seems to be working, I can give stop command which sets atom server-state to :stopped ....
Hey guys how can I use atom as seq?
Like this
(def k (atom [1 2 3]))
(seq k)
output -> [1 2 3]
when I do it return me one erro like this Don't know how to create ISeq from: clojure.lang.Atom
what is this operator @?
user=> (def a (atom 1))
#'user/a
user=> a
#object[clojure.lang.Atom 0x2e1ef60 {:status :ready, :val 1}]
user=> @a
1
user=> (deref a)
1
@victtorferreiralima check out https://clojure.org/guides/weird_characters
aaaah ok
Hi, does anybody use Docker to seal up their Clojure apps? i am interested in cross-platform distribution and it would make life very easy to have some sort of "make-a-me-a-binary-please-a" command.
depending on how it’s meant to be run an uberjar can get close to that - (each OS should know what to do with it if java is installed)
but I guess docker is useful if you don’t want to depend on java, or need to daemonize, or need outside-jvm things as well
@sova there is leiningen plugin for that - lein-bin.
fun fact - on a properly configured linux system, it suffices to set the executable bit on an uberjar
(binfmt-misc is the debian package that does this - might have other names in other distros)
Hello good people 🎉
complete to clojure newbie here.
In your editor of choice is there a way to evaluate forms inside let
with the bindings declared before in let
, if that makes sense? If so is it something cleverly provided by your editor/plugin (I am using vim+fireplace, don't hate ☮️ ❤️ :))
This is quite useful for learning--understanding what a more complicated function is doing by breaking it into pieces. So far I was just doing that "manually" taking out certain parts I wanted available in the ns and def
ining them
the idiom is - oops, misread(let [_ (some-side-effect) ...] ...)
I’m fond of this idiom: (def debug (atom []))
then inside the function (let [x (f y) _ (swap! debug conj {:y y :x x})] ...)
- that lets me run the function in normal usage and also play with the values it sees in a repl
and also it lets me catch values in the middle of the let block in case they get shadowed etc.
maybe example would be useful
(defsynth deci-wobble []
(let [temp-freq (/ 140 60 3)
tr (impulse temp-freq)
note (demand tr 0 (dseq [40 43 47 47 40 37 43 28] INF))])
...)
if I want to evaluate (demand ...
just to see what it returns 🙂 I can't do it cause it references tr
, a binding aboveyou can capture tr
oh wait - that’s defsynth, so all this is moot
defsynth is magic, the code inside is not real clojure, it’s a DSL that looks like clojure that is translated to UDP commands sent to a C++ process
right, nothing works like you expect in defsynth, period
@noisesmith your idiom looks promising need to play with that a bit to see if it's all I need 😉 thanks!
I’m sharing what I do, there’s editors that allow some instrumentation but it requires changing how clojure compiles things so it’s never seamless - I find the most beneficial thing to be writing code such that this sort of debugging doesn’t require stepping (there’s design benefits)
also I wrote a library for dumping data to disk (for unit tests or just debugging) - it eliminates soem of the gotchas that come up when naiively writing / reading edn https://github.com/noisesmith/poirot
if you wanted to go a step further and capture data from an arbitrary process even if you can’t be at the repl (or if you want the data to be reusable without recreating all the preconditions)
@prnc also, for real step debugging I have the impression that cursive is the editor / tool that gets closest to that experience for clojure
cool, cheers @noisesmith I will play with the debug
atom you suggested and see how far it can take me 🙂
Is there a good lib for testing my dom creation code from cljs? I was thinking something that could take html string and convert it into js objects to compare my code against? open to alternatives also
i'm looking to create a clojure(script) desktop app that's both osx and windows friendly and powered by re-frame / reagent. should i be exploring re-natal or cljs-electron?
@U0GC1C09L the same question here, but i'd like to target just linux. does anyone have suggestions on how to get started?
isn't re-natal for mobile?
i'm looking into descjop
Depending on the use case, a runnable jar might be an option, with something like quil for the interface?
wow... quil won't be providing components at all