[Haskell-cafe] sizeOf on a type

Patai Gergely patai_gergely at fastmail.fm
Fri Dec 18 15:09:30 EST 2009


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



More information about the Haskell-Cafe mailing list