Skip to content

Commit fc68329

Browse files
committed
Merge pull request #14 from purescript-contrib/lazy
Add Lazy instance for StateT
2 parents bda0441 + 737d86e commit fc68329

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

docs/Module.md

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

533533
instance functorStateT :: (Monad m) => Functor (StateT s m)
534534

535+
instance lazy1StateT :: Lazy1 (StateT s m)
536+
535537
instance monadPlusStateT :: (MonadPlus m) => MonadPlus (StateT s m)
536538

537539
instance monadStateT :: (Monad m) => Monad (StateT s m)

src/Control/Monad/State/Trans.purs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Control.Alternative
55
import Control.Plus
66
import Control.Monad.Trans
77
import Control.MonadPlus
8+
import Control.Lazy
89
import Data.Tuple
910

1011
newtype StateT s m a = StateT (s -> m (Tuple a s))
@@ -55,6 +56,9 @@ instance monadTransStateT :: MonadTrans (StateT s) where
5556
x <- m
5657
return $ Tuple x s
5758

59+
instance lazy1StateT :: Lazy1 (StateT s m) where
60+
defer1 f = StateT $ \s -> runStateT (f unit) s
61+
5862
liftCatchState :: forall s m e a. (m (Tuple a s) -> (e -> m (Tuple a s)) -> m (Tuple a s)) -> StateT s m a -> (e -> StateT s m a) -> StateT s m a
5963
liftCatchState catch m h = StateT $ \s -> catch (runStateT m s) (\e -> runStateT (h e) s)
6064

0 commit comments

Comments
 (0)