Skip to content

Commit c26963e

Browse files
add instance for Star (#28)
* add instance for Star * add Costar instance Co-authored-by: JordanMartinez <[email protected]>
1 parent 1e251c2 commit c26963e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"purescript-maybe": "master",
2424
"purescript-newtype": "master",
2525
"purescript-prelude": "master",
26+
"purescript-profunctor": "master",
2627
"purescript-refs": "master",
2728
"purescript-transformers": "master"
2829
},

src/Control/Parallel/Class.purs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import Data.Either (Either)
1414
import Data.Functor.Compose (Compose(..))
1515
import Data.Maybe (Maybe(..))
1616
import Data.Newtype (class Newtype)
17+
import Data.Profunctor.Costar (Costar(..))
18+
import Data.Profunctor.Star (Star(..))
1719
import Effect.Class (class MonadEffect, liftEffect)
1820
import Effect.Ref as Ref
1921

@@ -39,6 +41,15 @@ instance monadParMaybeT :: Parallel f m => Parallel (Compose f Maybe) (MaybeT m)
3941
parallel (MaybeT ma) = Compose (parallel ma)
4042
sequential (Compose fa) = MaybeT (sequential fa)
4143

44+
instance monadParStar :: Parallel f m => Parallel (Star f a) (Star m a) where
45+
parallel (Star f) = (Star $ parallel <<< f)
46+
sequential (Star f) = (Star $ sequential <<< f)
47+
48+
instance monadParCostar :: Parallel f m => Parallel (Costar f a) (Costar m a) where
49+
parallel (Costar f) = (Costar $ sequential >>> f)
50+
sequential (Costar f) = (Costar $ parallel >>> f)
51+
52+
4253
-- | The `ParCont` type constructor provides an `Applicative` instance
4354
-- | based on `ContT Unit m`, which waits for multiple continuations to be
4455
-- | resumed simultaneously.

0 commit comments

Comments
 (0)