In this recipe, we will look at Data.Vector from the vector package. So far, we have been extensively using lists. Though lists are ubiquitous in Haskell, they are not efficient where array-like access and operations are required. A vector supports arrays such as O(1) access to elements, as well as list-like incremental access. The vectors come in two flavors—immutable and mutable. We will look at both in this recipe.
Working with vector
How to do it...
- Create a new project working-with-vector with the simple Stack template:
stack new working-with-vector simple
- Add the dependency on the vector package in the build-depends subsection of the executable section:
executable working-with-vector ...