@hackage vec0.5.1
Vec: length-indexed (sized) list
Installation
Tested Compilers
Dependencies (11)
- QuickCheck ^>=2.14.2 || ^>=2.15.0.1
- adjunctions ^>=4.4.2
- base >=4.12.0.0 && <4.22
- boring ^>=0.2.2
- deepseq >=1.4.4.0 && <1.6
- distributive ^>=0.6.2 Show all…
Dependents (8)
@hackage/vec-optics, @hackage/testing-tensor, @hackage/sdl3-bindgen-sys, @hackage/overloaded, @hackage/rebound, @hackage/vec-lens, Show all…
Package Flags
adjunctions
(on by default)
Depend on adjunctions to provide its instances
distributive
(on by default)
Depend on distributive to provide its instances. Turning on, disables adjunctions too.
semigroupoids
(on by default)
Depend on semigroupoids to provide its instances, and traverse1.
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.