index*OffAddr
Simon Marlow
marlowsd at gmail.com
Fri Apr 23 08:22:59 EDT 2010
On 21/04/2010 09:45, Roman Leshchinskiy wrote:
> After thinking about this for a while, I came up with two possible solutions. One is to provide a "pure" version of touch#:
>
> use# :: o -> o' -> o'
>
> such that use# x y = y. This would change the code above to:
>
> I# (use# arr# (indexIntOffAddr# addr# i#))
>
> I don't know how to implement this, though, because use# would have to be able to return arbitrary (unboxed) types and the code generator doesn't really seem to support this.
>
> A perhaps simpler solution is to add a new set of primitives:
>
> indexIntOffAddrUsing# :: o -> Addr# -> Int# -> Int#
> ...
>
> These would take an additional argument which they'd touch and otherwise ignore. The code would then become:
>
> I# (indexIntOffAddrUsing# arr# addr# i#)
Seems like the way to go, I can't think of a better alternative.
> Incidentally, the index*OffAddr# primitives don't seem to be used anywhere.
There are a handful of uses in libraries/base, mainly GHC.Base.
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list