- 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:
build-depends: base >= 4.7 && < 5
- 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 ...
Get Haskell Cookbook now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.