Skip to content

MonadSTM #22

Open
Open

Description

@mitchellwrosen

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 ()

Activity

  1. simonmar commented on Jun 17, 2019

    @simonmar
    Member

    Seems reasonable. Want to make a PR?

  2. mitchellwrosen commented on Jun 17, 2019

    @mitchellwrosen
    ContributorAuthor

    Sure

  3. seanhess commented on Nov 10, 2020

    @seanhess

    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

  4. mitchellwrosen commented on Nov 13, 2020

    @mitchellwrosen
    ContributorAuthor

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

  5. demming commented on Mar 24, 2021

    @demming

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

  6. fumieval commented on Jan 10, 2022

    @fumieval

    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

  7. arybczak commented on Sep 6, 2026

    @arybczak
    Contributor

    I want to write a type signature like: (MonadReader Env m, MonadSTM m) => m ()

    You can, it's (MonadReader Env m, MonadBase STM m) => m () with MonadBase from transformers-base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions