[Haskell-cafe] Poisx select support

2008-01-16 Thread Galchin Vasili
Hello,

   In the ghc libraries directory I can't find the Haskell .hs/.lhsthat
implements Posix select. ?? I found Select.c.

Regards, Vasili
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poisx select support

2008-01-16 Thread Don Stewart
vigalchin:
Hello,

   In the ghc libraries directory I can't find the Haskell
.hs/.lhsthat implements Posix select. ?? I found Select.c.

In Control.Concurrent

forkIO
threadDelay
threadWaitRead
threadWaitWrite

The thread primitives are implemented in terms of select, and give you a
cleaner interface.

Also, with Control.Concurrent.STM.

atomically
orElse
retry

You can have threads wait on one of a series of alternative events.
Using STM, you'll be able to compose blocks of such code, which you 
can't do with select.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poisx select support

2008-01-16 Thread Galchin Vasili
Hi Don,

 Sorry ..I  wasn't clear enough.I am trying to determine from the
Haskell FFI doc what datatype to use in order to model C's void *, e.g.
for mmap http://www.opengroup.org/onlinepubs/95399/functions/mmap.html

Regards, Vasili



On 1/16/08, Don Stewart [EMAIL PROTECTED] wrote:

 vigalchin:
 Hello,
 
In the ghc libraries directory I can't find the Haskell
 .hs/.lhsthat implements Posix select. ?? I found Select.c.

 In Control.Concurrent

forkIO
threadDelay
threadWaitRead
threadWaitWrite

 The thread primitives are implemented in terms of select, and give you a
 cleaner interface.

 Also, with Control.Concurrent.STM.

atomically
orElse
retry

 You can have threads wait on one of a series of alternative events.
 Using STM, you'll be able to compose blocks of such code, which you
 can't do with select.

 -- Don

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poisx select support

2008-01-16 Thread Don Stewart
vigalchin:
Hi Don,

 Sorry ..I  wasn't clear enough.I am trying to determine from the
Haskell FFI doc what datatype to use in order to model C's void *, e.g.
for mmap
[1]http://www.opengroup.org/onlinepubs/95399/functions/mmap.html

Regards, Vasili

In the System.IO.Posix.MMap module, mmap is imported as:

foreign import ccall unsafe hs_bytestring_mmap.h hs_bytestring_mmap
c_mmap   :: CSize - CInt - IO (Ptr Word8)

foreign import ccall unsafe hs_bytestring_mmap.h munmap
c_munmap :: Ptr Word8 - CSize - IO CInt
 
You can see the full binding to mmap here:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-mmap

Cheers,
  Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poisx select support

2008-01-16 Thread Galchin Vasili
Hi Don,

 I am looking at the code for ghc-6.8.2 but don't see the mmap support.
Is this newly wriiten by you? I would also like to help round out the Posix
functionality in Haskell. Is there an accurate list of what needs to be done
given the fact that maybe some work is in progress but not checked in?

Thank you, Vasili


On 1/16/08, Don Stewart [EMAIL PROTECTED] wrote:

 vigalchin:
 Hi Don,
 
  Sorry ..I  wasn't clear enough.I am trying to determine from the
 Haskell FFI doc what datatype to use in order to model C's void *,
 e.g.
 for mmap
 [1]http://www.opengroup.org/onlinepubs/95399/functions/mmap.html
 
 Regards, Vasili

 In the System.IO.Posix.MMap module, mmap is imported as:

foreign import ccall unsafe hs_bytestring_mmap.h hs_bytestring_mmap
c_mmap   :: CSize - CInt - IO (Ptr Word8)

foreign import ccall unsafe hs_bytestring_mmap.h munmap
c_munmap :: Ptr Word8 - CSize - IO CInt

 You can see the full binding to mmap here:


 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-mmap

 Cheers,
 Don

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poisx select support

2008-01-16 Thread Don Stewart
vigalchin:
Hi Don,

 I am looking at the code for ghc-6.8.2 but don't see the mmap
support. Is this newly wriiten by you? I would also like to help round out
the Posix functionality in Haskell. Is there an accurate list of what
needs to be done given the fact that maybe some work is in progress but
not checked in?

Thank you, Vasili

Code isn't generally checked into ghc 6.8.2, or the base libraries.
Instead, new projects are distributed via hackage.haskell.org.  It is
like CPAN for Haskell, if you're familiar with CPAN.

The mmap bytestring package is available there, for example. 

For improving POSIX support in general, careful patches to the 'unix'
library would be the best way:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/unix

If something you need is missing from there, write it as a patch against 
the darcs repository for `unix',
http://darcs.haskell.org/packages/unix/, and submit it to
[EMAIL PROTECTED] for inclusion in the next release of that library.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poisx select support

2008-01-16 Thread Ian Lynagh
On Wed, Jan 16, 2008 at 12:40:22PM -0800, Donald Bruce Stewart wrote:
 
 If something you need is missing from there, write it as a patch against 
 the darcs repository for `unix',
 http://darcs.haskell.org/packages/unix/, and submit it to
 [EMAIL PROTECTED] for inclusion in the next release of that library.

Please note that patches for the unix library should follow the library
submissions process:

http://www.haskell.org/haskellwiki/Library_submissions


Thanks
Ian

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poisx select support

2008-01-16 Thread Spencer Janssen
On Wed, Jan 16, 2008 at 02:09:31PM -0600, Galchin Vasili wrote:
 Hi Don,
 
  Sorry ..I  wasn't clear enough.I am trying to determine from the
 Haskell FFI doc what datatype to use in order to model C's void *, e.g.
 for mmap http://www.opengroup.org/onlinepubs/95399/functions/mmap.html
 
 Regards, Vasili

For C's void *, I'd use Ptr ().


Cheers,
Spencer Janssen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Poisx select support

2008-01-16 Thread Bryan O'Sullivan
Spencer Janssen wrote:

 For C's void *, I'd use Ptr ().

Ptr a seems to be more usual, and hews closer to the idea that it's a
pointer to an opaque value.

b
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe