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

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

import Control.Monad.Cont
import Data.Monoid.Reducer

instance (Monoid m) => Monoid (Cont r m) where
    mempty = return mempty
    mappend = liftM2 mappend

instance (Monad m, Monoid n) => Monoid (ContT r m n) where
    mempty = return mempty 
    mappend = liftM2 mappend

instance Monoid m => Reducer m (Cont r m) where
    unit = return

instance (Monad m, Monoid n) => Reducer n (ContT r m n) where
    unit = return

instance (Monad m, Monoid n) => Reducer (m n) (ContT r m n) where
    unit = lift