Skip to content

Commit

Permalink
Merge pull request #82 from mlang/altRWST
Browse files Browse the repository at this point in the history
Alt instance for RWST.
  • Loading branch information
garyb authored Jan 3, 2017
2 parents ab7ccac + 43e7f0c commit 7b82f15
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Control/Monad/RWS/Trans.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Control.Monad.RWS.Trans

import Prelude

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

instance altRWST :: Alt m => Alt (RWST r w s m) where
alt (RWST m) (RWST n) = RWST $ \ r s -> m r s <|> n r s

instance bindRWST :: (Bind m, Monoid w) => Bind (RWST r w s m) where
bind (RWST m) f = RWST \r s ->
m r s >>= \(RWSResult s' a w) ->
Expand Down

0 comments on commit 7b82f15

Please sign in to comment.