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?

13 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

Thanks! @arybczak, do you have any Pro™ insights on unlifting in this case?

I had a quick look and they look alright to me. FWIW if you ever need ConcUnlift at any point and you use SeqUnlift, you’ll get an appropriate error at runtime when testing the code, so I wouldn’t worry about this too much.

2 Likes

Thanks @Kleidukos and @arybczak for the help!

Both packages are now released: effectful-postgresql and effectful-opaleye. Enjoy :slight_smile:

1 Like

Congratulations, I just added them on the ecosystem page Data Storage | Effectful

1 Like