Johan Tibell | 10 Mar 13:30 2014
Picon

Proposal: add createPipe to base

I've written a cross-platform* implementation of the pipe() syscall, currently for use within Cabal:

createPipe :: IO (Handle, Handle)
https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat/CreatePipe.hsc

It's a bit of a shame to leave it in Cabal as it's generally useful.

I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.

Discussion period: 3 weeks.

* Only tested on OS X, Windows, and Linux.

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Michael Snoyman | 10 Mar 13:32 2014

Re: Proposal: add createPipe to base




On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell <johan.tibell <at> gmail.com> wrote:
I've written a cross-platform* implementation of the pipe() syscall, currently for use within Cabal:

createPipe :: IO (Handle, Handle)
https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat/CreatePipe.hsc

It's a bit of a shame to leave it in Cabal as it's generally useful.

I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.

Discussion period: 3 weeks.

* Only tested on OS X, Windows, and Linux.


+1. I've needed this in the past when working with process, and ended up writing POSIX-only code as a result.
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Ian Lynagh | 10 Mar 13:47 2014
Picon

Re: Proposal: add createPipe to base

On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote:
> On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell <johan.tibell <at> gmail.com>wrote:
> 
> > I propose we add it to System.IO. Note that we'd have to copy the 5 lines
> > in System.Posix.IO.createPipe into base as the above implementation would
> > otherwise depend on the unix package.
> >
> +1. I've needed this in the past when working with process, and ended up
> writing POSIX-only code as a result.

Would it make more sense to put it in process, and thus avoid needing to
copy/move code into base?

Thanks
Ian
Johan Tibell | 10 Mar 13:54 2014
Picon

Re: Proposal: add createPipe to base

On Mon, Mar 10, 2014 at 1:47 PM, Ian Lynagh <igloo <at> earth.li> wrote:
On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote:
> On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell <johan.tibell <at> gmail.com>wrote:
>
> > I propose we add it to System.IO. Note that we'd have to copy the 5 lines
> > in System.Posix.IO.createPipe into base as the above implementation would
> > otherwise depend on the unix package.
> >
> +1. I've needed this in the past when working with process, and ended up
> writing POSIX-only code as a result.

Would it make more sense to put it in process, and thus avoid needing to
copy/move code into base?

I'm certainly open to that idea. If the only uses of pipes are for processes, I think that makes sense. Are there any typical non-process uses of pipes? I can't think of any right now.

-- Johan

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Brandon Allbery | 10 Mar 14:18 2014
Picon

Re: Proposal: add createPipe to base

On Mon, Mar 10, 2014 at 8:54 AM, Johan Tibell <johan.tibell <at> gmail.com> wrote:
On Mon, Mar 10, 2014 at 1:47 PM, Ian Lynagh <igloo <at> earth.li> wrote:
On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote:
> On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell <johan.tibell <at> gmail.com>wrote:
> > I propose we add it to System.IO. Note that we'd have to copy the 5 lines
> > in System.Posix.IO.createPipe into base as the above implementation would
> > otherwise depend on the unix package.
> >
> +1. I've needed this in the past when working with process, and ended up
> writing POSIX-only code as a result.

Would it make more sense to put it in process, and thus avoid needing to
copy/move code into base?

I'm certainly open to that idea. If the only uses of pipes are for processes, I think that makes sense. Are there any typical non-process uses of pipes? I can't think of any right now.

I know of one in C, and it seems potentially applicable to Haskell as well, but it's mostly(?) a Unix-ism: you allocate a pipe, write to it in a signal handler, and monitor the read end in an event loop (in Haskell, a thread) in order to change an asynchronous signal that may have happened when it's unsafe to e.g. allocate memory into a synchronous event that can be handled safely. Note that you must use an unbuffered write from System.Posix.IO to write from the signal handler safely, so this introduces a hard dependency on the `unix` package; although there may be a win32 equivalent.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b <at> gmail.com                                  ballbery <at> sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Nicolas Trangez | 10 Mar 20:41 2014

Re: Proposal: add createPipe to base


On Mar 10, 2014 1:54 PM, "Johan Tibell" <johan.tibell <at> gmail.com> wrote:
>
> On Mon, Mar 10, 2014 at 1:47 PM, Ian Lynagh <igloo <at> earth.li> wrote:
>>
>> On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote:
>> > On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell <johan.tibell <at> gmail.com>wrote:
>> >
>> > > I propose we add it to System.IO. Note that we'd have to copy the 5 lines
>> > > in System.Posix.IO.createPipe into base as the above implementation would
>> > > otherwise depend on the unix package.
>> > >
>> > +1. I've needed this in the past when working with process, and ended up
>> > writing POSIX-only code as a result.
>>
>> Would it make more sense to put it in process, and thus avoid needing to
>> copy/move code into base?
>
>
> I'm certainly open to that idea. If the only uses of pipes are for processes, I think that makes sense. Are there any typical non-process uses of pipes? I can't think of any right now.

Yes: transferring data from one socket to another in a zero-copy fashion using the 'splice' syscall in Linux requires passing stuff through a pipe (used as a buffer).
I for one wouldn't consider a dependency on 'process' to write such code (if I ever would in Haskell...) to be a problem though.

Nicolas

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Michael Snoyman | 10 Mar 14:01 2014

Re: Proposal: add createPipe to base




On Mon, Mar 10, 2014 at 2:47 PM, Ian Lynagh <igloo <at> earth.li> wrote:
On Mon, Mar 10, 2014 at 02:32:06PM +0200, Michael Snoyman wrote:
> On Mon, Mar 10, 2014 at 2:30 PM, Johan Tibell <johan.tibell <at> gmail.com>wrote:
>
> > I propose we add it to System.IO. Note that we'd have to copy the 5 lines
> > in System.Posix.IO.createPipe into base as the above implementation would
> > otherwise depend on the unix package.
> >
> +1. I've needed this in the past when working with process, and ended up
> writing POSIX-only code as a result.

Would it make more sense to put it in process, and thus avoid needing to
copy/move code into base?



I have no opinion on where it should go, process would be fine with me.

Michael 
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Stefan Holdermans | 11 Mar 06:08 2014

Re: Proposal: add createPipe to base

>>> I propose we add it to System.IO. Note that we'd have to copy the 5 lines
>>> in System.Posix.IO.createPipe into base as the above implementation would
>>> otherwise depend on the unix package.
>>> 
>> +1. I've needed this in the past when working with process, and ended up
>> writing POSIX-only code as a result.

+1 one from me, with a preference for process over base.

Cheers,

  Stefan
Johan Tibell | 30 Mar 16:45 2014
Picon

Re: Proposal: add createPipe to base

Since everyone is in favor, I will add createPipe to the process package, as most people seemed to prefer that to base.


On Tue, Mar 11, 2014 at 6:08 AM, Stefan Holdermans <stefan <at> vectorfabrics.com> wrote:
>>> I propose we add it to System.IO. Note that we'd have to copy the 5 lines
>>> in System.Posix.IO.createPipe into base as the above implementation would
>>> otherwise depend on the unix package.
>>>
>> +1. I've needed this in the past when working with process, and ended up
>> writing POSIX-only code as a result.

+1 one from me, with a preference for process over base.

Cheers,

  Stefan

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Edward Kmett | 10 Mar 20:29 2014
Picon

Re: Proposal: add createPipe to base

+1 for me. 

I have a slight preference for putting it in process over base given that we're considering a mass exodus of material from base in a couple of years and it'd be one more thing to move, but it is a very slight preference.

-Edward




On Mon, Mar 10, 2014 at 8:30 AM, Johan Tibell <johan.tibell <at> gmail.com> wrote:
I've written a cross-platform* implementation of the pipe() syscall, currently for use within Cabal:

createPipe :: IO (Handle, Handle)
https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat/CreatePipe.hsc

It's a bit of a shame to leave it in Cabal as it's generally useful.

I propose we add it to System.IO. Note that we'd have to copy the 5 lines in System.Posix.IO.createPipe into base as the above implementation would otherwise depend on the unix package.

Discussion period: 3 weeks.

* Only tested on OS X, Windows, and Linux.


_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Herbert Valerio Riedel | 10 Mar 21:04 2014
Picon

Re: Proposal: add createPipe to base

On 2014-03-10 at 13:30:05 +0100, Johan Tibell wrote:
> I've written a cross-platform* implementation of the pipe() syscall,
> currently for use within Cabal:
>
> createPipe :: IO (Handle, Handle)
> https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat/CreatePipe.hsc
>
> It's a bit of a shame to leave it in Cabal as it's generally useful.
>
> I propose we add it to System.IO. Note that we'd have to copy the 5 lines
> in System.Posix.IO.createPipe into base as the above implementation would
> otherwise depend on the unix package.

+1 from me (with a preference to put it in 'process' if that's still on the table)
Simon Marlow | 7 Apr 11:19 2014
Picon

Re: Proposal: add createPipe to base

The link below is 404'd, but... I seem to remember that on Windows there 
are subtleties to do with whether the pipe ends are inheritable by 
subprocesses or not.  See mkAnonPipe() in the process package for how we 
deal with this already in process.

+1 for having it in process.

Cheers,
Simon

On 10/03/2014 12:30, Johan Tibell wrote:
> I've written a cross-platform* implementation of the pipe() syscall,
> currently for use within Cabal:
>
> createPipe :: IO (Handle, Handle)
> https://github.com/haskell/cabal/blob/master/Cabal/tests/Distribution/Compat/CreatePipe.hsc
>
> It's a bit of a shame to leave it in Cabal as it's generally useful.
>
> I propose we add it to System.IO. Note that we'd have to copy the 5
> lines in System.Posix.IO.createPipe into base as the above
> implementation would otherwise depend on the unix package.
>
> Discussion period: 3 weeks.
>
> * Only tested on OS X, Windows, and Linux.
>
>
>
> _______________________________________________
> Libraries mailing list
> Libraries <at> haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>

Gmane