
Am Freitag, 13. Juli 2007 15:03 schrieb peterv:
You see, in C++ I can write:
[snip]
So basically a wrapper around a fixed-size array of any length. Implementations of (+), (-), dot, length, normalize, etc... then work on vectors of any size, without the overhead of storing the size, and with compile-time checking that only vectors of the same size can be used, etc... This also fits in nicely when creating a Matrix
class. I don't think Haskell has something like a "fixed-length array" or constant expressions that *must* be resolved at compile-time (like the N in the C++ template)? Or like Digital Mars D's "static if" statement (which is a control-flow statement that *must* succeed at compile time)?
You may be interested in http://okmij.org/ftp/Haskell/number-parameterized-types.html http://okmij.org/ftp/Haskell/types.html#branding HTH, Lukas