Haskell Language Vectors


It [Data.Vector] has an emphasis on very high performance through loop fusion, whilst retaining a rich interface. The main data types are boxed and unboxed arrays, and arrays may be immutable (pure), or mutable. Arrays may hold Storable elements, suitable for passing to and from C, and you can convert between the array types. Arrays are indexed by non-negative Int values.

The Haskell Wiki has these recommendations:

In general:

  • End users should use Data.Vector.Unboxed for most cases
  • If you need to store more complex structures, use Data.Vector
  • If you need to pass to C, use Data.Vector.Storable

For library writers;

  • Use the generic interface, to ensure your library is maximally flexible: Data.Vector.Generic