Gabriella439 / pipes-concurrency

Concurrency for the pipes ecosystem
BSD 3-Clause "New" or "Revised" License
43 stars 12 forks source link

Scoped spawn #33

Closed pthariensflame closed 9 years ago

pthariensflame commented 9 years ago

I find this function useful in my own code, and I thought I'd ask if it could be added to pipes-concurrency proper.

The name spawnWithin is easily negotiable, of course. :)

Gabriella439 commented 9 years ago

I was thinking of adding this using the managed library, in this form:

spawned :: Buffer a -> Managed (Output a, Input a)

Then you could write:

with (spawned buffer) (\(output, input) -> ...)

The only disadvantage would be a dependency on the managed library.

pthariensflame commented 9 years ago

Perhaps it could go in a pipes-managed library?

Gabriella439 commented 9 years ago

Then I'll go ahead and accept the type signature you propose and defer the Managed version for later. Could you write this up, but with the name withSpawn?

Gabriella439 commented 9 years ago

Oops, I just realized this was a pull request. Could you also use bracket to ensure that the release happens deterministically in the face of exceptions?

pthariensflame commented 9 years ago

@Gabriel439 Sure. I'll make those changes ASAP.

pthariensflame commented 9 years ago

Ready!

Gabriella439 commented 9 years ago

One last thing: just add it to the exports list

pthariensflame commented 9 years ago

Ah, right, I'm dumb!

Gabriella439 commented 9 years ago

It's okay. I make the same mistake all the time! :)

Gabriella439 commented 9 years ago

Thanks again for taking the time to contribute that! :)

pthariensflame commented 9 years ago

You're very welcome! :)