Skip to content

Commit aa1fba3

Browse files
authored
Merge pull request #126 from ursi/monadtell
Add subclasses to enforce the type class laws
2 parents ca04d73 + 83a555a commit aa1fba3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Control/Monad/Writer/Class.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Data.Tuple (Tuple(..))
1616
-- | Law:
1717
-- |
1818
-- | - `do { tell x ; tell y } = tell (x <> y)`
19-
class Monad m <= MonadTell w m | m -> w where
19+
class (Semigroup w, Monad m) <= MonadTell w m | m -> w where
2020
tell :: w -> m Unit
2121

2222
-- | An extension of the `MonadTell` class that introduces some operations on
@@ -33,7 +33,7 @@ class Monad m <= MonadTell w m | m -> w where
3333
-- | - `do { tell x ; tell y } = tell (x <> y)`
3434
-- | - `listen (pure a) = pure (Tuple a mempty)`
3535
-- | - `listen (writer a x) = tell x $> Tuple a x`
36-
class MonadTell w m <= MonadWriter w m | m -> w where
36+
class (Monoid w, MonadTell w m) <= MonadWriter w m | m -> w where
3737
listen :: forall a. m a -> m (Tuple a w)
3838
pass :: forall a. m (Tuple a (w -> w)) -> m a
3939

0 commit comments

Comments
 (0)