HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

Moduleatomic-counter-0.1.2.4Haskell2010

Control.Concurrent.Counter

Work with lifted Counter values in the IO monad. Please see other modules in this package for ST monad and for unlifted values.

Contents
  1. Create
  2. Read/write
  3. Arithmetic operations
  4. Bitwise operations
Synopsis
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

Read/write

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

Bitwise operations

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.