How to support hasql-transaction? #294
Unanswered
abigailalice
asked this question in
Q&A
Replies: 1 comment
-
Doesn't existence of transaction imply that it "just works" with hasql-effectful? Since it gives you |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to just get started with effectful, and wanted to try porting the use of the hasql-transaction library in my code to it, and was stumped how to do it (or if it's even possible). I saw that hasql-effectful library, but I don't (think) the way they port the
Session
type can work forTransaction
. In particular, the type forrunHasqlIO
here:Seems to imply that it would be possible to do arbitrary IO within
Eff (Transaction : es)
if I were to implement it similarly. However, that's not possible, asTransaction
isn't an instance ofMonadIO
. Additionally, it seems to leaveError UsageError :> es
constraints on each individual use ofsend
, when it should really only have one on therunTransaction
function.So I'm guessing what that type of implementation must actually do is run each individual
Transaction
in its own transaction, rather than running them all together in a single one, obviously not what I want. So I think I need a type more likeExcept I'm pretty sure even that would allow an
IOE :> es'
constraint to slip in, since my understanding was effects can be duplicated. And #272 makes me wonder if it's not possible, since Transaction sits at the bottom of my monad stack, but a comment at the end seems to indicate maybe they managed? Plus, Transaction is internally implemented with types with all the very basic monad transformers (ExceptT
,StateT
,ReaderT
), so maybe it's possible in this specific case even if not in the general one?Ultimately what I want is algebraic errors and readers overtop a transaction, to replace my existing
ExceptT e (ReaderT r) Transaction a
, but consideringEffectful.Concurrent.STM
doesn't lift functions likeretry :: STM :> es => Eff es a
to allow reader effects withinSTM
I suspect I'm out of luck for transactions as well, barring some way to restrictes
to make things like that work.Just trying to confirm I'm understanding things correctly though, or if digging into the internals more will lead to me figuring out how to implement it.
Beta Was this translation helpful? Give feedback.
All reactions