[Haskell-cafe] sizeOf on a type

Thomas DuBuisson thomas.dubuisson at gmail.com
Fri Dec 18 14:24:52 EST 2009


> I would like to write a routine like
>
>        nextPtr :: Storable a => Ptr a -> Ptr a
>        nextPtr = (`plusPtr` sizeOf (undefined :: a))

How about:
    getA :: Ptr a -> a
    getA _ = undefined

    nextPtr ptr = (`plusPtr` sizeOf (getA ptr)) ptr

-Thomas


More information about the Haskell-Cafe mailing list