[email protected]
[Top] [All Lists]

[Haskell-cafe] sizeOf on a type

Subject: [Haskell-cafe] sizeOf on a type
From: Gregory Crosswhite
Date: Fri, 18 Dec 2009 11:16:42 -0800
Hey everyone,

I would like to write a routine like

        nextPtr :: Storable a => Ptr a -> Ptr a
        nextPtr = (`plusPtr` sizeOf (undefined :: a))

which increments a pointer by the correct amount, but GHC complains that the 
type variable "a" is ambiguous.  I can see what's going on:  it can't tell that 
the "a" I am writing there is the same "a" that's in the type specification, 
but is there any way that I can make it identify "a" with the "a" in the 
specification for nextPtr?

Cheers,
Greg

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

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