BSD-3-Clause licensed by Dominik Schrempf
Maintained by [email protected]
This version can be pinned in stack with:circular-0.4.0.3@sha256:ced37f14ca75d6a49eb6151cc0775139eb08eadb269ea8c98d45012b2095f486,1842

Module documentation for 0.4.0.3

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

Circular

Circular stacks of fixed size.

Circular stacks are just normal vectors with a pointer to the last element.

Circular stacks may not be what you need because:

  • You need all values at a later time anyways.
  • You don’t want a monadic work flow, because circular stacks use mutable vectors.

Circular stacks are useful to you because:

  • They have a fixed size and consequently have constant memory usage. Constant memory usage is important if values are gathered continuously but only a specific number of values is needed at a later time.
  • They are fast, especially when summary statistics need to be computed across the stack.

Elements pushed on a circular stack replace the oldest (deepest) elements on the stack. QuickCheck and unit tests with HSpec give promising results — have a look yourself.

I use circular stacks, for example, as the data type for traces of Markov chains. In this case, lists cannot be used reliably, because the space requirement increases linearly with the chain length.

Circular is actively developed and functions may be removed, renamed, or changed. Ideas are welcome!

Changes

Revision history for circular

Unreleased changes

0.4.0.3

  • Tooling and compilation with GHC 9.2.3.

0.4.0.2

  • Tooling updates related to GHC 9.2.1.

0.4.0.1

  • Minor changes mostly related to tooling.
  • Nix support.

0.4.0.0

  • Do not export data constructors nor record fields.
  • fromVectorWith.

0.3.1.1

Cabal changes, versioning changes.

0.3.1

  • Change monadic folds so that commutativity is not anymore required.
  • Provide foldKM, a fold over the last k elements on the stack.

0.3.0

  • Bugfix take.
  • Make functions more consistent (fromVector and toVector now both work on mutable stacks).
  • Sort functions.
  • Improve documentation.

0.2.0

  • Complete rewrite using mutable vectors. A monadic interface is required now, but it is much cleaner in every other sense.

0.1.1

  • Remove mean.
  • Add benchmark.
  • Many small improvements.