twhitehead:
> On Thursday 16 October 2008 07:03:05 Roman Leshchinskiy wrote:
> > On 16/10/2008, at 21:34, Simon Peyton-Jones wrote:
> > > BUT people who care probably UNPACK their strict fields too, which
> > > is even better.  The time you can't do that is for sum types
> > >        data T = MkT ![Int]
> >
> > You also can't do it for polymorphic components. I've used code like:
> >
> >    data T a = MkT !a
> >
> >    foo :: T (a,b) -> a
> >    foo (MkT (x,y)) = x
> >
> > Here, unpacking doesn't work but foo could still access the components
> > of the pair directly.
> 
> This is actually the situation I was originally looking at.  I just 
> simplified 
> it for the sake of posting readable core and assembler.
> 
> 
> Specifically, I was looking at some of the assembler GHC was generating for 
> some array code to see if it could do a clean enough job to be used instead 
> of 
> C, and was finding this sort of thing because STUArrau is defined as
> 
> data STUArray s i a = STUArray !i !i !Int (MutableByteArray# s)

FWIW, I get much nicer code with uvector (which uses type families
to select monomorphic instances of things, and aggressive inlining, to
yield much better code in practice). The DPH arrays library uses
a similar method.

So you might make some progress by taking that direction.

-- Don
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to