
On Fri, 25 Jun 2010 18:30:06 -0300
Felipe Lessa
On Fri, Jun 25, 2010 at 12:41:48AM +0400, Alexey Khudyakov wrote:
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.
Did you see the generated core? I think you should give a try to the following simple code:
import qualified Data.Vector.Generic as VG -- vector == 0.6.*
vector2 :: Double -> Double -> Vec2D vector2 x y = Vec2D (VG.fromListN 2 [x,y])
I tryed to look at ghc core output but it was totally incomprehensible. Is there any documentation about how to inspect and interpret generated code, good practices etc?
Another question is there any specific problems with short vectors? They could be just 2 elements long. I mean performance problems
Probably there will be more overhead than defining
data Vec2D = Vec2D {-# UNPACK #-} !Double {-# UNPACK #-} !Double
You should profile to see how much difference there is between those representations.
Sure. This price of code generality.