Skip to content

Define Monoid instance for ReaderT #97

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 3 commits into from
Jun 3, 2017
Merged
Show file tree
Hide file tree
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: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"test": "pulp test"
},
"devDependencies": {
"pulp": "^10.0.4",
"purescript-psa": "^0.5.0-rc.1",
"pulp": "^11.0.0",
"purescript-psa": "^0.5.1",
"rimraf": "^2.6.1"
}
}
8 changes: 8 additions & 0 deletions src/Control/Monad/Reader/Trans.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Prelude

import Control.Alt (class Alt, (<|>))
import Control.Alternative (class Alternative)
import Control.Apply (lift2)
import Control.Monad.Cont.Class (class MonadCont, callCC)
import Control.Monad.Eff.Class (class MonadEff, liftEff)
import Control.Monad.Error.Class (class MonadThrow, class MonadError, catchError, throwError)
Expand All @@ -23,6 +24,7 @@ import Control.MonadZero (class MonadZero)
import Control.Plus (class Plus, empty)

import Data.Distributive (class Distributive, distribute, collect)
import Data.Monoid (class Monoid, mempty)
import Data.Newtype (class Newtype)

-- | The reader monad transformer.
Expand Down Expand Up @@ -72,6 +74,12 @@ instance monadReaderT :: Monad m => Monad (ReaderT r m)

instance monadZeroReaderT :: MonadZero m => MonadZero (ReaderT r m)

instance semigroupReaderT :: (Apply m, Semigroup a) => Semigroup (ReaderT s m a) where
append = lift2 (<>)

instance monoidReaderT :: (Applicative m, Monoid a) => Monoid (ReaderT s m a) where
mempty = pure mempty

instance monadPlusReaderT :: MonadPlus m => MonadPlus (ReaderT r m)

instance monadTransReaderT :: MonadTrans (ReaderT r) where
Expand Down