@@ -19,13 +19,15 @@ import Data.Profunctor.Star (Star(..))
19
19
import Effect.Class (class MonadEffect , liftEffect )
20
20
import Effect.Ref as Ref
21
21
22
- -- | The `Parallel` class abstracts over monads which support
23
- -- | parallel composition via some related `Applicative`.
24
- class (Monad m , Applicative f ) <= Parallel f m | m -> f , f -> m where
22
+ -- | The `Parallel` class abstracts over pairs of `Apply`s where one of them
23
+ -- | (`m`) composes sequentially, and the other (`f`) composes in parallel.
24
+ -- | `m` is usually a `Monad`, which enforces the sequential nature of its
25
+ -- | composition, but it doesn't need to be.
26
+ class (Apply m , Apply f ) <= Parallel f m | m -> f , f -> m where
25
27
parallel :: m ~> f
26
28
sequential :: f ~> m
27
29
28
- instance monadParExceptT :: Parallel f m => Parallel (Compose f (Either e )) (ExceptT e m ) where
30
+ instance monadParExceptT :: ( Parallel f m , Monad m ) => Parallel (Compose f (Either e )) (ExceptT e m ) where
29
31
parallel (ExceptT ma) = Compose (parallel ma)
30
32
sequential (Compose fa) = ExceptT (sequential fa)
31
33
@@ -37,7 +39,7 @@ instance monadParWriterT :: (Monoid w, Parallel f m) => Parallel (WriterT w f) (
37
39
parallel = mapWriterT parallel
38
40
sequential = mapWriterT sequential
39
41
40
- instance monadParMaybeT :: Parallel f m => Parallel (Compose f Maybe ) (MaybeT m ) where
42
+ instance monadParMaybeT :: ( Parallel f m , Monad m ) => Parallel (Compose f Maybe ) (MaybeT m ) where
41
43
parallel (MaybeT ma) = Compose (parallel ma)
42
44
sequential (Compose fa) = MaybeT (sequential fa)
43
45
@@ -49,7 +51,6 @@ instance monadParCostar :: Parallel f m => Parallel (Costar f a) (Costar m a) wh
49
51
parallel (Costar f) = (Costar $ sequential >>> f)
50
52
sequential (Costar f) = (Costar $ parallel >>> f)
51
53
52
-
53
54
-- | The `ParCont` type constructor provides an `Applicative` instance
54
55
-- | based on `ContT Unit m`, which waits for multiple continuations to be
55
56
-- | resumed simultaneously.
0 commit comments