HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulelifted-base-0.2.3.12Haskell98

Control.Concurrent.Lifted

This is a wrapped version of Control.Concurrent with types generalized from IO to all monads in either MonadBase or MonadBaseControl.

  • 1 type
  • 21 values

Concurrent Haskell

1 declaration
datadata ThreadId
#

A ThreadId is an abstract type representing a handle to a thread. ThreadId is an instance of Eq, Ord and Show, where the Ord instance implements an arbitrary total ordering over ThreadIds. The Show instance lets you convert an arbitrary-valued ThreadId to string form; showing a ThreadId value is occasionally useful when debugging or diagnosing the behaviour of a concurrent program.

Note: in GHC, if you have a ThreadId, you essentially have a pointer to the thread itself. This means the thread itself can't be garbage collected until you drop the ThreadId. This misfeature would be difficult to correct while continuing to support threadStatus.

Instances3Eq, Ord, Show
  • Eq ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Ord ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync
  • Show ThreadIdDefined in ghc-internal-9.1003.0 · GHC.Internal.Conc.Sync

Basic concurrency operations

6 declarations
valuefork :: MonadBaseControl IO m => m () -> m ThreadId
#

Generalized version of forkIO.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

valueforkWithUnmask
  1. :: MonadBaseControl IO m
  2. => (forall a. m a -> m a) -> m ()
  3. -> m ThreadId
#

Generalized version of forkIOWithUnmask.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

valueforkFinally
  1. :: MonadBaseControl IO m
  2. => m a
  3. -> Either SomeException a -> m ()
  4. -> m ThreadId
#

Generalized version of forkFinally.

Note that in forkFinally action and_then, while the forked action and the and_then function have access to the captured state, all their side-effects in m are discarded. They're run only for their side-effects in IO.

Threads with affinity

valueforkOn :: MonadBaseControl IO m => Int -> m () -> m ThreadId
#

Generalized version of forkOn.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

Scheduling

1 declaration

Blocking

Waiting

Communication abstractions

0 declarations

Bound Threads

5 declarations
valueforkOS :: MonadBaseControl IO m => m () -> m ThreadId
#

Generalized version of forkOS.

Note that, while the forked computation m () has access to the captured state, all its side-effects in m are discarded. It is run only for its side-effects in IO.

Weak references to ThreadIds

1 declaration