wip: explore removing delays

This commit is contained in:
orion 2024-05-13 21:06:41 -05:00
parent e05c74f42f
commit d3b8d1792d
Signed by: orion
GPG Key ID: 6D4165AE4C928719
4 changed files with 1 additions and 10 deletions

View File

@ -13,7 +13,6 @@ workspace:
- lists: ">=7.0.0 <8.0.0" - lists: ">=7.0.0 <8.0.0"
- maybe: ">=6.0.0 <7.0.0" - maybe: ">=6.0.0 <7.0.0"
- mmorph: ">=7.0.0 <8.0.0" - mmorph: ">=7.0.0 <8.0.0"
- newtype: ">=5.0.0 <6.0.0"
- node-buffer: ">=9.0.0 <10.0.0" - node-buffer: ">=9.0.0 <10.0.0"
- node-event-emitter: ">=3.0.0 <4.0.0" - node-event-emitter: ">=3.0.0 <4.0.0"
- node-fs: ">=9.1.0 <10.0.0" - node-fs: ">=9.1.0 <10.0.0"

View File

@ -20,7 +20,6 @@ package:
- lists: ">=7.0.0 <8.0.0" - lists: ">=7.0.0 <8.0.0"
- maybe: ">=6.0.0 <7.0.0" - maybe: ">=6.0.0 <7.0.0"
- mmorph: ">=7.0.0 <8.0.0" - mmorph: ">=7.0.0 <8.0.0"
- newtype: ">=5.0.0 <6.0.0"
- node-buffer: ">=9.0.0 <10.0.0" - node-buffer: ">=9.0.0 <10.0.0"
- node-event-emitter: ">=3.0.0 <4.0.0" - node-event-emitter: ">=3.0.0 <4.0.0"
- node-fs: ">=9.1.0 <10.0.0" - node-fs: ">=9.1.0 <10.0.0"

View File

@ -1 +0,0 @@
module Pipes.CSV.Parse where

View File

@ -8,10 +8,8 @@ import Control.Monad.ST.Class (liftST)
import Control.Monad.ST.Ref as STRef import Control.Monad.ST.Ref as STRef
import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Class (lift)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Newtype (wrap)
import Data.Traversable (for_) import Data.Traversable (for_)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (delay)
import Effect.Aff.Class (class MonadAff, liftAff) import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Effect.Exception (Error) import Effect.Exception (Error)
@ -34,7 +32,6 @@ fromReadable r =
pure $ Done unit pure $ Done unit
go { error, cancel } = do go { error, cancel } = do
liftAff $ delay $ wrap 0.0
err <- liftEffect $ liftST $ STRef.read error err <- liftEffect $ liftST $ STRef.read error
for_ err throwError for_ err throwError
@ -62,7 +59,6 @@ fromWritable w =
pure $ Done unit pure $ Done unit
go { error, cancel } = do go { error, cancel } = do
liftAff $ delay $ wrap 0.0
err <- liftEffect $ liftST $ STRef.read error err <- liftEffect $ liftST $ STRef.read error
for_ err throwError for_ err throwError
@ -96,7 +92,6 @@ fromTransform t =
pure $ Done unit pure $ Done unit
yieldFromReadableHalf = yieldFromReadableHalf =
flip tailRecM unit $ const do flip tailRecM unit $ const do
liftAff $ delay $ wrap 0.0
res <- liftEffect (O.read t) res <- liftEffect (O.read t)
case res of case res of
O.ReadJust a -> do O.ReadJust a -> do
@ -105,11 +100,9 @@ fromTransform t =
O.ReadWouldBlock -> pure $ Done unit O.ReadWouldBlock -> pure $ Done unit
O.ReadClosed -> yield Nothing $> Done unit O.ReadClosed -> yield Nothing $> Done unit
go { error, cancel } = do go { error, cancel } = do
liftAff $ delay $ wrap 0.0
err <- liftEffect $ liftST $ STRef.read error err <- liftEffect $ liftST $ STRef.read error
for_ err throwError for_ err throwError
yieldFromReadableHalf
ma <- await ma <- await
case ma of case ma of
Nothing -> cleanup cancel Nothing -> cleanup cancel
@ -120,6 +113,7 @@ fromTransform t =
O.WriteClosed -> cleanup cancel O.WriteClosed -> cleanup cancel
O.WriteOk -> pure $ Loop { error, cancel } O.WriteOk -> pure $ Loop { error, cancel }
O.WriteWouldBlock -> do O.WriteWouldBlock -> do
yieldFromReadableHalf
liftAff $ O.awaitWritableOrClosed t liftAff $ O.awaitWritableOrClosed t
pure $ Loop { error, cancel } pure $ Loop { error, cancel }
in in