Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction class constraints #147

Merged
merged 29 commits into from
Jul 17, 2023
Merged

Transaction class constraints #147

merged 29 commits into from
Jul 17, 2023

Conversation

mzabani
Copy link
Owner

@mzabani mzabani commented Jul 16, 2023

Fixes #133

mzabani added 29 commits July 5, 2023 19:25
This ensures fully qualified object names end up in the
representations, which is nice, but more importantly, it ensures
the schema is immune to the user's search_path setting.
Still very early work. The `InTxnT` ctor must be exposed for some
of the hoisting, and it's not clear how we can allow hoisting
monadic type parameters of custom types without doing so.
The monadic type parameter forced hoisting in lots of places where
it was purely unnecessary. This even helped clean up some of the
code.
A callback that runs in `InTxnT m` needs to be callable from more
than one base monad. In one branch of code, it's called from `m`,
but in another, it's called from `ResourceT m`. Its type is clearly
insufficient, so we'll probably need a class.
actions in the code.

This is a "cheap "escape from more restrictive monadic composition,
since now last actions must be able to run in _any_ monad that
satisfies a few class constraints, rather than constraints based
on the base monad.

This is fine for our codebase as it is, but is over-restrictive.
- Lots of type applications to guide type inference
- Lots of apparently redundant class constraints
- Lots of `txn ~ InTxnT (ResourceT m)`, which should be unnecessary
- Pushing `MonadResource m` constraint up, beyond where needed

It's time to start tidying up
In general, this pushes MonadResource deeper into where it's
necessary, but inside the Internal module it is actually added
to one function where it isn't strictly necessary, but where it
better aligns monadic types with the other functions, reducing
the need for lifting
It is possible to declare a function that is not constrained with
`NotInTxn m`, yet it called `beginCommitTxnBracket` by using
`liftIO`.
Otherwise retry tests fail, and that's something I prefer to fix
some other time.
With the new transaction class constraints, we can be much more
certain every transaction is read-write
@mzabani mzabani marked this pull request as ready for review July 17, 2023 11:03
@mzabani mzabani merged commit 088b792 into master Jul 17, 2023
@mzabani mzabani deleted the transaction-class-constraints branch July 17, 2023 11:04
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.

SQL schema specification inconsistencies
1 participant