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

Add Control.Monad.STM.Class #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Control/Monad/STM/Class.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{-# LANGUAGE CPP #-}

#if __GLASGOW_HASKELL__ >= 701
{-# LANGUAGE Trustworthy #-}
#endif

-----------------------------------------------------------------------------
-- |
-- Module : Control.Monad.STM
-- Copyright : (c) The University of Glasgow 2004
-- License : BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : non-portable (requires STM)
--
-- Class of monads based on @STM@.
-----------------------------------------------------------------------------

module Control.Monad.STM.Class (
MonadSTM(..)
) where

import GHC.Conc (STM)


-- | Monads in which 'STM' computations may be embedded.
-- Any monad built by applying a sequence of monad transformers to the
-- 'STM' monad will be an instance of this class.
--
-- Instances should satisfy the following laws, which state that 'liftSTM'
-- is a transformer of monads:
--
-- * @'liftSTM' . 'return' = 'return'@
--
-- * @'liftSTM' (m >>= f) = 'liftSTM' m >>= ('liftSTM' . f)@
class Monad m => MonadSTM m where
-- | Lift a computation from the 'STM' monad.
liftSTM :: STM a -> m a

-- | @since FIXME
instance MonadSTM STM where
liftSTM = id
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog for [`stm` package](http://hackage.haskell.org/package/stm)

## Unreleased

* Added `Control.Monad.STM.Class` module

* Before release, update `@since FIXME` annotations

## 2.5.0.0 *Sep 2018*

* Removed `alwaysSucceeds` and `always`, GHC's invariant checking primitives. (GHC #14324)
Expand Down
1 change: 1 addition & 0 deletions stm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ library
Control.Concurrent.STM.TBQueue
Control.Concurrent.STM.TSem
Control.Monad.STM
Control.Monad.STM.Class
other-modules:
Control.Sequential.STM

Expand Down