Fork me on GitHub

I’m starting with polylith, and I find that copying the function signatures from the implementation to the interface is annoying. I still like the idea of the separation though. I’m thinking about, as a starting point, generating these signatures. Have others have the same thought?


Are you migrating an existing codebase or writing code from scratch?


I’m rewriting an older project


But I started from scratch


There are no tools that I know about that could generate a first guess of an interface.


Ok, thank you. Then I might play with the idea, I’ll let you know if I do.

👍 1

I think everyone finds it a bit annoying at first, but I've found that it's a good time to think about docstrings and function ordering. I tend to keep my interface files in strictly alphabetical order and have the docstrings focused on users/client code calls, but my impl files in grouped functionality order and docstrings focused on future maintainers.

🧠 1
👍 2

I was just about to ask about docstrings. That was helpful, thank you!


Given a polylith project with global extra-deps, when I update a global dependency, then how do I get the dependent projects and trigger a CI?


Or is it not possible to define dependencies globally for all the bases/components?


You can only add library dependencies to the component, base and project level, not to the workspace top level. The way to go is to add the “global” dependency to all your projects.


The has this deps.edn-file in the root-level...what about these deps defined there? Why are they defined there?


I've read the whole docs, but probably didn't save that.


The :dev and :test aliases in the root deps.edn file configures the development project. All other aliases in that file configures things you want to do with the Clojure CLI, for example specifying the alias`:outdated` to use

🙏 1

Q about public dynamic vars and Polylith: I have some (currently legacy) code that has a public dynamic var that callers need to set via binding when calling into the module. The dynamic var is part of the public interface but it's also something that the implementation has to rely on. Given that, in Polylith, the interface requires the impl, I can't put it directly in the interface because the impl could not require the interface. Is this one of those cases where something like top.brick.interface.dynamic would be a good location, so that both client code and the brick implementation can require it, much as is recommended with protocols? (i.e., top.brick.interface.protocols)


I think this is the right way to go. Putting the shared code in the sub-interface looks clean to me.

polylith 2

If the only operations you are doing on the dynamic var are reading and binding, you can just expose some functions in the interface that do the same job



;; impl
(def ^{:dynamic true} *some-var*)

(defn some-var []

(defmacro with-some-var [new-val body]
  (binding [*some-var* new-val]

;; interface
(def some-var impl/some-var)

(defmacro with-some-var [new-val body]
  `(impl/with-some-var new-val body))


then just find+replace your binding usages + usage of the var