
25 Sep
2012
25 Sep
'12
4:49 a.m.
That's part of a problem. There are really two aspects to it. Firstly, a naive list-based implementation would be a loop. But when I write ([x,y] :: Vector Double) somewhere in an inner loop in my program, I *really* don't want a loop with two iterations at runtime - I want just an allocation and two writes. I suppose this could be solved by doing something like this:
Some time ago I played with function fromList and rewrite rules. For statically known lists it's possible to rewrite fromList [a,b,c] → cons a $ cons b $ cons c $ empty Latter is compiled down to single allocation and three writes.