Added typesafe indexing to matrices.
Broken Mat.hs because of genSingletons TH.