@mattly http://blog.muhuk.com/2015/10/01/who_in_their_right_mind_would_use_monads_in_clojure.html#.WJorvhIrLUI
I’ll add this wonderful little series of short posts: http://www.clojure.net/2012/02/02/Monads-in-Clojure/
@bill yeah I gave the talk on cats a few months back https://github.com/funcool/cats
that http://muhuk.com link is 404ing
as it appears their site is offline
wish I hadn’t missed your Cats talk
the code /comments are here: https://github.com/mattly/pdxclj-cats-promesa/blob/master/src/preso.clj
tx!
I tried to walk through the "why" before the "what"
perusing…
I use "maybe math" as an example at the beginning because I've ended up having to implement some variant of that in pretty much every language I've ever worked in
@mattly looking more closely at your code example…
https://clojurians.slack.com/files/mattly/F410FHD6V/mount_patterns__old_and_new.clj
I see what you did there. All dependency on state is encapsulated in a defstate
. Code in defstate
can call functions so long as they reference no variables def’d outside the fn. (was gonna say “pure” fns but um, this is Clojure)
heh
a lot of the documentation / writeups for mount encourage you to put the behavior in the start/stop clauses of defstate
once I realized that was a bad idea and stopped doing it, it became a lot easier to manage
So back to Mount vs. Component: the point about Mount defining a bunch of singletons is apt. My fave example of that is an app that needs to read from one PostgreSQL db and write to another one. In Component, I’d just have two (differently-configured) instances of my db component and I’d be off to the races. In Mount this won’t work because you configure the database namespace once (to talk to the database) and you’re stuck. My take is that this is what Yurt is for. Yurt uses Boot Pods to provide separate isolated worlds. Communication between these Pods looks like it’d be cumbersome.
then again, w/ your scheme perhaps I could easily define two states: one for each db, initialized from two sets of config settings This would entail moving that state creation (for the db connections) outside the db namespace into some higher-level (app-specific) one
yeah that's more or less what I do
I have two postgresql databases and a mysql database I work with
all at once?
config validation and pool creation are its own concern
yep
as well as spark, cassandra and dynamodb
it's a mess
wow
but that mess is why I was able to push for clojure on this project 😄
in what is otherwise a ruby shop
step 1: create mess, step 2: propose awesome solution, step 3: profit!
I didn't create the mess tho
😄
the only stores I own outright are spark and one of the pg databases
the rest are Other Services' Data
and some of it is HIPPA-protected