Ptr and ForeignPtr Questions
Manuel M. T. Chakravarty
chak@cse.unsw.edu.au
Sun, 23 Sep 2001 21:02:14 +1000
Ashley Yakeley <ashley@semantic.org> wrote,
> At 2001-09-23 00:45, Manuel M. T. Chakravarty wrote:
>
> >No, unfortunately not. Consider, for example, that storage
> >qualifiers would have to be generated correctly and there is
> >no way to determine form a Haskell type whether a `const'
> >modifier needs to be added.
>
> I would assume that Ptr types would always be mapped to non-const
> pointers. Do you have an example of a Haskell type for a foreign import
> function, for which the corresponding C function type would be ambiguous?
Take, for example, the following excerpt of the Linux man
pages
STRCAT(3) Linux Programmer's Manual STRCAT(3)
NAME
strcat, strncat - concatenate two strings
SYNOPSIS
#include <string.h>
char *strcat(char *dest, const char *src);
char *strncat(char *dest, const char *src, size_t n);
If you want to bind these functions from Haskell, you have
to deal with `const' qualifiers. The same holds for many
other functions in existing C libraries.
Manuel