{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}

module Data.Monoid.Monad.Reader
    ( module Control.Monad.Reader
    , module Data.Monoid.Reducer
    )  where

import Control.Monad.Reader
import Data.Monoid.Reducer

instance Monoid m => Monoid (Reader e m) where
    mempty = return mempty
    mappend = liftM2 mappend

instance Monoid m => Reducer m (Reader e m) where
    unit = return

instance (Monad m, Monoid n) => Monoid (ReaderT e m n) where
    mempty = return mempty
    mappend = liftM2 mappend

instance (Monad m, Monoid n) => Reducer n (ReaderT e m n) where
    unit = return

instance (Monad m, Monoid n) => Reducer (m n) (ReaderT e m n) where
    unit = lift