HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulerelude-1.2.0.0Haskell2010

Relude.Lifted.Concurrent

SPDX-License-Identifier : MIT Maintainer : Kowainik xrom.xkov@gmail.com Stability : Stable Portability : Portable

Lifted MVar and STM functions.

  • 4 types
  • 31 values
  • Packagerelude-1.2.0.0
  • Exports35
  • LanguageHaskell2010
  • LicenceMIT
  • SourceConcurrent.hs

MVar

10 declarations
datadata MVar a
#

An MVar (pronounced "em-var") is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.

Instances3NFData1, Eq, NFData
  • NFData1 MVarDefined in deepseq-1.5.0.0 · Control.DeepSeq
  • Eq (MVar a)Defined in ghc-internal-9.1003.0 · GHC.Internal.MVar

    Compares the underlying pointers.

  • NFData (MVar a)Defined in deepseq-1.5.0.0 · Control.DeepSeq

    NOTE: Only strict in the reference and not the referenced value.

STM

4 declarations
newtypenewtype STM a
#

A monad supporting atomic memory transactions.

Instances11Monad, Functor, MonadFix, Applicative, Alternative, MonadPlus, …
  • Monad STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Functor STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • MonadFix STMDefined in stm-2.5.3.1 · Control.Monad.STM · orphan
  • Applicative STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Alternative STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync

    Takes the first non-retrying STM action.

  • MonadPlus STMDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync

    Takes the first non-retrying STM action.

  • MonadCatch STMDefined in exceptions-0.10.9 · Control.Monad.Catch
  • MonadThrow STMDefined in exceptions-0.10.9 · Control.Monad.Catch
  • MArray TArray e STMDefined in stm-2.5.3.1 · Control.Concurrent.STM.TArray
  • Semigroup a => Semigroup (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Monoid a => Monoid (STM a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
valuethrowSTM :: Exception e => e -> STM a
#

A variant of throw that can only be used within the STM monad.

Throwing an exception in STM aborts the transaction and propagates the exception. If the exception is caught via catchSTM, only the changes enclosed by the catch are rolled back; changes made outside of catchSTM persist.

If the exception is not caught inside of the STM, it is re-thrown by atomically, and the entire STM is rolled back.

Although throwSTM has a type that is an instance of the type of throw, the two functions are subtly different:

throw e    `seq` x  ===> throw e
throwSTM e `seq` x  ===> x

The first example will cause the exception e to be raised, whereas the second one won't. In fact, throwSTM will only cause an exception to be raised when it is used within the STM monad. The throwSTM variant should be used in preference to throw to raise an exception within the STM monad because it guarantees ordering with respect to other STM operations, whereas throw does not.

valuecatchSTM :: Exception e => STM a -> (e -> STM a) -> STM a
#

Exception handling within STM actions.

catchSTM m f catches any exception thrown by m using throwSTM, using the function f to handle the exception. If an exception is thrown, any changes made by m are rolled back, but changes prior to m persist.

TVar

7 declarations
datadata TVar a
#

Shared memory locations that support atomic memory transactions.

Instances1Eq
  • Eq (TVar a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync

TMVar

14 declarations
newtypenewtype TMVar a
#

A TMVar is a synchronising variable, used for communication between concurrent threads. It can be thought of as a box, which may be empty or full.

Instances1Eq
  • Eq (TMVar a)Defined in stm-2.5.3.1 · Control.Concurrent.STM.TMVar