Re: [Haskell-cafe] carry state around ....

2008-07-29 Thread Ketil Malde
Galchin, Vasili [EMAIL PROTECTED] writes: ok guys .. what is this phantom type concept? Is it a type theory thing or just Haskell type concept? Here's another example. Say you want to use bytestrings with different encodings. You obviously don't want to concatenate a string representing

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Brandon S. Allbery KF8NH
On 2008 Jul 28, at 1:54, Galchin, Vasili wrote: allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb - do poke p_aiocb aiocb As I understand it, you can't do this;you must use the same aiocb throughout (that is, the same chunk of memory, not merely the same values; there is

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Galchin, Vasili
Hi Brandon, So even if I go to ForeignPtr is a problem? And/Or is this a by reference vs by value issue? Kind regards, Vasili On Mon, Jul 28, 2008 at 1:09 AM, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: On 2008 Jul 28, at 1:54, Galchin, Vasili wrote: allocaBytes (#const

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Galchin, Vasili
Hi Brandon, So based on what you are saying I kind of need a Haskell AIO imperative/monadic function that basically returns a handle that is associated with this AIOCB chunk-of-memory This handle gets passed around during an AIO I/O session?? Sorry for talking too imperatively ;^)

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Brandon S. Allbery KF8NH
On 2008 Jul 28, at 2:36, Galchin, Vasili wrote: Hi Brandon, So even if I go to ForeignPtr is a problem? And/Or is this a by reference vs by value issue? As I read your code, you're allocating a C object, poking the Haskell fields into it, and passing it on, then peeking the

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Brandon S. Allbery KF8NH
On 2008 Jul 28, at 2:41, Galchin, Vasili wrote: So based on what you are saying I kind of need a Haskell AIO imperative/monadic function that basically returns a handle that is associated with this AIOCB chunk-of-memory This handle gets passed around during an AIO I/O session??

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Galchin, Vasili
Brandon, Your reading on my code is quite correct. So you are suggesting that the Haskell aiocb contain a ForeignPtr to actual aiocb that is passed the C functions. In this scenario, whose responsibility to allocate the chunk of memory for the aiocb? Vasili On Mon, Jul 28, 2008 at 2:04

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Galchin, Vasili
So at the moment you're using using Storable and a Haskell record, say: data AIOCB = AIOCB { ... } and we're suggesting instead: newtype AIOCB = AIOCB (ForeignPtr AIOCB) ^^^ I am somewhat new to Haskell. Not a total newbie! But what exactly does the above mean? Are the three

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Felipe Lessa
2008/7/28 Galchin, Vasili [EMAIL PROTECTED]: and we're suggesting instead: newtype AIOCB = AIOCB (ForeignPtr AIOCB) ^^^ I am somewhat new to Haskell. Not a total newbie! But what exactly does the above mean? Are the three references of AIOCB in different namespaces? The first and the

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Galchin, Vasili
Thanks, Felipe. On Mon, Jul 28, 2008 at 8:01 PM, Felipe Lessa [EMAIL PROTECTED]wrote: 2008/7/28 Galchin, Vasili [EMAIL PROTECTED]: and we're suggesting instead: newtype AIOCB = AIOCB (ForeignPtr AIOCB) ^^^ I am somewhat new to Haskell. Not a total newbie! But what exactly

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Galchin, Vasili
what does a datatype with no constructors mean? E.g. data RSAStruct data EVP_PKEY data EVP_CIPHER data EVP_CIPHER_CTX data EVP_MD_CTX data EVP_MD data BIGNUM On Mon, Jul 28, 2008 at 8:01 PM, Felipe Lessa [EMAIL PROTECTED]wrote: 2008/7/28 Galchin, Vasili [EMAIL PROTECTED]: and we're

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Bryan Donlan
On Mon, Jul 28, 2008 at 08:48:23PM -0500, Galchin, Vasili wrote: what does a datatype with no constructors mean? E.g. data RSAStruct data EVP_PKEY data EVP_CIPHER data EVP_CIPHER_CTX data EVP_MD_CTX data EVP_MD data BIGNUM It's simply a datatype that can never have a value - a

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Galchin, Vasili
ok guys .. what is this phantom type concept? Is it a type theory thing or just Haskell type concept? Vasili On Mon, Jul 28, 2008 at 8:53 PM, Bryan Donlan [EMAIL PROTECTED] wrote: On Mon, Jul 28, 2008 at 08:48:23PM -0500, Galchin, Vasili wrote: what does a datatype with no constructors mean?

Re: [Haskell-cafe] carry state around ....

2008-07-28 Thread Austin Seipp
Excerpts from Galchin, Vasili's message of Mon Jul 28 21:14:56 -0500 2008: ok guys .. what is this phantom type concept? Is it a type theory thing or just Haskell type concept? Vasili Phantom types are more of an idiom than anything else; they are types with no real concrete representation,

Re: [Haskell-cafe] carry state around ....

2008-07-27 Thread Galchin, Vasili
Hi Duncan and Brandon, I am moving to the ForeignPtr strategy. However, I always try to learn from where I am before going to a new approach. I have discovered by debugging that the AIOCB peek is working; however, passing the peeked AIOCB back to the caller(i.e. the test program) is not

Re: [Haskell-cafe] carry state around ....

2008-07-21 Thread John Meacham
On Mon, Jul 21, 2008 at 01:05:48PM +1200, Richard A. O'Keefe wrote: I think it may be time for a little clarity about aoicb's. From the Single Unix Specification: The aio.h header shall define the aiocb structure which shall include AT LEAST the following members: int

Re: [Haskell-cafe] carry state around ....

2008-07-20 Thread John Meacham
In order to write portable code that accesses C structures, you need to write a c shim, or better, use the 'hsc2hs' tool to produce portable code. For an example, you can see my OpenSSL binding code in http://repetae.net/repos/ginsu/RSA.hsc in particular the 'createPkey' function. the #ptr

Re: [Haskell-cafe] carry state around ....

2008-07-20 Thread Duncan Coutts
On Sat, 2008-07-19 at 23:55 -0500, Galchin, Vasili wrote: yes Duncan I am trying to pass-by-value. I am familiar with ForeignPtr; however, I don't comprehend what you and Brandon are suggesting to do. Could either of you provide a code illustration or point at existing code to illustrate your

Re: [Haskell-cafe] carry state around ....

2008-07-20 Thread Richard A. O'Keefe
I think it may be time for a little clarity about aoicb's. From the Single Unix Specification: The aio.h header shall define the aiocb structure which shall include AT LEAST the following members: int aio_fildes File descriptor. off_t aio_offset File

Re: [Haskell-cafe] carry state around ....

2008-07-20 Thread Brandon S. Allbery KF8NH
On 2008 Jul 20, at 21:05, Richard A. O'Keefe wrote: For asynchronous I/O, this means that - you can allocate an aiocb object - an aiocb passed to aio_suspend, aio_error, aio_return, or aio_cancel should have been filled in by aio_read or aio_write and should be EXACTLY THE SAME object,

Re: [Haskell-cafe] carry state around ....

2008-07-20 Thread Galchin, Vasili
Thank you Duncan for your example. I will also read the RSA code. Regards, Vasili On Sun, Jul 20, 2008 at 6:51 AM, Duncan Coutts [EMAIL PROTECTED] wrote: On Sat, 2008-07-19 at 23:55 -0500, Galchin, Vasili wrote: yes Duncan I am trying to pass-by-value. I am familiar with ForeignPtr;

[Haskell-cafe] carry state around ....

2008-07-19 Thread Galchin, Vasili
hello, Following is more of a criticism of Linux implementation of the Posix real-time extension of asynchronous I/O if not interesting please skip. The central data structure for Posix AIO is an aiocb. In any case, the Linux implementors added to the aiocb: /* Asynchronous I/O control

Re: [Haskell-cafe] carry state around ....

2008-07-19 Thread Brandon S. Allbery KF8NH
On 2008 Jul 19, at 2:40, Galchin, Vasili wrote: My viewpoint is that the above Internal members must be carried around in a Haskell program. Am I correct?? If I am correct, then the Linux implementation of Posix AIO is not portable to say Solaris? In hindsight, if I am correct, it seems

Re: [Haskell-cafe] carry state around ....

2008-07-19 Thread Duncan Coutts
On Sat, 2008-07-19 at 01:40 -0500, Galchin, Vasili wrote: hello, Following is more of a criticism of Linux implementation of the Posix real-time extension of asynchronous I/O if not interesting please skip. The central data structure for Posix AIO is an aiocb. In any case,

Re: [Haskell-cafe] carry state around ....

2008-07-19 Thread Duncan Coutts
On Sat, 2008-07-19 at 10:45 -0400, Brandon S. Allbery KF8NH wrote: On 2008 Jul 19, at 2:40, Galchin, Vasili wrote: My viewpoint is that the above Internal members must be carried around in a Haskell program. Am I correct?? If I am correct, then the Linux implementation of Posix AIO is

Re: [Haskell-cafe] carry state around ....

2008-07-19 Thread Galchin, Vasili
Brandon, You lost me can you explain what an opaque aiocb would look like? Vasili On Sat, Jul 19, 2008 at 9:45 AM, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: On 2008 Jul 19, at 2:40, Galchin, Vasili wrote: My viewpoint is that the above Internal members must be carried

Re: [Haskell-cafe] carry state around ....

2008-07-19 Thread Brandon S. Allbery KF8NH
On 2008 Jul 19, at 16:42, Galchin, Vasili wrote: You lost me can you explain what an opaque aiocb would look like? In Haskell, it's a ForeignPtr --- you can't see inside it except by FFI calls. Although Duncan is correct and you can use an FFI preprocessor to access the

Re: [Haskell-cafe] carry state around ....

2008-07-19 Thread Galchin, Vasili
yes Duncan I am trying to pass-by-value. I am familiar with ForeignPtr; however, I don't comprehend what you and Brandon are suggesting to do. Could either of you provide a code illustration or point at existing code to illustrate your approach? Kind regards, Vasili On Sat, Jul 19, 2008 at 8:28