vec: Vec: length-indexed (sized) list

[ bsd3, data, dependent-types, library ] [ Propose Tags ]

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:

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

Versions [RSS] [faq] 0, 0.1, 0.1.1,, 0.2, 0.3, 0.4, 0.4.1
Change log
Dependencies adjunctions (==4.4.*), base (>=4.7 && <4.17), boring (==0.2.*), deepseq (>= && <1.5), distributive (>=0.5.3 && <0.7), fin (>=0.2.1 && <0.3), hashable (>= && <1.5), indexed-traversable (>=0.1.1 && <0.2), QuickCheck (>=2.14.2 && <2.15), semigroupoids (>=5.3.5 && <5.4), semigroups (>=0.18.4 && <0.21), transformers (>= && <0.7), transformers-compat (>=0.6.5 && <0.7 || >=0.7.1 && <0.8) [details]
License BSD-3-Clause
Copyright (c) 2017-2021 Oleg Grenrus
Author Oleg Grenrus <>
Maintainer Oleg.Grenrus <>
Category Data, Dependent Types
Home page
Bug tracker
Source repo head: git clone
Uploaded by phadej at 2022-01-03T12:41:34Z
Distributions Arch:0.4, LTSHaskell:0.4, NixOS:0.4, Stackage:0.4.1
Downloads 4416 total (61 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2022-01-03 [all 1 reports]


[Index] [Quick Jump]

Manual Flags


Depend on adjunctions to provide its instances


Depend on distributive to provide its instances. Turning on, disables adjunctions too.


Depend on semigroupoids to provide its instances, and traverse1.

Automatic Flags

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

For package maintainers and hackage trustees