Skip to content

Commit 7b82f15

Browse files
authored
Merge pull request #82 from mlang/altRWST
Alt instance for RWST.
2 parents ab7ccac + 43e7f0c commit 7b82f15

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Control/Monad/RWS/Trans.purs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Control.Monad.RWS.Trans
88

99
import Prelude
1010

11+
import Control.Alt (class Alt, (<|>))
1112
import Control.Monad.Eff.Class (class MonadEff, liftEff)
1213
import Control.Monad.Error.Class (class MonadError, throwError, catchError)
1314
import Control.Monad.Reader.Class (class MonadAsk, class MonadReader)
@@ -58,6 +59,9 @@ instance applyRWST :: (Bind m, Monoid w) => Apply (RWST r w s m) where
5859
m r s' <#> \(RWSResult s'' a'' w'') ->
5960
RWSResult s'' (f' a'') (w' <> w'')
6061

62+
instance altRWST :: Alt m => Alt (RWST r w s m) where
63+
alt (RWST m) (RWST n) = RWST $ \ r s -> m r s <|> n r s
64+
6165
instance bindRWST :: (Bind m, Monoid w) => Bind (RWST r w s m) where
6266
bind (RWST m) f = RWST \r s ->
6367
m r s >>= \(RWSResult s' a w) ->

0 commit comments

Comments
 (0)