[Haskell-cafe] getPtrSize works, but is annoying
Ugh, I figured out how to write code to do what I wanted, but it seems like an ugly solution: getPtrSize :: Ptr a - Int getPtrSize = getFrom dummy where getFrom :: a - Ptr a - Int getFrom dummy _ = sizeOf dummy Any thoughts on a less ugly solution, or is this really the best that I can do? Cheers, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] getPtrSize works, but is annoying
On Fri, Dec 18, 2009 at 12:20 PM, Gregory Crosswhite gcr...@phys.washington.edu wrote: Ugh, I figured out how to write code to do what I wanted, but it seems like an ugly solution: getPtrSize :: Ptr a - Int getPtrSize = getFrom dummy where getFrom :: a - Ptr a - Int getFrom dummy _ = sizeOf dummy With -XScopedTypeVariables: getPtrSize :: forall a. Ptr a - Int getPtrSize p = sizeOf (undefined :: a) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe