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

Separate SqlTransaction monad from SqlQueryT #28

Closed
8 tasks done
brandonchinn178 opened this issue Dec 6, 2020 · 0 comments · Fixed by #29
Closed
8 tasks done

Separate SqlTransaction monad from SqlQueryT #28

brandonchinn178 opened this issue Dec 6, 2020 · 0 comments · Fixed by #29

Comments

@brandonchinn178
Copy link
Owner

brandonchinn178 commented Dec 6, 2020

The monad that is added to the monad transformer stack and maintains the database connection pool / transaction information should be separate from the monad that executes SQL queries in a transaction.

Effectively, SqlTransaction should be the same thing as persistent's SqlPersistT type, except we want to restrict unsafe IO actions, like forkIO (see #7) or IO actions that aren't rerunnable. This is so that databases where transactions are expected to be retried if serialization fails (e.g. https://www.postgresql.org/docs/9.5/transaction-iso.html).

  • Add separate SqlTransaction type
  • SqlTransaction should forbid MonadIO instances (using GHC.TypeLits.TypeError)
  • Add MonadRerunnableIO class + instance
    • with rerunnableIO and rerunnableM
  • Write withTransaction :: SqlTransaction m a -> m a
  • Test SqlTransaction does not allow arbitrary IO
  • Update docs
  • Update README, haddocks, etc.
  • Update CHANGELOG
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 a pull request may close this issue.

1 participant