Skip to content

Commit 25935d1

Browse files
committed
Merge pull request #61 from xuwei-k/WriterT-Semigroup
relax WriterT instance constraints
2 parents a46b635 + 07b768b commit 25935d1

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

docs/Control/Monad/Writer/Trans.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ The `MonadWriter` type class describes the operations supported by this monad.
1919
##### Instances
2020
``` purescript
2121
instance functorWriterT :: (Functor m) => Functor (WriterT w m)
22-
instance applyWriterT :: (Monoid w, Apply m) => Apply (WriterT w m)
22+
instance applyWriterT :: (Semigroup w, Apply m) => Apply (WriterT w m)
2323
instance applicativeWriterT :: (Monoid w, Applicative m) => Applicative (WriterT w m)
24-
instance altWriterT :: (Monoid w, Alt m) => Alt (WriterT w m)
25-
instance plusWriterT :: (Monoid w, Plus m) => Plus (WriterT w m)
24+
instance altWriterT :: (Alt m) => Alt (WriterT w m)
25+
instance plusWriterT :: (Plus m) => Plus (WriterT w m)
2626
instance alternativeWriterT :: (Monoid w, Alternative m) => Alternative (WriterT w m)
27-
instance bindWriterT :: (Monoid w, Monad m) => Bind (WriterT w m)
27+
instance bindWriterT :: (Semigroup w, Monad m) => Bind (WriterT w m)
2828
instance monadWriterT :: (Monoid w, Monad m) => Monad (WriterT w m)
2929
instance monadRecWriterT :: (Monoid w, MonadRec m) => MonadRec (WriterT w m)
3030
instance monadPlusWriterT :: (Monoid w, MonadPlus m) => MonadPlus (WriterT w m)

src/Control/Monad/Writer/Trans.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,23 @@ mapWriterT f m = WriterT $ f (runWriterT m)
4848
instance functorWriterT :: (Functor m) => Functor (WriterT w m) where
4949
map f = mapWriterT $ (<$>) \(Tuple a w) -> Tuple (f a) w
5050

51-
instance applyWriterT :: (Monoid w, Apply m) => Apply (WriterT w m) where
51+
instance applyWriterT :: (Semigroup w, Apply m) => Apply (WriterT w m) where
5252
apply f v = WriterT $
5353
let k (Tuple a w) (Tuple b w') = Tuple (a b) (w <> w')
5454
in k <$> (runWriterT f) <*> (runWriterT v)
5555

5656
instance applicativeWriterT :: (Monoid w, Applicative m) => Applicative (WriterT w m) where
5757
pure a = WriterT $ pure $ Tuple a mempty
5858

59-
instance altWriterT :: (Monoid w, Alt m) => Alt (WriterT w m) where
59+
instance altWriterT :: (Alt m) => Alt (WriterT w m) where
6060
alt m n = WriterT $ runWriterT m <|> runWriterT n
6161

62-
instance plusWriterT :: (Monoid w, Plus m) => Plus (WriterT w m) where
62+
instance plusWriterT :: (Plus m) => Plus (WriterT w m) where
6363
empty = WriterT empty
6464

6565
instance alternativeWriterT :: (Monoid w, Alternative m) => Alternative (WriterT w m)
6666

67-
instance bindWriterT :: (Monoid w, Monad m) => Bind (WriterT w m) where
67+
instance bindWriterT :: (Semigroup w, Monad m) => Bind (WriterT w m) where
6868
bind m k = WriterT $ do
6969
Tuple a w <- runWriterT m
7070
Tuple b w' <- runWriterT (k a)

0 commit comments

Comments
 (0)