m//[((i,i), 0) | i <- [1..n]]is the same matrix, except with the diagonal zeroed. Repeated indices in the association list are handled as for array: Haskell 2010 specifies that the resulting array is undefined (i.e. bottom), but GHC's implementation uses the last association for each index.