[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] sizeOf on a type

Subject: Re: [Haskell-cafe] sizeOf on a type
From: Thomas DuBuisson
Date: Fri, 18 Dec 2009 11:24:52 -0800
> 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
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

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