BSD-3-Clause licensed by Alexey Kuleshevich
Maintained by [email protected]
This version can be pinned in stack with:pvar-1.0.0.0@sha256:3d4a6855b0960baee78f6956f082eb8aa1cede52d2955b7faef186d1133f7964,1893

Module documentation for 1.0.0.0

Used by 1 package in lts-20.12(full list with versions):

pvar

Interface for a mutable variable PVar that can hold values that have Prim instance.

Status

Language Travis Azure Coveralls
GitHub top language Travis Build Status Coverage Status
Package Hackage Nightly LTS
pvar Hackage Nightly Nightly

Overview

Main features include:

  • Performance. There is practically no overhead when compared to operating on pure values, although there is a higher memory overhead, since PVar is backed by a MutableByteArray#
  • Atomic operations for PVars with Int values. This includes a unique function that is not available in ghc-prim out of the box:
atomicModifyIntPVar :: PrimMonad m => PVar m Int -> (Int -> (Int, a)) -> m a
  • Works in PrimMonad, therefore it is usable with ST, IO and various transformer monads.
  • Easy access to PVar contents with Storable
  • isByteArrayPinned, isMutableByteArrayPinned function that work on ghc-7.10 and ghc-8.0 as well as all the newer ones.

Changes

Changelog for pvar

1.0.0.0

  • Switch to MonadPrim type classes that was introduced in primitive-0.7.1.0
  • Fix definition PVar m a -> PVar a s. Parametrization on a monad is not general enough for some cases and making state token s last allows to use it with forall easier.
  • Relax monad in conversion to ForeignPtr

0.2.0.0

  • Rename modifyPVar to fetchModifyPVar and modifyPVarM to fetchModifyPVarM. This is a breaking change in favor of consistency with other librarries.
  • New implementation for modifyPVar and modifyPVarM that can return some artifact.
  • Addition of modifyFetchPVar and modifyFetchPVarM
  • Addition of atomicModifyFetchIntPVar and atomicFetchModifyIntPVar

0.1.1.0

  • Addition of backwards compatible:
    • isByteArrayPinned, isMutableByteArrayPinned (that work on ghc-7.10 and ghc-8.0)
    • Primitive versions isByteArrayPinned#, isMutableByteArrayPinned#
  • Support for GHC 7.10 and GHC 8.0
  • Re-export sizeOf and alignment for easier compatibility with older primitive versions.

0.1.0.0

  • Initial release