[Haskell-cafe] Construction of short vectors

Alexey Khudyakov alexey.skladnoy at gmail.com
Thu Jun 24 16:41:48 EDT 2010

Hello, cafe

I have question about vector package.

Currently I'm playing with data types which are isomorphic to vectors of fixed
length. Think about vector in N-dimensional space, list of parameters to
function R^n → R, set of measurements with uncertainties, etc. They have
different semantics but exactly the same representation and it's often
advantageous to think about them as N-dimensional vectors.

Then constructor like one below arise naturally. And I don't know how to write
them properly. It's possible to use fromList but then list could be allocated
which is obviously wasteful.

> vector2 :: Double -> Double -> Vec2D
> vector2 x y = ...
> -- Vec2D is some wrapper around Vector data type

Another question is there any specific problems with short vectors? They could
be just 2 elements long. I mean performance problems

More information about the Haskell-Cafe mailing list