pvar: Mutable variable with primitive values

[ bsd3, data, library ] [ Propose Tags ]

Mutable variable PVar that is backed by a single value MutableByteArray

[Skip to Readme]
Versions [faq],,
Change log CHANGELOG.md
Dependencies base (>=4.8 && <6), deepseq, primitive (>= [details]
License BSD-3-Clause
Copyright 2020 Alexey Kuleshevich
Author Alexey Kuleshevich
Maintainer alexey@kuleshevi.ch
Category Data
Home page https://github.com/lehins/pvar#readme
Bug tracker https://github.com/lehins/pvar/issues
Source repo head: git clone https://github.com/lehins/pvar
Uploaded by lehins at 2020-04-02T02:59:39Z
Distributions NixOS:
Downloads 401 total (10 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2020-04-02 [all 1 reports]


[Index] [Quick Jump]


Maintainer's Corner

For package maintainers and hackage trustees

Readme for pvar-

[back to package description]


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


| Language | Travis | Azure | Coveralls | |:--------:|:------:|:-----:|:---------:| | GitHub top language | Travis | Build Status | Coverage Status

| Package | Hackage | Nightly | LTS | |:-------------------|:-------:|:-------:|:---:| | pvar| Hackage| Nightly| Nightly


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.