Questions regarding uvector

Tyson Whitehead twhitehead at
Mon Jan 19 00:00:00 EST 2009

I've been looking at uvector and had some questions (hopefully this is the 
right mailing list for this, if not, sorry, and please direct me properly).

First, is there any design thing deeper than just supporting things like the 
unit and pair arrays for layering UArr on top of the underlying BUArr?

Second, the STG code and the native and via-C assembler generated by ghc 6.8.2 
with -O2 for

test :: UArr Int -> Int -> Int
test = indexU


indexU :: UA e => UArr e -> Int -> e
indexU arr n = indexS (streamU arr) n

is a loop that simultaneously increments the offset while decrementing the 
index until it reaches the desired position.

If I understand correctly, this indexU definition was used instead of just 
bring indexU from UArr into scope in order to cancel any possible unstreamU in 
arr, and this is a big part of the whole streamU/unstreamU magic.  It replaces 
what would other require N^2 rules to avoid a bunch of temporaries with one.

I wonder if a rule code be added to change any outstanding "indexS (streamU 
arr) n" into an UArr indexU after streamU/unstreamU fusion?  Such rules for 
each of these type of functions (i.e., ones that aren't of the form "= 
unstreamU . ...") would also not be N^2 and would eliminate temporary streams.

Thanks!  -Tyson

PS:  Nice code by the way.  : )

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url :

More information about the Glasgow-haskell-users mailing list