vector-sized: Size tagged vectors

[ bsd3, data, library ] [ Propose Tags ]

Please see

[Skip to Readme]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,,,,,,,,,,,,,,,,,,, 1.4.2, 1.4.3,, 1.4.4, 1.5.0 (info)
Change log
Dependencies adjunctions (>=4.3 && <4.5), base (>=4.9 && <5), binary (>=, comonad (>=4 && <6), deepseq (>=1.1 && <1.5), distributive (>=0.5 && <0.7), finite-typelits (>=0.1), hashable (>=, indexed-list-literals (>=, primitive (>=0.5 && <0.8), vector (>=0.11 && <0.14) [details]
License BSD-3-Clause
Copyright 2016 Joe Hermaszewski
Author Joe Hermaszewski
Revised Revision 1 made by Bodigrim at 2022-12-30T20:09:34Z
Category Data
Home page
Bug tracker
Source repo head: git clone
Uploaded by jophish at 2021-08-26T05:18:30Z
Distributions Arch:1.5.0, LTSHaskell:1.5.0, NixOS:1.5.0
Reverse Dependencies 26 direct, 54 indirect [details]
Downloads 22667 total (135 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for vector-sized-1.5.0

[back to package description]

vector-sized Hackage

This package exports a newtype tagging the vectors from the vector package with a type-level natural representing their size. It also exports functions from vector whose size can be determined ahead of time, appropriately retyped.

Currently, we provide size-tagged versions of the following:

We also provide mutable versions of each of the above. Additionally, we include functions for converting to and from 'unsized' vectors and lists, using CPS-style existentials.

The code in this package is based on the initial work by Ben Gamari in a PR for vulkan.

How is this different to fixed-vector?

This package is fairly similar to fixed-vector, as both libraries are designed to provide vectors of statically known length. However, the implementations used are different, with different tradeoffs. vector-sized uses a newtype wrapper around vectors from vector, and is thus able to handle vectors of arbitrary length. However, this approach requires us to carry a runtime representation of length, which is a significant memory overhead for small vectors. fixed-vector instead defines all functions as manipulations of Church-encoded product types of the form ∀r. (a → a → r) → r (for 2D vectors), allowing it to work for both arbitrary product types (like data V2 a = V2 a a) and opaque length-parameterized vectors. However, as a consequence of this implementation choice, fixed-vector cannot handle vectors whose size exceeds tens of elements.