Skip to content

Alt instance for RWST. #82

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 1 commit into from
Jan 3, 2017
Merged
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
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