{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, GeneralizedNewtypeDeriving #-}------------------------------------------------------------------------------- |-- Module : Data.Monoid.Self-- Copyright : (c) Edward Kmett 2009-- License : BSD-style-- Maintainer : ekmett@gmail.com-- Stability : experimental-- Portability : portable---- A simple 'Monoid' transformer that takes a 'Monoid' m and produces a new @m@-Reducer named 'Self' @m@-- -- This is useful when you have a generator that already contains monoidal values or someone supplies-- the map to the monoid in the form of a function rather than as a "Reducer" instance. You can just-- @'getSelf' . `reduce`@ or @'getSelf' . 'mapReduce' f@ in those scenarios. These behaviors are encapsulated -- into the 'fold' and 'foldMap' combinators in "Data.Monoid.Combinators" respectively.-------------------------------------------------------------------------------moduleData.Monoid.Self(Self(Self,getSelf))whereimportData.Monoid(Monoid(..))importData.Monoid.Reducer(Reducer,unit)newtypeSelfm=Self{getSelf::m}deriving(Monoid)instanceMonoidm=>Reducerm(Selfm)whereunit=SelfinstanceFunctorSelfwherefmapf(Selfx)=Self(fx)