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

Moduleatomic-counter-0.1.2.4Haskell2010

Control.Concurrent.Counter.Lifted.IO

Lifted Control.Concurrent.Counter.Lifted.Counter specialized to operate in the IO monad.

  • 1 type
  • 10 values
newtypenewtype Counter
#

Memory location that supports select few atomic operations.

Isomorphic to IORef Int.

Instances1Eq
  • Eq CounterDefined in atomic-counter-0.1.2.4 · Control.Concurrent.Counter.Lifted.IO

    Pointer equality

Create

1 declaration

Read/write

3 declarations
valueset :: Counter -> Int -> IO ()
#

Atomically assign new value to the counter.

valuecas
  1. :: Counter
  2. -> Int

    Expected old value

  3. -> Int

    New value

  4. -> IO Int
#

Atomic compare and swap, i.e. write the new value if the current value matches the provided old value. Returns the value of the element before the operation

Arithmetic operations

2 declarations
valueadd :: Counter -> Int -> IO Int
#

Atomically add an amount to the counter and return its old value.

valuesub :: Counter -> Int -> IO Int
#

Atomically subtract an amount from the counter and return its old value.

Bitwise operations

4 declarations
valueand :: Counter -> Int -> IO Int
#

Atomically combine old value with a new one via bitwise and. Returns old counter value.

valueor :: Counter -> Int -> IO Int
#

Atomically combine old value with a new one via bitwise or. Returns old counter value.

valuexor :: Counter -> Int -> IO Int
#

Atomically combine old value with a new one via bitwise xor. Returns old counter value.

valuenand :: Counter -> Int -> IO Int
#

Atomically combine old value with a new one via bitwise nand. Returns old counter value.