New packages effectful-postgresql and effectful-opaleye

I’ve uploaded 2 new packages candidates: effectful-postgresql and effectful-opaleye. These integrate postgresql-simple and opaleye with effectful. I’d appreciate any feedback, especially on the effectful unlifting stuff which I’m not 100% confident about.

effectful-postgresql defines a simple dynamic effect WithConnection which abstracts the idea of “give me a postgresql-simple Connection, so I can do something with it”. I can think of 2 ways of interpreting this effect, both of which are implemented in the library: providing one Connection for the entire duration of the interpreted program (see runWithConnection or runWithConnectInfo); or using a Pool of connections and only opening one when needed (see runWithConnectionPool).

effectful-opaleye builds on the above by using the provided Connection to run type-safe PostgreSQL operations using opaleye.


If possible, I’d like to request feedback from people who understand effectful/postgresql-simple/oplaye internals well (maybe @tomjaguarpaw or @Kleidukos?). At the moment in my interpreters I’m using localSeqUnlift(IO) : here, here, here and here. Does this make sense, or should I be using a different UnliftStrategy?

12 Likes

I’m going to do what’s called a Pro Gamer Move™ and strategically redirect you to @arybczak for the finer details of unlifting.

I wrote personal bindings to pg-transact, whose implementation you can see here: pg-transact-effectful/src/Effectful/PostgreSQL/Transact/Effect.hs at main · Kleidukos/pg-transact-effectful · GitHub (TW: it’s rife with unsafeEff_).

3 Likes