▲ | cosmic_quanta 5 days ago | ||||||||||||||||
That's a great question. Haskell has arrays and matrices of homogeneous types, so it wouldn't work by default. If you needed this kind of functionality, you would have to create your own Matrix type which would look very similar to a 9-tuple, and then define matrix multiplication. It would then be possible to encode the dimensional constraints in the type signature, but it's already quite involved for 2x2 matrices:
I can't imagine for 3x3. | |||||||||||||||||
▲ | simiones 5 days ago | parent [-] | ||||||||||||||||
Thanks for the sample! I was asking because it seems to me this is always an interesting example of a very common and very well defined formal operation where nevertheless type systems are extremely cumbersome to use, but I'm always curious if there is some solution that I'm missing. I wonder if there is any plausible approach that would work closer to how units are treated in physics calculations - not as types, but as special numerical values, more or less (values that you can multiply/divide by any other unit, but can only add/subtract with themselves). | |||||||||||||||||
|