This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-12
Channels
- # announcements (65)
- # aws (1)
- # babashka (12)
- # beginners (111)
- # bristol-clojurians (1)
- # cider (32)
- # clj-kondo (55)
- # clojars (3)
- # clojure (71)
- # clojure-europe (17)
- # clojure-france (4)
- # clojure-italy (36)
- # clojure-losangeles (8)
- # clojure-nl (6)
- # clojure-uk (115)
- # clojurescript (2)
- # datomic (99)
- # fulcro (32)
- # graalvm (12)
- # graphql (20)
- # hoplon (203)
- # meander (56)
- # mount (3)
- # off-topic (17)
- # pathom (17)
- # reitit (22)
- # shadow-cljs (32)
- # spacemacs (9)
- # tools-deps (19)
- # vim (25)
- # vscode (3)
@joshkh I have a Hakyll system I set up a while back that uses Markdown. Then I put it in an S3 bucket as static hosting.
@joshkh if you want a static site generator that is not supported by github pages, you can give gitlab pages a try. Just push the source (markdown?) and have it built and served automatically. I have a gitbook powered site that way https://walkable.gitlab.io
I've definitely thought about using Enlive to transform HTML->HTML and let me write raw HTML but define tags to be transformed like <toc> or similar
@U0LE4C7CK switch to your cljs REPL in cider, and try cider-connect-sibling-clj
I use this exact workflow with shadow all the time. Fire up shadow with cider-Jack-in-cljs
and then cider-connect-sibling
to get one of each REPL going.
Thanks! I got it working with an cider-jack-in-cljs
with shadow, and then cider-connect-clj
to an external lein repl
, but this sounds better
and the opposite is true - if I cider-jack-in-clj I can't navigate through my cljs files
I've also tried jacking in with a lein repl, then starting a shadow-cljs server in a terminal and then using cider-connect-cljs, but the connect never finishes connecting
so I'm curious if anybody does have a workflow to manage this. Right now I'm just trying to work on either frontend stuff or backend stuff and kill the repl when I switch
Did you give cider-connect-cljs the port that shadow cljs printed out?
I got a project with similar set up, what I did was to jack in clj and connect cljs
With shadow running in a terminal
Sorry Im not using a computer, cant be more specific
that's fine! it's good to know that somebody has it working. I think I'll turn on nrepl debugging and see what's going on with the connect
Maybe you should ask in #cider also
Morning all
What's the idiomatic way to handle erroneous states/values in clojure? Coming from Elixir, I'm used to pattern matching and I've seen theres pattern matching in clojure too, but I don't know what the norm is
Exceptions even for non exceptional data? I'm thinking more like gracefully handling a 500 from an API call
If you prefer pattern matching, there is https://github.com/clojure/core.match. It is not non-idiomatic.
And if this was being passed up a call stack, is there any standard to tag the data structure as a 'bad' return. Eg, simply assoc a :state :error
?
Or should I just throw/catch?
The only solutions for error handling in clojure are nil punning and exceptions. The ecosystem provides alternatives, but not ones I'd say are idiomatic.
I think there is no consensus one way or the other. If you look at Pedestal: http://pedestal.io/reference/error-handling - it uses a key :exception. But plain old throw/catch works too.
Pedestal is special because it's not using normal stack frames, so they're making exceptions work with their concept of a stack frame.
Yeah, I agree Pedestal is special. But defining a bad value as opposed to nil punning works too.
Spec is the only core thing that does this I think. I'm not sure if it's actually exposed to user space though. Certainly not too much.
i just throw (ex-info msg map)
and put the information about error in the map
. let the caller handle the exception use if/case/cond/multimethod or like pedestal does, core.match
Seems like a good solution, thanks. I'm just toying with clojure at the moment and didn't know about ex-info
You can also try https://github.com/adambard/failjure for exceptions and error handling. It provides a way to handle exceptions and errors in a very functional way. It works for Clojurescript too.
In Clojure, the answer is often to think about your (possibly namespaced) map keys, and where they will travel throughout your app. Throwing up the call stack is just one more means of conveyance for a well-structured map.
What data structure should I use for a collection that has both sequential and associative characteristics?
Exceptions even for non exceptional data? I'm thinking more like gracefully handling a 500 from an API call
Is there any theoretical reason why ordered-map library doesn't support nth
via the Indexed interface? I noticed the same with clojure's sorted-map, sorted-set and priority-map, even though all of them have well-defined orderings
You might already know about this and it doesn't answer your question, but there is https://github.com/clojure/data.avl
Indexed is for the case where you can look up the nth value in better than linear time (hash, etc)
ordered or sorted would require a linear time walk of the data
the nth
function knows how to do this walk on a sequential (but not Indexed) data structure already
that's what I thought, but nth
already works on seqs in O(n) time - is that an exception to the rule?
hmm, it also looks like the ordered-map library uses an underlying .order
field which is a regular vector, so nth lookups could in fact be near-constant
oops, I should have known it wasn't that simple - dissoc on an ordered-map leaves nil
gaps in the .order vector, which requires a linear traversal to filter out
Thanks! I got it working with an cider-jack-in-cljs
with shadow, and then cider-connect-clj
to an external lein repl
, but this sounds better
java -jar Memories.jar -m memories.server
15:39:00.142 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
Exception in thread "main" java.lang.NumberFormatException: For input string: "-m"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.<init>(Integer.java:867)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at clojure.lang.Reflector.invokeConstructor(Reflector.java:305)
at memories.server$run_server.invokeStatic(server.clj:29)
at memories.server$run_server.invoke(server.clj:28)
at memories.server$_main.invokeStatic(server.clj:34)
at memories.server$_main.doInvoke(server.clj:33)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at memories.server.main(Unknown Source)
make: *** [run-jar] Error 1
I’m trying to make my first uberjar
, but trying to run the jar gives me this exception. What does Unknown Source
really mean here?@hkjels java -jar Memories.jar
already calls memorias.server
you are calling (memories.server/-main ["-m" "memories.server"])
what could be a great library to generate code documentation.
Documentation Tools here: https://www.clojure-toolbox.com/
i recently tried out https://github.com/weavejester/codox and was surprised to find out how easy it was to get something reasonable fairly quickly
Does anyone here has experience with manifold library?
@ramonp.rios what about it
I have a consume
that executes a function when i receive a message from a topic in activemq
(let [handler (fn [msg]
(log/info (str "creating customer into " http-url " : " msg))
(->> @(add-customer-ror http-url msg)
(log/info "returned from server ")))
stream (m/topic->stream conn topic)]
(ms/consume handler stream))
What i'm trying to do now it's to be able to handle errors with it
My first attempt was zip
this, putting into a chain
and then do a catch
for it
ah, I'm not too familiar with that part of manifold, only the parts I'm using in yada.
(let [handler (fn [msg]
(log/info (str "creating customer into " http-url " : " msg))
(->> @(add-customer-ror http-url msg)
(log/info "returned from server ")))
stream (m/topic->stream conn topic)]
(-> (ms/consume handler stream)
ms/zip
(d/chain (fn [_] (println "Done")) )
(d/catch (fn [e] (println e "Couldn't consume, restarting ...")))))
No problem, @U04V15CAJ 🙂 . I appreciate your help anyway. Someone can see this and add something to the discussion