- 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 hs-source-dirs: src main-is: Main.hs default-language: Haskell2010 build-depends: base >= 4.7 && < 5 , vector
- Open src/Main.hs and start coding there. We will experiment with vector in this file:
module Main where
- Import both immutable and mutable vector modules:
import qualified Data.Vector as V import qualified Data.Vector.Mutable as MV import Data.Vector ((//),(!),(!?))
- We will use smaller functions to demonstrate the vector and its abilities.
- Construction: We can construct ...