The word you are looking for, as many others have said, is "endomorphism." But in a more specific note, it is worth mentioning the Endo type in Data.Monoid :
data Endo a = Endo { appEndo :: a -> a } instance Monoid (Endo a) where mempty = Endo id Endo f `mappend` Endo g = Endo (f . g)
This type is sometimes useful. For example, as Brent Yorgi explains, the folds are made of monoids :
import Data.Monoid foldr :: (a -> b -> b) -> b -> [a] -> b foldr fz xs = appEndo (mconcat (map (Endo . f) xs)) z foldl :: (b -> a -> b) -> b -> [a] -> b foldl fz xs = appEndo (mconcat (map (Endo . flip f) (reverse xs))) z
Thus, since monoids are associative, folding can often be parallelized (with a division and rest strategy), first rewriting them in terms of Endo , and then replacing the specific Endo b for this fold with a slightly more specific type that allows you to do some work on each mappend step.
source share