portland-or

Clojure in PDX yo!
bill 2017-02-07T20:20:01.000065Z

I’ll add this wonderful little series of short posts: http://www.clojure.net/2012/02/02/Monads-in-Clojure/

mattly 2017-02-07T20:22:41.000066Z

@bill yeah I gave the talk on cats a few months back https://github.com/funcool/cats

mattly 2017-02-07T20:23:01.000068Z

that http://muhuk.com link is 404ing

mattly 2017-02-07T20:23:15.000069Z

as it appears their site is offline

bill 2017-02-07T20:26:17.000071Z

wish I hadn’t missed your Cats talk

mattly 2017-02-07T20:27:38.000072Z

the code /comments are here: https://github.com/mattly/pdxclj-cats-promesa/blob/master/src/preso.clj

bill 2017-02-07T20:27:48.000074Z

tx!

mattly 2017-02-07T20:27:57.000075Z

I tried to walk through the "why" before the "what"

bill 2017-02-07T20:28:34.000076Z

perusing…

mattly 2017-02-07T20:29:48.000077Z

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

bill 2017-02-07T20:32:17.000078Z

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

mattly 2017-02-07T20:32:55.000080Z

heh

mattly 2017-02-07T20:33:34.000081Z

a lot of the documentation / writeups for mount encourage you to put the behavior in the start/stop clauses of defstate

mattly 2017-02-07T20:34:02.000082Z

once I realized that was a bad idea and stopped doing it, it became a lot easier to manage

bill 2017-02-07T20:39:25.000083Z

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.

bill 2017-02-07T20:41:30.000084Z

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

mattly 2017-02-07T20:56:47.000085Z

yeah that's more or less what I do

mattly 2017-02-07T20:57:11.000086Z

I have two postgresql databases and a mysql database I work with

bill 2017-02-07T20:57:28.000087Z

all at once?

mattly 2017-02-07T20:57:38.000088Z

config validation and pool creation are its own concern

mattly 2017-02-07T20:57:41.000089Z

yep

mattly 2017-02-07T20:57:54.000090Z

as well as spark, cassandra and dynamodb

mattly 2017-02-07T20:58:04.000091Z

it's a mess

bill 2017-02-07T20:58:06.000092Z

wow

mattly 2017-02-07T20:58:16.000093Z

but that mess is why I was able to push for clojure on this project 😄

mattly 2017-02-07T20:58:26.000094Z

in what is otherwise a ruby shop

bill 2017-02-07T20:58:37.000095Z

step 1: create mess, step 2: propose awesome solution, step 3: profit!

mattly 2017-02-07T20:58:45.000096Z

I didn't create the mess tho

mattly 2017-02-07T20:58:46.000097Z

😄

mattly 2017-02-07T20:59:14.000098Z

the only stores I own outright are spark and one of the pg databases

mattly 2017-02-07T20:59:34.000099Z

the rest are Other Services' Data

mattly 2017-02-07T20:59:40.000100Z

and some of it is HIPPA-protected