Skip to content

Commit 261b030

Browse files
committed
Add semigroup & monoid instances
1 parent e6e1fe9 commit 261b030

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Effect.purs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ module Effect
33
, untilE, whileE, forE, foreachE
44
) where
55

6-
import Control.Applicative (class Applicative, liftA1)
7-
import Control.Apply (class Apply)
8-
import Control.Bind (class Bind)
9-
import Control.Monad (class Monad, ap)
6+
import Prelude
107

11-
import Data.Functor (class Functor)
12-
import Data.Unit (Unit)
8+
import Control.Apply (lift2)
139

1410
-- | The `Effect` type constructor is used to represent _native_ effects.
1511
-- |
@@ -37,6 +33,12 @@ foreign import bindE :: forall a b. Effect a -> (a -> Effect b) -> Effect b
3733

3834
instance monadEffect :: Monad Effect
3935

36+
instance semigroupEffect :: Semigroup a => Semigroup (Effect a) where
37+
append = lift2 append
38+
39+
instance monoidEffect :: Monoid a => Monoid (Effect a) where
40+
mempty = pureE mempty
41+
4042
-- | Loop until a condition becomes `true`.
4143
-- |
4244
-- | `untilE b` is an effectful computation which repeatedly runs the effectful

0 commit comments

Comments
 (0)