lpsmith / postgresql-simple

Mid-level client library for accessing PostgreSQL from Haskell
Other
206 stars 71 forks source link

Add basic forward cursor support? #211

Closed BardurArantsson closed 7 years ago

BardurArantsson commented 7 years ago

So, I've been playing around a bit with various streaming abstractions, and it seems that often one needs to "fall back" on explicit cursor use to interface with postgresql-simple from such libraries. (io-streams would be an example, but also thinking conduit and the like.)

it seems to me that it would be kind of nice to have a basic Cursor API included in postgresql-simple. I think it could be as simple even as just extracting "close", "declare" and "fetch" from the "fold" implementation into documented functions. I think it'd be a good little win because it's a bit messy and also a little tricky (e.g. the "isFailedTransactionError" in "close").

Would you be inclined to accept a PR to do something like this? (Assuming code quality, etc. is up to snuff.)

EDIT: Seems to be within the remit of postgresql-simple as a mid-level library :)

lpsmith commented 7 years ago

Yeah, probably, assuming it's reasonable quality. I'd be able to give better feedback if you sketched out an API though. Incidentally, have you seen my postgresql-simple-streams library?

BardurArantsson commented 7 years ago

Cool, I'll do a pull request with the basic implementation, shouldn't take too long.

(Yes, I did see that. It seems to be a bit out of date with warnings about partial pattern matches and Text.Blaze dependencies which don't really make sense since text >n.nn has builders built-in, etc.)

BardurArantsson commented 7 years ago

Alright, I've put up the PR at https://github.com/lpsmith/postgresql-simple/pull/212 We can discuss further there.