This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # adventofcode (18)
- # beginners (27)
- # boot (5)
- # cider (3)
- # cljs-dev (2)
- # cljsrn (1)
- # clojure (78)
- # clojure-austin (1)
- # clojure-brasil (2)
- # clojure-uk (1)
- # clojurescript (11)
- # css (1)
- # cursive (11)
- # data-science (6)
- # datascript (3)
- # datomic (3)
- # emacs (24)
- # graphql (1)
- # hoplon (2)
- # off-topic (1)
- # om (8)
- # onyx (1)
- # portkey (11)
- # re-frame (18)
- # ring (5)
- # ring-swagger (1)
- # shadow-cljs (1)
- # sql (5)
- # testing (1)
does anybody know resource/article/guide that can explain refactoring strategy in clojure (or LISP in general), I've been struggling on how to deal with impure functions, mostly because of their testability. I was hoping something like refactoring.guru, but at this point, I guess any simple article will do 😆
@hawari.rahman17 Can you be a bit more specific about what you're struggling with? Is this database code or something else?
Impure functions are not necessarily "bad" but they can always be refactored into a pure function that returns a data structure representing a delta on the environment and an impure function that accepts that data structure and performs the actual update. You still have the task of testing the update functions but that's a more focused task -- and then your pure functions can often be tested generatively.
hi @seancorfield, mostly it's when I'm dealing with database calls, I have a tasks that kinda looks like this:
(defn do-tasks [args] (do-some-validation args) (store args))
I think we already have this kind of conversation, haven't we? the solution that I came up with is to "inject" the
store function into
but now I'm saying that I need some kind of reference is because I sense that a lot of my code smells, not just necessarily because impure functions. I sort of need a pointer on what's next to learn for a clojure programmer, like learning design patterns next if you're already comfortable with OOP concept.
I think there are a couple of things you could try.
One would be something like Sean described above: have your
do-tasks fn return a data structure specifying the actions the impure fn is going to perform. This is very easy and nice in e.g. datomic, but can also apply to sql using e.g. honeysql or the like.
Another would be to define a protocol for your impure thing. For a database in particular, one is advised to not try to define a protocol for arbitrary database interactions, that’s just too complex and doesn’t buy you anything. Define a protocol for the things your caller needs and implement those. (I think one fairly quickly develops an aesthetic judgment on when the protocol is coherent or not, but you’ll make mistakes at first. No worries!) Then, pass an impl of the protocol into all the formerly impure fns.
Note these techniques aren’t exclusive, but can complement each other.
hi @U04V4HWQ4, thank you for the advice. I guess the thing that keeps me struggling even after months of experimenting with clojure is I tend to revisit the things that I've done in my previous languages: mocking, injecting dependency, and I always try to find the equivalent in clojure. that's why I'm kind of looking for something to refresh my understanding of clojure: why things the way it is, what to avoid and what to look for when building something.
Does anyone have experience working with quil? I'm hoping for some tips on workflows and dealing with errors in draw functions.
Hello, I am a beginner in the closure eco-system. I have some questions I would like to ask ..
1. are there some testing library which have the concept of 'compare to snapshots', similar to
2. Which libraries are commonly used for generating html? (I found https://github.com/weavejester/hiccup but I have no idea if it is a marginal one or not)
@vincent.cantin and hiccup doesn't look too marginal to me, judging from its github stars / watchers
I have a Clojure app that interacts with other commands through its stdin and stdout. I have been able to run an nrepl server from my app and interact with it from Cursive while it is running. It's fun! However, when I try to do the same from CIDER, it does not work. I am able to connect to my nrepl server with
cider-connect and am able to evaluate forms. However, it seems that CIDER captures stdout from my app and makes it go into my Emacs instead of where it is supposed to go (through the original stdout to another app that I am supposed to be interacting with).
I've found something vaguely relevant-looking at https://clojurians-log.clojureverse.org/cider/2017-08-18.html but it's not clear to me what I am supposed to do.
For those of you who are also interested in the answer to my question two and a half hours ago, I have a solution. Instead of using
:handler cider-nrepl-handler in my starting the nrepl server, I created a custom
my-cider-nrepl-handler, which is the same as
cider.nrepl/cider-nrepl-handler, except that it uses a custom version of the
cider-middleware vector which omits the
Having a hard time trying to get a free Datomic transactor running on Heroku: https://stackoverflow.com/questions/48035500/heroku-datomic-buildpack-throws-device-eth1-does-not-exist Asked in #datomic but quiet there.
i guess trying to figure out how to get your transactor.properties onto heroku is probably the place to start
are there any web development stacks that follow a similar philosophy as this? https://github.com/facebookincubator/create-react-app#philosophy
I'm having analysis paralysis at all the micro libraries available to set up a figwheel + react environment
Me too. I know that someone is working on it. For the time being I liked the tenzing templates