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

MonadSTM #22

Open
mitchellwrosen opened this issue Jun 14, 2019 · 6 comments
Open

MonadSTM #22

mitchellwrosen opened this issue Jun 14, 2019 · 6 comments

Comments

@mitchellwrosen
Copy link
Contributor

Could this MonadSTM type class be adopted by the stm package?

It would be useful for certain abstractions such as the "console region" defined in concurrent-output, which currently defines its own equivalent type class.

My use case involves a monad transformer atop such a thing; I want to write a type signature like:

(MonadReader Env m, MonadSTM m) => m ()
@simonmar
Copy link
Member

Seems reasonable. Want to make a PR?

@mitchellwrosen
Copy link
Contributor Author

Sure

@seanhess
Copy link

Is there any movement on this? Or is there another recommended path? It seems like wanting to have your TVars in a MonadReader instance would be a pretty common use case

@mitchellwrosen
Copy link
Contributor Author

As far as I can tell the PR is ready to merge

@demming
Copy link

demming commented Mar 24, 2021

Hey, any updates on this issue? I too would love to use it from the stm package.

@fumieval
Copy link

I'm not sure if it's a good idea to provide instances for both STM and IO. Unlike MonadIO, it's not a monad homomorphism because liftRegion (a >>= k) and liftRegion m >>= liftRegion . k are completely different; hiding atomically semantics behind such abstraction seems like a footgun.

If the usecase is about monads like ReaderT Env STM, it should not have an instance for IO. Otherwise generalising atomically to MonadIO m => STM a -> m a seem like the right approach

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

No branches or pull requests

5 participants