Skip to content

Conversation

@arybczak
Copy link
Member

@arybczak arybczak commented Sep 15, 2025

Copy link

@Raveline Raveline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks generally good to me. I got a bit sidetracked when reading because your withState is not at all behaving like the withState from mtl and I guess it's a bit confusing for people who are used to the mtl one, but since it's a purely internal function, it doesn't matter.

{ unDBEff :: Eff (State (DBState es) : es) a
}
deriving newtype (Functor, Applicative, Monad, MonadThrow, MonadCatch, MonadMask)
runDB cs0 ts0 m = PQ.withConnectionData cs0 ts0 $ \cd0 -> do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of do in this block that are not necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, as I said before, this is for appeasing emacs indentation mode :p

runDB
:: forall es a
. IOE :> es
:: IOE :> es

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come you can now remove the forall here now ? Or was it already unnecessary to begin with ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old runWithState and doWithTransaction from the where clause was using it before.

GetLastQuery :: DB m SomeSQL
GetTransactionSettings :: DB m TransactionSettings
SetTransactionSettings :: TransactionSettings -> DB m ()
GetLastQuery :: DB m (BackendPid, SomeSQL)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you very often don't care about the first parameter (as illustrated in the change you made in tests), it might be interesting to add a helper getLastQuery' which basically fmap snd over getLastQuery. It's likely to be a very common use-case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite. getLastQuery is never used in regular code, it's pretty much a helper for throwDB to fill in details in the DBEXception wrapper.

@arybczak arybczak marked this pull request as ready for review November 20, 2025 09:10
@arybczak arybczak requested a review from Raveline November 20, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants