Fork me on GitHub
Fred Ross04:03:39

@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


What's the workflow for working with a clojure(script) project as far as repls go?

Fred Ross04:03:35

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


Cider doesn't seem to like having both a clj and a cljs repl at the same time


@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


I'm using shadow-cljs for the frontend and lein for the backend


cider-jack-in-cljs works like a dream, except it doesn't work for clj


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?


yup! it did want to connect to the lein nrepl server by default, though


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


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 and nil punning


Exceptions even for non exceptional data? I'm thinking more like gracefully handling a 500 from an API call


Or just case/cond/multiple dispatch on data shape/values

ūüĎć 4

‚ėĚÔłŹ this one


If you prefer pattern matching, there is 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: - 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 for exceptions and error handling. It provides a way to handle exceptions and errors in a very functional way. It works for Clojurescript too.


If you're Haskelly-minded


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?


You mean like an ordered-map?


oh.. I'll try playing around with that, thanks!

replied to a thread:Exceptions and nil punning

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


I'll check that out too, thanks!

Alex Miller (Clojure team)12:03:51

Indexed is for the case where you can look up the nth value in better than linear time (hash, etc)

Alex Miller (Clojure team)12:03:00

ordered or sorted would require a linear time walk of the data

Alex Miller (Clojure team)12:03:53

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

Alex Miller (Clojure team)13:03:39

then they could implement it (sorted maps are trees)

ūüĎĆ 4

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(
        at java.lang.Integer.parseInt(
        at java.lang.Integer.<init>(
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
        at java.lang.reflect.Constructor.newInstance(
        at clojure.lang.Reflector.invokeConstructor(
        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(
        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"])


You’re absolutely correct


thank you!

Eduardo Mata15:03:34

what could be a great library to generate code documentation.


i recently tried out and was surprised to find out how easy it was to get something reasonable fairly quickly

Ramon Rios17:03:52

Does anyone here has experience with manifold library?

Ramon Rios17:03:32

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))

Ramon Rios17:03:52

What i'm trying to do now it's to be able to handle errors with it

Ramon Rios17:03:06

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.

Ramon Rios17:03:44

(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)
          (d/chain (fn [_] (println "Done")) )
          (d/catch (fn [e] (println e "Couldn't consume, restarting ...")))))

Ramon Rios17:03:23

No problem, @U04V15CAJ ūüôā . I appreciate your help anyway. Someone can see this and add something to the discussion


Is it behaving differently than you'd expect as written?