Fork me on GitHub

How am I supposed to spec (with spec.alpha) XML endpoints on a Reitit API?


@UAEH11THP if you figure out how to spec XML, I can try to cook up an example how to integrate it to reitit.


Haven’t specced XML, #clojure-spec might help with that.


I've found some Stack Overflow responses about Swagger specs for XML


Is there a predicate to distinguish set or hashsets from other kind of sequences ?


user=> (set? #{})


jupp works 🙂


looked at the wrong place in ... thanx


clojure.repl which is used for you by default has a few useful functions for finding things: apropos which can find things by regex or substring of name and find-doc which finds things by regex or substring of their documentation


user=> (apropos "set")
(clojure.core/-reset-methods clojure.core/aset clojure.core/aset-boolean clojure.core/aset-byte clojure.core/aset-char clojure.core/aset-double clojure.core/aset-float clojure.core/aset-int clojure.core/aset-long clojure.core/aset-short clojure.core/bit-set clojure.core/compare-and-set! clojure.core/hash-set clojure.core/ref-set clojure.core/reset! clojure.core/reset-meta! clojure.core/reset-vals! clojure.core/resultset-seq clojure.core/set clojure.core/set-agent-send-executor! clojure.core/set-agent-send-off-executor! clojure.core/set-error-handler! clojure.core/set-error-mode! clojure.core/set-validator! clojure.core/set? clojure.core/sorted-set clojure.core/sorted-set-by clojure.core/var-set clojure.core/vreset! clojure.pprint/set-pprint-dispatch clojure.repl/set-break-handler! clojure.spec.gen.alpha/set)
- it's a lot, but set? is in there


and there's also doc of course

user=> (doc set?)
  Returns true if x implements IPersistentSet


it would be cool to see the doc strings fixed up so that find-doc would be more likely to find the right thing for the intuitive query (eg. if #"predicate.*set" matched that doc string)


yea I know these, unfortunately I expected the set? predicate in the clojure.set namespace ... so I read in the wrong direction ...




nvm, that is way off


FYI, if you are using the compression ns of be aware that it suffers the Zip Slip vulnerability We released a patched version under

💯 12

Is it possible to with-redefs-fn a private Var? I'm trying to mock up the underpinnings of io.pedestal.log/error in a test:

(deftest go-resolve-expr-throws
  (let [*keyvals (atom nil)
        log-expr (ns-resolve (find-ns 'io.pedestal.log) 'log-expr)]
    (with-redefs-fn {log-expr (fn [_ _ kvs]
                                (swap! *keyvals conj (apply array-map kvs)))}
      (fn []
        (is (= [nil {:errors [{:message "Exception in expr"}]}]
                 (go-resolve _
                   (throw (ex-info "Exception in expr" {}))))))

        (is (= []
But my test runs as if the redef is not in place. Thoughts?


Try to use fully qualified var name - (with-redefs-fn {io.pedestal.log/log-expr ...


Does not work with a private var.


I need to design a complicated feature. It’s a webapp that needs to collect a bunch of forms from a user, and save them to a DB. The trouble is, there are a bunch of forms, there’s a workflow for determining which forms to collect from the user, and the workflow will change over time, so I’d like the UI, the backend service and the DB to be driven from the same workflow/ruleset. Are there any good blog posts / talks / libraries for dealing with that problem?


Fulcro (a battery-included fork of can be a good building block for your problem. It provides a full-stack framework (or in your words: workflow/ruleset) so you won't be overwhelmed by too many decisions to make. Its data driven nature of the whole system (client side db, server-client communication) keeps your app flexible at the same time. Subsystems are pretty independent hence easy to refactor. It takes time to learn, though


haven't used either of these myself (yet), but perhaps using a rules engine would serve your purposes?


sounds like it might a be a good fit for some kind of finite state machine or finite state transducer


I don't have a go to library for that. in the past I have created a defrecord to hold the parts of a fst ( shows it as a 6-tuple), and then gone from there, accumulating little helper functions for things like adding state transitions to a machine, and querying the machine for which states can receive certain events. macros for closed dispatch over machine states and outputs (because the machine is a effectively a compile time constant macros can use it to validate things).

👍 8

@arohner @yogthos has a blogpost describing (if I’m understanding correctly) something like that here


Thanks! This is interesting, and part of the problem, but not the whole thing. I have a workflow that says “The user needs to fill in form A, or form B. If check box ‘foo’ on form B is checked, they also need to fill out form C, etc. I would like that workflow to be 1) obviously laid out in one place. 2) kept in sync between browser and backend, so both sides agree on which forms need to be gathered


and for extra fun, some forms are only necessary if a backend server calculation says so


depending on how you represent a state machine, you can get very abstract. each state is a set of required form names, inputs sets of completed and validated form names


huh, I hadn’t thought of just using a pure state machine, interesting.


Nice! And bundles of rules can be composed as data and switched in as required.


As usual, @ztellman has already solved the problem


holy crap that’s a cool library


I haven't actually found automat to be super useful for state machines. automat seems to be all about compiling a state machine for accepting a sequence of events as something that runs really fast, which is cool, but for how I have used state machines in the past, the running time of transitions of the state machine aren't so important, the ability to query the machine about states and assert that certain states accept similar inputs, and really manipulating the fsm as an object versus "running" it has been much more important