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

module Data.Monoid.Monad.Writer.Lazy
    ( module Control.Monad.Writer.Lazy
    , module Data.Monoid.Reducer
    )  where

import Control.Monad.Writer.Lazy
import Data.Monoid.Reducer

instance (Monoid w, Monoid m) => Monoid (Writer w m) where
    mempty = return mempty
    mappend = liftM2 mappend

instance (Monad m, Monoid w, Monoid n) => Monoid (WriterT w m n) where
    mempty = return mempty 
    mappend = liftM2 mappend

instance (Monoid w, Monoid m) => Reducer m (Writer w m) where
    unit = return

instance (Monad m, Monoid w, Monoid n) => Reducer n (WriterT w m n) where
    unit = return

instance (Monad m, Monoid w, Monoid n) => Reducer (m n) (WriterT w m n) where
    unit = lift