Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-07-03 Thread Manuel M T Chakravarty
Ross Paterson <[EMAIL PROTECTED]> wrote, > On Thu, Jul 03, 2003 at 06:51:31PM +1000, Manuel M T Chakravarty wrote: > > Ross Paterson <[EMAIL PROTECTED]> wrote, > > > > > The new wording: > > > > > > \code{unsafePerformIO} may compromise typing; to avoid this, the programmer > > > should ensu

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-07-03 Thread Ross Paterson
On Thu, Jul 03, 2003 at 06:51:31PM +1000, Manuel M T Chakravarty wrote: > Ross Paterson <[EMAIL PROTECTED]> wrote, > > > The new wording: > > > > \code{unsafePerformIO} may compromise typing; to avoid this, the programmer > > should ensure that the result of \code{unsafePerformIO} has a monom

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-07-03 Thread Manuel M T Chakravarty
Ross Paterson <[EMAIL PROTECTED]> wrote, > The new wording: > > \code{unsafePerformIO} may compromise typing; to avoid this, the programmer > should ensure that the result of \code{unsafePerformIO} has a monomorphic > type. > > rules out the following: > > my_hash :: Storable a => a

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-24 Thread Ross Paterson
The new wording: \code{unsafePerformIO} may compromise typing; to avoid this, the programmer should ensure that the result of \code{unsafePerformIO} has a monomorphic type. rules out the following: my_hash :: Storable a => a -> Int my_hash a = fromIntegral $ unsafePerformIO

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-08 Thread Manuel M T Chakravarty
Malcolm Wallace <[EMAIL PROTECTED]> 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

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-05 Thread Alastair Reid
ok, I'm convinced. The semantics of empty datatypes can be a type inhabited only by bottom. Hugs implements exactly that. [Except in the special case of a few magical names (Int, Float, etc) when they occur in the Prelude (and only then). Since it is only usable in the Prelude, they can be t

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-05 Thread Manuel M T Chakravarty
"Simon Marlow" <[EMAIL PROTECTED]> 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) >

RE: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-05 Thread Simon Marlow
> > > > 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 lik

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-05 Thread Malcolm Wallace
> > Let's be clear about the role of Point here: it is a dummy type > > argument to Ptr, used to disambiguate the type 'Ptr Point' from any > > other kind of Ptr. It is for type-safety in the Haskell code. > > > > It doesn't matter how many values of the type Point there are. I could > > use an

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-05 Thread Manuel M T Chakravarty
"Simon Marlow" <[EMAIL PROTECTED]> wrote, > > We routinely use code like this: > > > > data Point > > foreign import getMousePos :: Ptr Point -> IO () > > foreign import getX :: Ptr Point -> IO Int > > foreign import getY :: Ptr Point -> IO Int > > > > The idea being that: > > > > 1) t

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-04 Thread Malcolm Wallace
> > > > * 6.2: All the types in CTypes must be newtypes that are exported > > > > abstractly. > > > > How about exporting them non-abstractly for nhc98 only, and adding a > > comment to explain why the workaround is necessary? > > That's what I prefer, too. OK, that's what I've done.

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-04 Thread Manuel M T Chakravarty
"Simon Marlow" <[EMAIL PROTECTED]> wrote, > > Manuel M T Chakravarty <[EMAIL PROTECTED]> writes: > > > > > -=- Changes since RC 9 > > > > > > * 6.2: All the types in CTypes must be newtypes that are exported > > > abstractly. > > > > This change makes things highly inconvenient in n

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-04 Thread Manuel M T Chakravarty
Ross Paterson <[EMAIL PROTECTED]> wrote, > Minor nits: there's a footnote saying "Finalizers in Haskell cannot > be savely [sic] realised without requiring support for pre-emptive > concurrency". I'd suggest dropping "pre-emptive": with cooperative > concurrency it's perfectly safe to collect the

RE: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Simon Marlow
> We routinely use code like this: > > data Point > foreign import getMousePos :: Ptr Point -> IO () > foreign import getX :: Ptr Point -> IO Int > foreign import getY :: Ptr Point -> IO Int > > The idea being that: > > 1) there is a foreign type (which might be called Point, > MousePo

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Alastair Reid
On Tuesday 03 June 2003 10:15 am, Simon Marlow wrote: > > We know that T must contain bottom. > > Not necessarily - GHC's primitive types don't contain bottom. Of course, GHC's primitive types aren't in the standard. > But I'm probably just being awkward, since I really don't understand > what i

RE: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Simon Marlow
> On Monday 02 June 2003 2:32 pm, Simon Marlow wrote: > > > Ok. But I still don't understand why the whole discussion > isn't moot. > > I can't see how to acquire a value of type T that isn't bottom. > > Whether you can acquire values of this type or not, we need > to give it a semantics.

RE: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Simon Marlow
Alastair Reid writes: > I strongly agree that we should definitely add the ability to > declare types > whose definition is provided externally. (i.e., provide the > feature that empty datatype decls currently provide.) > > Before adding them, we need to agree on the semantics and > syntax (

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Fergus Henderson
On 02-Jun-2003, Alastair Reid <[EMAIL PROTECTED]> wrote: > > > The Mercury compiler will generate appropriate glue code to marshal and > > unmarshal values of that type. > > How does it figure out what concrete type to use? Does it use trial > compilations a la autoconf? No. We don't try to s

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Alastair Reid
On Monday 02 June 2003 2:32 pm, Simon Marlow wrote: > Ok. But I still don't understand why the whole discussion isn't moot. > I can't see how to acquire a value of type T that isn't bottom. Whether you can acquire values of this type or not, we need to give it a semantics. We know that T mus

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Alastair Reid
> Using `newtype T = MkT Int8' or equivalent only works for foreign data > types whose representation is known. How do you deal with C's "time_t", > for example? Or with C "struct" types? The user doesn't want to make > non-portable assumptions about what padding the C compiler is going > to in

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Malcolm Wallace
"Simon Marlow" <[EMAIL PROTECTED]> writes: > Are you suggesting we ought to be able to define new primitive types? Sorry, yes indeed that was the suggestion. Or at least, it is not so much a suggestion, as a recognition that Hugs and nhc98 already use the 'data T' mechanism for this purpose, so

RE: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Simon Marlow
> Using `newtype T = MkT Int8' or equivalent only works for foreign data > types whose representation is known. How do you deal with > C's "time_t", > for example? Or with C "struct" types? The user doesn't want to make > non-portable assumptions about what padding the C compiler is going > t

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Fergus Henderson
On 02-Jun-2003, Simon Marlow <[EMAIL PROTECTED]> wrote: > > > On 02-Jun-2003, Simon Marlow <[EMAIL PROTECTED]> wrote: > > > > > > I can't see how to acquire a value of type T that isn't bottom. > > > > By calling a function defined using the FFI, of course. > > But the FFI lists the types tha

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Fergus Henderson
On 02-Jun-2003, Alastair Reid <[EMAIL PROTECTED]> wrote: > If all the compiler is given is: > > data T > > where T is not a builtin type, the compiler can't possible know how to > represent or marshall it. (And since we can already do that using 'newtype T > = MkT Int8' I don't think we need

RE: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Simon Marlow
> On 02-Jun-2003, Simon Marlow <[EMAIL PROTECTED]> wrote: > > > > I can't see how to acquire a value of type T that isn't bottom. > > By calling a function defined using the FFI, of course. But the FFI lists the types that may be returned by a foreign function, and T is not one of them. Are

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Fergus Henderson
On 02-Jun-2003, Simon Marlow <[EMAIL PROTECTED]> wrote: > > I can't see how to acquire a value of type T that isn't bottom. By calling a function defined using the FFI, of course. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Fergus Henderson
On 02-Jun-2003, Alastair Reid <[EMAIL PROTECTED]> wrote: > > I was just trying to show how to create a value of type > T which might be bottom. It would have been easier to use: > > t :: T > t = undefined The same issue arises for ghc's unboxed types, of course. ghc has some complic

RE: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Simon Marlow
> > I'm not following this. what exactly is derefPtr? The only > analogous > > function I can think of is Foreign.peek: > > Sorry, I meant peek. > > > but peek will unmarshal the value at the end of the Ptr into T, so T > > cannot be abstract. > > Sorry, I was just trying to show how to crea

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Alastair Reid
> I'm not following this. what exactly is derefPtr? The only analogous > function I can think of is Foreign.peek: Sorry, I meant peek. > but peek will unmarshal the value at the end of the Ptr into T, so T > cannot be abstract. Sorry, I was just trying to show how to create a value of type T w

RE: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Simon Marlow
> I don't think we have much choice about whether undefined > values are part of > the type. If you can create a value of that type: > > x <- derefPtr (px :: Ptr T) I'm not following this. what exactly is derefPtr? The only analogous function I can think of is Foreign.peek: peek :: Sto

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Alastair Reid
On Monday 02 June 2003 11:14 am, Malcolm Wallace wrote: > How about something like: > > The declaration > data T > declares an abstract datatype T, whose values and operations are > defined external to the Haskell language. Values of T follow > the semantics of the foreign language,

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Malcolm Wallace
John Meacham wrote: > > This was discussed here before and there seemed to be some support for > > it, but how about adding the empty data declaration extension to the FFI > > spec? I agree, it would be a suitable addition to the FFI, since it is the place where such types make most sense. Alas

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Marcin 'Qrczak' Kowalczyk
Dnia nie 1. czerwca 2003 23:55, Alastair Reid napisaƂ: > introduces a type T whose only value is bottom. > ]] > > This semantics is obviously flawed though because it would suggest that any > two values of type T are equal (and equal to bottom) and that optimizations > based on that equality are

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Alastair Reid
On Saturday 31 May 2003 10:11 pm, John Meacham wrote: > This was discussed here before and there seemed to be some support for > it, but how about adding the empty data declaration extension to the FFI > spec? I strongly agree that we should definitely add the ability to declare types whose defin

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-01 Thread John Meacham
This was discussed here before and there seemed to be some support for it, but how about adding the empty data declaration extension to the FFI spec? They are used quite often to represent the abstract targets of pointers as in: data Foo data Bar foreign lookupBar :: Ptr Foo -> IO (Ptr Bar) --

RE: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-05-28 Thread Simon Marlow
> Manuel M T Chakravarty <[EMAIL PROTECTED]> writes: > > > -=- Changes since RC 9 > > > > * 6.2: All the types in CTypes must be newtypes that are exported > > abstractly. > > This change makes things highly inconvenient in nhc98. A newtype > can only be passed across the FFI in n

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-05-27 Thread Malcolm Wallace
Manuel M T Chakravarty <[EMAIL PROTECTED]> writes: > -=- Changes since RC 9 > > * 6.2: All the types in CTypes must be newtypes that are exported > abstractly. This change makes things highly inconvenient in nhc98. A newtype can only be passed across the FFI in nhc98 if we have enou