Tridiagonal matrix algorithm implementation in Haskell