On Mon, Mar 12, 2012 at 6:45 AM, Simon Marlow <marlo...@gmail.com> wrote:
> But I can only pass unboxed types to foreign prim. >> >> Is this an intrinsic limitation or just an artifact of the use cases >> that have presented themselves to date? >> > > It's an intrinsic limitation - the I# box is handled entirely at the > Haskell level, primitives only deal with primitive types. > Ah. I was reasoning by comparison to atomicModifyMutVar#, which deals with unboxed polymorphic types, and even lies with a too general return type. Though the result there is returned in an unboxed tuple, the argument is passed unboxed. Is that implemented specially? But anyway, I suspect your first definition of unsafeIndex will be faster > than the one using foreign import prim, because calling out-of-line to do > the indexing is slow. Sure though, I suppose that balance of may shift as the side of the short vector grows. (e.g. with Johan it'd probably be 16 items). > Also pseq is slow - use seq instead. > Of course. I was being paranoid at the time and trying to get it to work at all. ;) what you really want is built-in support for unsafeField#, which is > certainly do-able. It's very similar to dataToTag# in the way that the > argument is required to be evaluated - this is the main > fragility, unfortunately GHC doesn't have a way to talk about things that > are unlifted (except for the primitive unlifted types). But it just about > works if you make sure there's a seq in the right place. I'd be happy even if I had to seq the argument myself before applying it, as I was trying above. -Edward
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users