[Haskell-cafe] sizeOf on a type
Henning Thielemann
lemming at henning-thielemann.de
Tue Dec 22 15:55:36 EST 2009
On Fri, 18 Dec 2009, Gregory Crosswhite wrote:
> 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 do not need the Scoped Type Variables feature here, although it may
simplify writing. I remember we had a similar thread here, recently. A
solution can be:
sizeOfPtr :: Ptr a -> a -> Int
sizeOfPtr _ x = sizeOf x
to be called by (sizeOfPtr ptr undefined).
I have added this example to:
http://www.haskell.org/haskellwiki/Scoped_type_variables#Avoiding_Scoped_Type_Variables
But in order to be found in Category:FAQ we might need a different title.
More information about the Haskell-Cafe
mailing list