Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Ashley Yakeley
At 2001-09-23 23:12, Manuel M. T. Chakravarty wrote: >> I was just hoping for GHC to be able to spit out headers for 'foreign >> import' functions that the user could then define. This merely means a >> map from some restricted set of Haskell function types to C types. > >Functionality like tha

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Manuel M. T. Chakravarty
Ashley Yakeley <[EMAIL PROTECTED]> wrote, > At 2001-09-23 19:14, Manuel M. T. Chakravarty wrote: > > >Hmm, we must be misunderstanding each other. Given that you > >have > > > > foreign import strcat :: Ptr CChar -> Ptr CChar -> IO (Ptr CChar) > > > >How do you want to know whether the C proto

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Ashley Yakeley
At 2001-09-23 19:14, Manuel M. T. Chakravarty wrote: >Hmm, we must be misunderstanding each other. Given that you >have > > foreign import strcat :: Ptr CChar -> Ptr CChar -> IO (Ptr CChar) > >How do you want to know whether the C prototype is > > char *strcat(char *dest, const char *src)

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Manuel M. T. Chakravarty
Ashley Yakeley <[EMAIL PROTECTED]> wrote, > At 2001-09-23 04:04, Marcin 'Qrczak' Kowalczyk wrote: > > >It would be impossible then to directly call a C function with a > >parameter declared as a const pointer. It's illegal in C to have > >mismatching prototypes of the same function. > > You can

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Manuel M. T. Chakravarty
Ashley Yakeley <[EMAIL PROTECTED]> wrote, > At 2001-09-23 04:02, Manuel M. T. Chakravarty wrote: > > >> 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 fu

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Ashley Yakeley
At 2001-09-23 15:56, Marcin 'Qrczak' Kowalczyk wrote: >> But do you have an example of a Haskell type for a foreign import >> function, for which the corresponding C function type would be ambiguous? > >Ptr CChar (as an argument). It could be either char * or const char *. It's always char*. A

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Ashley Yakeley
At 2001-09-23 04:04, Marcin 'Qrczak' Kowalczyk wrote: >It would be impossible then to directly call a C function with a >parameter declared as a const pointer. It's illegal in C to have >mismatching prototypes of the same function. You can always do this: module MyModule where { f

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Marcin 'Qrczak' Kowalczyk
Sun, 23 Sep 2001 15:41:41 -0700, Ashley Yakeley <[EMAIL PROTECTED]> pisze: > But do you have an example of a Haskell type for a foreign import > function, for which the corresponding C function type would be ambiguous? Ptr CChar (as an argument). It could be either char * or const char *. --

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Ashley Yakeley
At 2001-09-23 04:02, Manuel M. T. Chakravarty wrote: >> 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,

Re: Alternative Design for Finalisation

2001-09-23 Thread Reuben Thomas
> >I guess 's' is British and 'z' is American. > > Chambers (of Cambridge, England) has both. "z" used to be the British English standard. It is still preferred by the Oxford English Dictionary, and consequently, the Oxford Universtiy Press. The rationale is that "z" is the most sensible transcri

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Marcin 'Qrczak' Kowalczyk
Sun, 23 Sep 2001 02:04:49 -0700, Ashley Yakeley <[EMAIL PROTECTED]> pisze: > I would assume that Ptr types would always be mapped to non-const > pointers. It would be impossible then to directly call a C function with a parameter declared as a const pointer. It's illegal in C to have mismatchin

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Manuel M. T. Chakravarty
Ashley Yakeley <[EMAIL PROTECTED]> 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' > >modifi

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Ashley Yakeley
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 wo

Re: Ptr and ForeignPtr Questions

2001-09-23 Thread Manuel M. T. Chakravarty
Ashley Yakeley <[EMAIL PROTECTED]> wrote, > At 2001-09-21 02:20, Manuel M. T. Chakravarty wrote: > > >One could attempt to generate C prototypes from the Haskell > >type declarations or similar things, btu it doesn't work > >out. > > Why not? Isn't there a straightforward type map? No, unfortu