- Create a new project working-with-type-family with a simple stack template:
stack new working-with-type-family simple
- Add a dependency on vector-space library in the build-depends sub-section of executable section:
executable working-with-type-family hs-source-dirs: src main-is: Main.hs default-language: Haskell2010 build-depends: base >= 4.7 && < 5 , vector-space
- Open src/Main.hs. We will be adding our source here.
- Define the module Main, and import Data.VectorSpace:
module Main where import Data.VectorSpace
- Define vectors in three dimensions by using a tuple:
diagonal :: (Double, Double, Double) diagonal = (1, 1, 1)
xaxis :: (Double, Double, Double) xaxis = (1, 0, 0)
- Scale the diagonal vector, and take ...