https://github.com/parsaalizadeh/fenwick-tree
Implementation of mutable Fenwick trees as a Haskell library
https://github.com/parsaalizadeh/fenwick-tree
data-structures fenwick-tree haskell
Last synced: 5 months ago
JSON representation
Implementation of mutable Fenwick trees as a Haskell library
- Host: GitHub
- URL: https://github.com/parsaalizadeh/fenwick-tree
- Owner: ParsaAlizadeh
- License: mit
- Created: 2025-04-07T17:00:43.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-28T14:29:33.000Z (about 1 year ago)
- Last Synced: 2025-06-19T01:03:42.101Z (12 months ago)
- Topics: data-structures, fenwick-tree, haskell
- Language: Haskell
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# mutable-fenwick
[](https://hackage.haskell.org/package/mutable-fenwick-0.1.1.0)
This package provides an implementation of mutable
[Fenwick trees](https://en.wikipedia.org/wiki/Fenwick_tree) in Haskell.
## Features
It is maximally generic. Each operation of Fenwick tree is implemented using a subset of constraints
from `Semigroup`, `Monoid`, or `Commutative`, chosen carefully based on the nature of each
operation. This is mostly possible due to how Haskell typeclasses work, and provides different
functionality based on the constraints provided by the underlying element type.
It is fast and efficient. Every operation is marked as inline, meaning that they will be optimized
for the given element type. With `ArrayC` and `VectorC` from this package, it is possible to use
unboxed arrays and vectors for newtypes that implement a custom algebra (e.g. `Sum`, `Product` or
`Xor`). An implementation using this library can be as fast as a C/C++ implementation.
It is the only Haskell library (I believe, as of this date) that provides Fenwick trees.
- The [FenwickTree](https://hackage.haskell.org/package/FenwickTree) package is more similar to a
Segment tree, and it does not have a generic interface for the data structure.
- The [binary-indexed-tree](https://hackage.haskell.org/package/binary-indexed-tree) package
has an interface for ST monad, but the implementation is only limited to `Sum` monoid.