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

Would it be a good idea to write proper instances for MonadResult? #349

Open
MangoIV opened this issue Nov 5, 2023 · 5 comments
Open

Would it be a good idea to write proper instances for MonadResult? #349

MangoIV opened this issue Nov 5, 2023 · 5 comments
Labels

Comments

@MangoIV
Copy link
Collaborator

MangoIV commented Nov 5, 2023

Hi, currently the only instance for MonadResult is the catchall instance that then requires a MonadIO; would it be a good idea to instead write proper instances for all the usual Monad transformers to be able to write interpretations that are not necessarily impure without using {-# OVERLAPPING #-} pragmas on the MonadResult instance?

@MangoIV
Copy link
Collaborator Author

MangoIV commented Nov 5, 2023

Also what I don't quite understand is; if we disregard overlapping instances, we get exactly MonadIO, right, because for any Monad m we instantly discharge into MonadIO, except if we specify a MonadResult constraint on that m

@echatav
Copy link
Contributor

echatav commented Nov 14, 2023

MonadResult is only needed to define safe Transactions. Otherwise you’re right, MonadIO would suffice alone. Users should not write MonadResult instances.

@echatav
Copy link
Contributor

echatav commented Nov 15, 2023

You can imagine that MonadResult is a superclass of MonadIO.

class MonadResult m => MonadIO m

It’s not possible to do that but the catchall instance mostly accomplishes the same thing.

instance MonadIO m => MonadResult m

@MangoIV
Copy link
Collaborator Author

MangoIV commented Nov 15, 2023

perhaps I need to rephrase my issue here; currently, afaict, there's no way to escape from PQ but using IO; there's no way to actually interpret the SQL queries in any other way; what I want to do is interpret a subset of squeal queries in a pure way, there's no way of doing so currently, afaict, because of the MonadIO io => PQ ... io and the getRows :: ... io .. type signatures where the latter stems from the catchall instace of MonadResult

@echatav
Copy link
Contributor

echatav commented Nov 15, 2023

I see. I’m afraid I didn’t anticipate such a need as reinterpreting PQ purely as libPQ is IO bound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants