Here's a simple function to return pointer alignment:
{-
But I get the following error:
Could not deduce (Storable a0) arising from a use of `alignment' from the context (Storable a) bound by the type signature for ptrAlign1 :: Storable a => Ptr a -> Int at prog.hs:8:14-41 The type variable `a0' is ambiguous
If I rewrite ptrAlign in a ptrAlign fraction, for example:
ptrAlign2 :: (Storable a) => Ptr a -> Int ptrAlign2 = ptrAlign3 undefined where ptrAlign3 :: (Storable a) => a -> Ptr a -> Int ptrAlign3 x _ = alignment x
It works great (of course, this version doesn't even need ScopedTypeVariables ).
But I'm still wondering why the first version is causing an error and what can be done to solve it?
haskell ghc type-variables
Clinton
source share