vec: Vec: length-indexed (sized) list
This package provides length-indexed (sized) lists, also known as vectors.
data Vec n a where
VNil :: Vec 'Nat.Z a
(:::) :: a -> Vec n a -> Vec ('Nat.S n) a
The functions are implemented in four flavours:
naive: with explicit recursion. It's simple, constraint-less, yet slow.
pull: using
Fin n -> arepresentation, which fuses well, but makes some programs hard to write. Anddata-family: which allows lazy pattern matching
inline: which exploits how GHC dictionary inlining works, unrolling recursion if the size of
Vecis known statically.
As best approach depends on the application, vec doesn't do any magic
transformation. Benchmark your code.
This package uses fin, i.e. not GHC.TypeLits, for indexes.
For lens or optics support see vec-lens and vec-optics packages respectively.
See Hasochism: the pleasure and pain of dependently typed haskell programming by Sam Lindley and Conor McBride for answers to how and why. Read APLicative Programming with Naperian Functors by Jeremy Gibbons for (not so) different ones.
Similar packages
linear has
Vtype, which usesVectorfromvectorpackage as backing store.Vecis a real GADT, but tries to provide as many useful instances (uptolens).vector-sized Great package using
GHC.TypeLits. Current version (0.6.1.0) usesfinite-typelitsandIntindexes.sized-vector depends on
singletonspackage.vecisn't light on dependencies either, but try to provide wide GHC support.sized also depends on a
singletonspackage. TheSized f n atype is generalisation oflinear'sVfor anyListLike.clash-prelude is a kitchen sink package, which has
CLaSH.Sized.Vectormodule. Also depends onsingletons.
Modules
[Index] [Quick Jump]
Flags
Manual Flags
| Name | Description | Default |
|---|---|---|
| adjunctions | Depend on | Enabled |
| distributive | Depend on | Enabled |
| semigroupoids | Depend on | Enabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- vec-0.5.1.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)
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
For package maintainers and hackage trustees
Candidates
| Versions [RSS] | 0, 0.1, 0.1.1, 0.1.1.1, 0.2, 0.3, 0.4, 0.4.1, 0.5, 0.5.1 |
|---|---|
| Change log | ChangeLog.md |
| Dependencies | adjunctions (>=4.4.2 && <4.5), base (>=4.12.0.0 && <4.22), boring (>=0.2.2 && <0.3), deepseq (>=1.4.4.0 && <1.6), distributive (>=0.6.2 && <0.7), fin (>=0.3.1 && <0.4), hashable (>=1.4.4.0 && <1.5 || >=1.5.0.0 && <1.6), indexed-traversable (>=0.1.4 && <0.2), QuickCheck (>=2.14.2 && <2.15 || >=2.15.0.1 && <2.16), semigroupoids (>=6.0.1 && <6.1), transformers (>=0.5.6.2 && <0.7) [details] |
| Tested with | ghc ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.4 || ==9.10.1 || ==9.12.2 |
| License | BSD-3-Clause |
| Copyright | (c) 2017-2021 Oleg Grenrus |
| Author | Oleg Grenrus <oleg.grenrus@iki.fi> |
| Maintainer | Oleg.Grenrus <oleg.grenrus@iki.fi> |
| Revised | Revision 2 made by phadej at 2025-05-02T14:19:02Z |
| Category | Data, Dependent Types |
| Home page | https://github.com/phadej/vec |
| Bug tracker | https://github.com/phadej/vec/issues |
| Source repo | head: git clone https://github.com/phadej/vec.git(vec) |
| Uploaded | by phadej at 2024-06-08T14:36:15Z |
| Distributions | Arch:0.5.1, LTSHaskell:0.5.1, NixOS:0.5.1 |
| Reverse Dependencies | 7 direct, 8456 indirect [details] |
| Downloads | 6403 total (26 in the last 30 days) |
| Rating | (no votes yet) [estimated by Bayesian average] |
| Your Rating | |
| Status | Docs uploaded by user Build status unknown [no reports yet] |