Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit 8a2317f

Browse files
Update modifyState to return the internal state.
1 parent cd1404d commit 8a2317f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/State.purs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ getRender = map fst <<< pure <<< runStore =<< get
4242
-- | (`state -> state`) within the `Store`. We can do this with the `seeks`
4343
-- | function from `Control.Comonad.Store`. You could use this directly, or
4444
-- | write helpers like the ones provided here.
45-
-- | make it feel more natural.
4645
-- |
4746
-- | ```purescript
4847
-- | -- without helpers
4948
-- | H.modify_ $ seeks $ \st -> st { field = newValue }
5049
-- | -- with helpers
5150
-- | modifyState_ \st -> st { field = newValue }
5251
-- | ```
53-
modifyState :: m s a. MonadState (Store s a) m => (s -> s) -> m (Store s a)
54-
modifyState = modify <<< seeks
52+
modifyState :: m s a. MonadState (Store s a) m => (s -> s) -> m s
53+
modifyState f = map snd <<< pure <<< runStore =<< modify (seeks f)
5554

5655
modifyState_ :: m s a. MonadState (Store s a) m => (s -> s) -> m Unit
5756
modifyState_ = modify_ <<< seeks

0 commit comments

Comments
 (0)