{-# LANGUAGE MagicHash,UnboxedTuples #-} module Size where import GHC.Exts import Foreign unsafeSizeof :: a -> Int unsafeSizeof a = case unpackClosure# a of (# x, ptrs, nptrs #) -> sizeOf (undefined::Int) + -- one word for the header I# (sizeofByteArray# (unsafeCoerce# ptrs) +# sizeofByteArray# nptrs)