Skip to content

Add execWriterT #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,9 @@

### Values

evalStateT :: forall s m a. (Monad m) => StateT s m a -> s -> m a
evalStateT :: forall s m a. (Apply m) => StateT s m a -> s -> m a

execStateT :: forall s m a. (Monad m) => StateT s m a -> s -> m s
execStateT :: forall s m a. (Apply m) => StateT s m a -> s -> m s

liftCallCCState :: forall s m a b. (((Tuple a s -> m (Tuple b s)) -> m (Tuple a s)) -> m (Tuple a s)) -> ((a -> StateT s m b) -> StateT s m a) -> StateT s m a

Expand Down Expand Up @@ -779,6 +779,8 @@

### Values

execWriterT :: forall w m a. (Apply m) => WriterT w m a -> m w

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

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
Expand Down
8 changes: 4 additions & 4 deletions src/Control/Monad/State/Trans.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ newtype StateT s m a = StateT (s -> m (Tuple a s))
runStateT :: forall s m a. StateT s m a -> s -> m (Tuple a s)
runStateT (StateT s) = s

evalStateT :: forall s m a. (Monad m) => StateT s m a -> s -> m a
evalStateT m s = runStateT m s >>= \(Tuple x _) -> return x
evalStateT :: forall s m a. (Apply m) => StateT s m a -> s -> m a
evalStateT m s = fst <$> runStateT m s

execStateT :: forall s m a. (Monad m) => StateT s m a -> s -> m s
execStateT m s = runStateT m s >>= \(Tuple _ s) -> return s
execStateT :: forall s m a. (Apply m) => StateT s m a -> s -> m s
execStateT m s = snd <$> runStateT m s

mapStateT :: forall s m1 m2 a b. (m1 (Tuple a s) -> m2 (Tuple b s)) -> StateT s m1 a -> StateT s m2 b
mapStateT f m = StateT $ f <<< runStateT m
Expand Down
3 changes: 3 additions & 0 deletions src/Control/Monad/Writer/Trans.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ newtype WriterT w m a = WriterT (m (Tuple a w))
runWriterT :: forall w m a. WriterT w m a -> m (Tuple a w)
runWriterT (WriterT x) = x

execWriterT :: forall w m a. (Apply m) => WriterT w m a -> m w
execWriterT m = snd <$> runWriterT m

mapWriterT :: forall w1 w2 m1 m2 a b. (m1 (Tuple a w1) -> m2 (Tuple b w2)) -> WriterT w1 m1 a -> WriterT w2 m2 b
mapWriterT f m = WriterT $ f (runWriterT m)

Expand Down