Compare commits

..

2 Commits

Author SHA1 Message Date
c73d934a5c
chore: prepare v2.1.1 2024-06-23 20:49:22 -05:00
dc1ba322a9
fix: asyncpipe is mfunctor 2024-06-23 20:49:17 -05:00
3 changed files with 15 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "purescript-node-stream-pipes", "name": "purescript-node-stream-pipes",
"version": "v2.1.0", "version": "v2.1.1",
"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.0' version: '2.1.1'
license: 'GPL-3.0-or-later' license: 'GPL-3.0-or-later'
location: location:
githubOwner: 'cakekindel' githubOwner: 'cakekindel'

View File

@ -8,7 +8,7 @@ import Control.Monad.Error.Class (class MonadError, class MonadThrow, catchError
import Control.Monad.Except (ExceptT, runExceptT) import Control.Monad.Except (ExceptT, runExceptT)
import Control.Monad.Fork.Class (class MonadBracket, class MonadFork, fork) import Control.Monad.Fork.Class (class MonadBracket, class MonadFork, fork)
import Control.Monad.Maybe.Trans (MaybeT(..), runMaybeT) import Control.Monad.Maybe.Trans (MaybeT(..), runMaybeT)
import Control.Monad.Morph (hoist) import Control.Monad.Morph (class MFunctor, hoist)
import Control.Monad.Rec.Class (class MonadRec, Step(..), tailRecM) import Control.Monad.Rec.Class (class MonadRec, Step(..), tailRecM)
import Control.Monad.ST.Class (liftST) import Control.Monad.ST.Class (liftST)
import Control.Monad.ST.Ref (STRef) import Control.Monad.ST.Ref (STRef)
@ -131,6 +131,18 @@ getAsyncIO (Pure _) = pure Nothing
instance MonadTrans (AsyncPipe a b) where instance MonadTrans (AsyncPipe a b) where
lift = M <<< map Pure lift = M <<< map Pure
instance MFunctor (AsyncPipe a b) where
hoist _ (Pure a) = Pure a
hoist f (M m) = M $ f $ hoist f <$> m
hoist f (AsyncIO ({read, write, awaitWrite, awaitRead} /\ m)) =
AsyncIO
$ { read: f read
, write: f <<< write
, awaitWrite: f awaitWrite
, awaitRead: f awaitRead
}
/\ hoist f m
instance Monad m => Functor (AsyncPipe a b m) where instance Monad m => Functor (AsyncPipe a b m) where
map f (Pure r) = Pure $ f r map f (Pure r) = Pure $ f r
map f (M m) = M $ map f <$> m map f (M m) = M $ map f <$> m