2 Commits

Author SHA1 Message Date
271ca13f8b chore: prepare v2.1.2 2024-06-25 14:20:38 -05:00
4a9dbf0a3c fix: relax pipeAsync constraints 2024-06-25 14:20:25 -05:00
3 changed files with 6 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "purescript-node-stream-pipes", "name": "purescript-node-stream-pipes",
"version": "v2.1.1", "version": "v2.1.2",
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"csv-parse": "^5.5.6", "csv-parse": "^5.5.6",

View File

@@ -1,7 +1,7 @@
package: package:
name: node-stream-pipes name: node-stream-pipes
publish: publish:
version: '2.1.1' version: '2.1.2'
license: 'GPL-3.0-or-later' license: 'GPL-3.0-or-later'
location: location:
githubOwner: 'cakekindel' githubOwner: 'cakekindel'

View File

@@ -29,7 +29,6 @@ import Data.Tuple.Nested (type (/\), (/\))
import Effect.Aff.Class (class MonadAff, liftAff) import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Class (class MonadEffect, liftEffect) import Effect.Class (class MonadEffect, liftEffect)
import Effect.Console (log) import Effect.Console (log)
import Effect.Exception (Error, error)
import Effect.Now as Now import Effect.Now as Now
import Pipes (await, yield) import Pipes (await, yield)
import Pipes.Collect as Collect import Pipes.Collect as Collect
@@ -322,19 +321,19 @@ sync m =
-- | -- |
-- | If the consuming half fails, the error is caught, the producing half is killed, and the error is rethrown. -- | If the consuming half fails, the error is caught, the producing half is killed, and the error is rethrown.
pipeAsync pipeAsync
:: forall f m a b :: forall e f m a b
. MonadRec m . MonadRec m
=> MonadAff m => MonadAff m
=> MonadBracket Error f m => MonadBracket e f m
=> Producer (Maybe a) m Unit => Producer (Maybe a) m Unit
-> AsyncPipe (Maybe a) (Maybe b) m Unit -> AsyncPipe (Maybe a) (Maybe b) m Unit
-> Producer (Maybe b) m Unit -> Producer (Maybe b) m Unit
pipeAsync prod m = pipeAsync prod m =
lift (getAsyncIO m) lift (getAsyncIO m)
>>= case _ of >>= case _ of
Nothing -> throwError $ error "`pipeAsync` invoked on `AsyncPipe` that did not have `AsyncIO`" Nothing -> pure unit
Just ({write, read, awaitWrite, awaitRead} /\ done) -> do Just ({write, read, awaitWrite, awaitRead} /\ done) -> do
errST :: STRef _ (Maybe Error) <- lift $ liftEffect $ liftST $ ST.Ref.new Nothing errST :: STRef _ (Maybe e) <- lift $ liftEffect $ liftST $ ST.Ref.new Nothing
killST :: STRef _ Boolean <- lift $ liftEffect $ liftST $ ST.Ref.new false killST :: STRef _ Boolean <- lift $ liftEffect $ liftST $ ST.Ref.new false
let let