Matrix -> Haskell: created types for the algorithm