Malcolm Wallace <Malcolm.Wallace@cs.york.ac.uk> wrote,
data Point foreign import getMousePos :: Ptr Point -> IO () foreign import getX :: Ptr Point -> IO Int foreign import getY :: Ptr Point -> IO Int
vs
data Point = Point (Ptr Point) foreign import getMousePos :: Point -> IO ()
I like the second idiom. You are right that there is no need for the application programmer to know whether pointers are involved, because even in the first style, it is not possible to 'peek' inside a Ptr Point to get the `actual' Point value. So why not hide the pointer altogether? Yes.
From this, I infer that there is no dire need for empty data types in conjunction with the FFI. Consequently, I suggest that we do not include empty data types into the FFI spec (especially because the spec otherwise refrains from extending the base language in any way other than by foreign declarations).
Cheers, Manuel