Skip to content

Commit ac33773

Browse files
committed
Add execWriterT
1 parent 129eedf commit ac33773

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/Module.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,8 @@
779779

780780
### Values
781781

782+
execWriterT :: forall w m a. (Monad m) => WriterT w m a -> m w
783+
782784
liftCallCCWriter :: forall w m a b. (Monoid w) => (((Tuple a w -> m (Tuple b w)) -> m (Tuple a w)) -> m (Tuple a w)) -> ((a -> WriterT w m b) -> WriterT w m a) -> WriterT w m a
783785

784786
liftCatchWriter :: forall w m e a. (m (Tuple a w) -> (e -> m (Tuple a w)) -> m (Tuple a w)) -> WriterT w m a -> (e -> WriterT w m a) -> WriterT w m a

src/Control/Monad/Writer/Trans.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ newtype WriterT w m a = WriterT (m (Tuple a w))
1313
runWriterT :: forall w m a. WriterT w m a -> m (Tuple a w)
1414
runWriterT (WriterT x) = x
1515

16+
execWriterT :: forall w m a. (Monad m) => WriterT w m a -> m w
17+
execWriterT m = runWriterT m >>= \(Tuple _ w) -> return w
18+
1619
mapWriterT :: forall w1 w2 m1 m2 a b. (m1 (Tuple a w1) -> m2 (Tuple b w2)) -> WriterT w1 m1 a -> WriterT w2 m2 b
1720
mapWriterT f m = WriterT $ f (runWriterT m)
1821

0 commit comments

Comments
 (0)