module Data.Monoid.Category where
import qualified Control.Category as Cat
import Data.Monoid.Acme
import Control.Applicative
newtype Composition c = Composition {getComposition :: c}
instance Cat.Category c => Monoid (Composition (c a a)) where
mempty = Composition Cat.id
mappend (Composition a) (Composition b) = Composition $ a Cat.>>> b
newtype RevComposition c = RevComposition {getRevComposition :: c}
instance Cat.Category c => Monoid (RevComposition (c a a)) where
mempty = RevComposition Cat.id
mappend (RevComposition a) (RevComposition b) = RevComposition $ a Cat.<<< b
composeMany :: (Alternative m, Cat.Category cat) => m (cat a a) -> m (cat a a)
composeMany = manyWith Composition getComposition
invComposeMany :: (Alternative m, Cat.Category cat) => m (cat a a) -> m (cat a a)
invComposeMany = manyWith RevComposition getRevComposition