I dont see how to fix this.
There was a thread about statically knowing lots about the shape of matrices using the type system. http://www.haskell.org/pipermail/haskell/2006-April/017845.html I believe they incorporated this (variable size identity matrix, for example) in their approach. (They don't preserve your property of being able to do things with simple list syntax, like [[1,2],[3,4]] * [[5,6],[7,8]] , instead you have to use Template Haskell and some small contructor functions)
Could be better to forget about fromInteger...
Except then you wouldn't have a full instance for Num. How about constructing an infite list of infinite lists of that number: fromInteger x = map repeat (repeat (fromInteger x)) when it gets zipped with smaller matrices, will it terminate? It works with addition but multiplying caused problems: [[1,2],[3,4]] + 10 = [[11,12],[13,14]] [[1,2],[3,4]] * 10 = [[40,60],[40,60],[40,60],[40,60],[40,60], ..... Hmm... Jared.
Atila Jared Updike wrote: >> fromInteger x = [[fromInteger x]] > > Wouldn't you want the expression > > [[1,0],[0,2]] + 10 > > to yield > > [[11,10],[10,12]] > > instead of [[11]] ? I guess you would need some complicated machinery > so this is one thing you have to ignore to keep your otherwise nifty > instance nice and simple. > > Jared.
-- http://www.updike.org/~jared/ reverse ")-:" _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
