Re: [Haskell-cafe] FFI woes!

2004-12-18 Thread Robert Dockins
> Well that shouldn't affect the functionality. The weak pointer was > only a way of attatching a finalizer to the Playback object. It is > true that I should probably wrap up the the SoundPlaybackRaw inside > the SoundPlayback as well, to save CPU, but it shouldn't matter for > the core functiona

Re: [Haskell-cafe] safe code to run in finalizers: ACIO revisited

2004-12-18 Thread Robert Dockins
On Sat, 2004-12-18 at 21:19 +0100, Marcin 'Qrczak' Kowalczyk wrote: > Robert Dockins <[EMAIL PROTECTED]> writes: > > > So, to be safe, the action of a finalizer must commute with every > > other finalizer (they must be central). > > What does "should" mean? I am suggesting that being "affine ce

Re: [Haskell-cafe] safe code to run in finalizers: ACIO revisited

2004-12-18 Thread Marcin 'Qrczak' Kowalczyk
Robert Dockins <[EMAIL PROTECTED]> writes: > So, to be safe, the action of a finalizer must commute with every > other finalizer (they must be central). What does "should" mean? There are useful finalizers which don't have this property. E.g. a finalizer can remove an entry from a weak dictionary

[Haskell-cafe] safe code to run in finalizers: ACIO revisited

2004-12-18 Thread Robert Dockins
Due to one of the threads on cafe recently, I have been doing some thinking about finalizers. There is this sort of intuitive notion that some things shouldn't be done inside finalizers. For example, no output should be produced, because the output handles may have been finalized already, and fin

Re: [Haskell-cafe] Why no IO transformer monad?

2004-12-18 Thread Keean Schupke
As far as I understand it IO is a special case of a state monad (where the state is the "World". If this is the case and there is a state-transformer (StateT) then it should be possible to write an IO transformer. Unfortunately I also think because of some magic in the ST and IO monads, you canno

[Haskell-cafe] Why no IO transformer monad?

2004-12-18 Thread Henning Sato von Rosen
Hi all! For each basic monad there seems to be a corresponding transformer, e.g. 'StateT' for 'State' and so on. I guess the reason lies in the fact that if there were an IO Transformer monad, one might run it and get the 'Universe' out of the IO monad. But, I am working on understanding IO mag

Re: [Haskell-cafe] FFI woes!

2004-12-18 Thread Sebastian Sylvan
On Sat, 18 Dec 2004 10:33:25 +, Keean Schupke <[EMAIL PROTECTED]> wrote: > I still think you need to use a StablePtr, so the sample will not get > garbage collected. > > You then need to free the sample explicitly when playback has finished... > > Ideally you want to add a callback to do the

Re: [Haskell-cafe] FFI woes!

2004-12-18 Thread Keean Schupke
I still think you need to use a StablePtr, so the sample will not get garbage collected. You then need to free the sample explicitly when playback has finished... Ideally you want to add a callback to do the free-ing. In my opinion if the library you are using does not provide this callback then th

Re: [Haskell-cafe] FFI woes!

2004-12-18 Thread Sebastian Sylvan
On Sat, 18 Dec 2004 09:07:12 +, Keean Schupke <[EMAIL PROTECTED]> wrote: > Sebastian Sylvan wrote: > > >What do you mean? > >Yes the sample is copied to memory when loaded, but I still have to > >"worry" because if it's garbage colleced (ie, a "free" call is called > >on it) then the sound can

Re: [Haskell-cafe] FFI woes!

2004-12-18 Thread Sebastian Sylvan
On Thu, 16 Dec 2004 11:08:13 -0500, Robert Dockins <[EMAIL PROTECTED]> wrote: > > -- play a sample > > samplePlay :: SoundSample -> IO SamplePlayback > > samplePlay sample = do ch <- withForeignPtr sample (fsound_PlaySound (-1)) > > let spb = SP ch sample -- SamplePlaybackRaw

Re: [Haskell-cafe] FFI woes!

2004-12-18 Thread Keean Schupke
Sebastian Sylvan wrote: What do you mean? Yes the sample is copied to memory when loaded, but I still have to "worry" because if it's garbage colleced (ie, a "free" call is called on it) then the sound can not be played anymore (because the data is gone). I mean the sound card has its own, indep