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

Moduleprimitive-0.9.1.0Haskell2010

Data.Primitive.PrimVar

Variant of MutVar that has one less indirection for primitive types. The difference is illustrated by comparing MutVar Int and PrimVar Int:

  • MutVar Int: MutVar# --> I#

  • PrimVar Int: MutableByteArray#

This module is adapted from a module in Edward Kmett's prim-ref library.

  • 1 type
  • 17 values
  • Packageprimitive-0.9.1.0
  • Exports18
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourcePrimVar.hs

Primitive References

9 declarations

Atomic Operations

9 declarations

Atomic operations on `PrimVar s Int`. All atomic operations imply a full memory barrier.

valuecasInt :: PrimMonad m => PrimVar (PrimState m) Int -> Int -> Int -> m Int
#

Given a primitive reference, the expected old value, and the new value, perform an 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.