[Haskell-cafe] sizeOf on a type

Gregory Crosswhite gcross at phys.washington.edu
Fri Dec 18 17:03:18 EST 2009

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!


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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list