haskell-cafe@haskell.org
[Top] [All Lists]

Re: [Haskell-cafe] sizeOf on a type

Subject: Re: [Haskell-cafe] sizeOf on a type
From: Gregory Crosswhite
Date: Fri, 18 Dec 2009 14:03:18 -0800
Yay, advancePtr is exactly what I needed!  I totally missed that one in the 
docs.

Also thanks to those of you who pointed me to the scoped type variables 
feature, since I had figured that a feature liked that had to exist but I just 
didn't know where to look for it.

You guys rock!

Cheers,
Greg


On Dec 18, 2009, at 12:09 PM, Patai Gergely wrote:

> Hi,
> 
>> I would like to write a routine like
>> 
>>      nextPtr :: Storable a => Ptr a -> Ptr a
>>      nextPtr = (`plusPtr` sizeOf (undefined :: a))
>> 
>> which increments a pointer by the correct amount, but
>> GHC complains that the type variable "a" is ambiguous.
> 
> Maybe Foreign.Marshal.Array.advancePtr is what you really need in this
> case.
> 
> Gergely
> 
> -- 
> http://www.fastmail.fm - The professional email service
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@xxxxxxxxxxx
> http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>